diff --git a/.gitignore b/.gitignore index c1ee1a3..53eaa21 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ /target -*.tar.zst **/*.rs.bk diff --git a/Cargo.lock b/Cargo.lock index 6c36d9f..6ecf30d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,467 +1,188 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +[[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] -name = "autocfg" -version = "1.1.0" +name = "atty" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +dependencies = [ + "hermit-abi 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "bitflags" -version = "1.3.2" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "cc" -version = "1.0.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.1.8" +version = "2.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d7ae14b20b94cb02149ed21a86c423859cbe18dc7ed69845cace50e52b40a5" dependencies = [ - "bitflags", - "clap_lex", - "is-terminal", - "strsim", - "termcolor", + "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "clap_lex" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "350b9cf31731f9957399229e9b2adc51eeabdfbe9d71d9a0552275fd12710d09" -dependencies = [ - "os_str_bytes", -] - -[[package]] -name = "dirs" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs-sys" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" -dependencies = [ - "libc", - "redox_users", - "winapi", -] - -[[package]] -name = "errno" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" -dependencies = [ - "errno-dragonfly", - "libc", - "winapi", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "getrandom" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - [[package]] name = "hermit-abi" -version = "0.3.1" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" - -[[package]] -name = "indexmap" -version = "1.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" dependencies = [ - "autocfg", - "hashbrown", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1abeb7a0dd0f8181267ff8adc397075586500b81b28a73e8a0208b00fc170fb3" -dependencies = [ - "libc", - "windows-sys", -] - -[[package]] -name = "is-terminal" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b6b32576413a8e69b90e952e4a026476040d81017b80445deda5f2d3921857" -dependencies = [ - "hermit-abi", - "io-lifetimes", - "rustix", - "windows-sys", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libc" -version = "0.2.139" +version = "0.2.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" - -[[package]] -name = "linux-raw-sys" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" [[package]] name = "lqsd" -version = "0.1.1" +version = "0.1.0" dependencies = [ - "clap", - "serde", - "toml", - "xdg", + "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "xdg 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "memchr" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "os_str_bytes" -version = "6.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" - [[package]] name = "proc-macro2" -version = "1.0.51" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" dependencies = [ - "unicode-ident", + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "quote" -version = "1.0.23" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" dependencies = [ - "proc-macro2", -] - -[[package]] -name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags", -] - -[[package]] -name = "redox_users" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" -dependencies = [ - "getrandom", - "redox_syscall", - "thiserror", -] - -[[package]] -name = "rustix" -version = "0.36.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644" -dependencies = [ - "bitflags", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys", - "windows-sys", + "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde" -version = "1.0.152" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" dependencies = [ - "serde_derive", + "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" -version = "1.0.152" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_spanned" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0efd8caf556a6cebd3b285caf480045fcc1ac04f6bd786b09a6f11af30c4fcf4" -dependencies = [ - "serde", + "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "strsim" -version = "0.10.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "1.0.109" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "termcolor" -version = "1.2.0" +name = "textwrap" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" dependencies = [ - "winapi-util", -] - -[[package]] -name = "thiserror" -version = "1.0.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "toml" -version = "0.7.2" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7afcae9e3f0fe2c370fd4657108972cbb2fa9db1b9f84849cefd80741b01cb6" dependencies = [ - "serde", - "serde_spanned", - "toml_datetime", - "toml_edit", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "toml_datetime" -version = "0.6.1" +name = "unicode-width" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" -dependencies = [ - "serde", -] [[package]] -name = "toml_edit" -version = "0.19.4" +name = "unicode-xid" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a1eb0622d28f4b9c90adc4ea4b2b46b47663fde9ac5fafcb14a1369d5508825" -dependencies = [ - "indexmap", - "serde", - "serde_spanned", - "toml_datetime", - "winnow", -] [[package]] -name = "unicode-ident" -version = "1.0.6" +name = "vec_map" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "winapi" -version = "0.3.9" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", + "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-targets" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" - -[[package]] -name = "windows_i686_gnu" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" - -[[package]] -name = "windows_i686_msvc" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" - -[[package]] -name = "winnow" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faf09497b8f8b5ac5d3bb4d05c0a99be20f26fd3d5f2db7b0716e946d5103658" -dependencies = [ - "memchr", -] [[package]] name = "xdg" -version = "2.4.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4583db5cbd4c4c0303df2d15af80f0539db703fa1c68802d4cbbd2dd0f88f6" -dependencies = [ - "dirs", -] + +[metadata] +"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +"checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" +"checksum hermit-abi 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eff2656d88f158ce120947499e971d743c05dbcbed62e5bd2f38f1698bbc3772" +"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" +"checksum proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548" +"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" +"checksum serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" +"checksum serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" +"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +"checksum syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1e4ff033220a41d1a57d8125eab57bf5263783dfdcc18688b1dacc6ce9651ef8" +"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +"checksum toml 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a" +"checksum unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" +"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" +"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" +"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +"checksum xdg 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57" diff --git a/Cargo.toml b/Cargo.toml index f1b433c..137b668 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,15 +1,15 @@ [package] name = "lqsd" -version = "0.1.1" -authors = ["Marko Korhonen "] +version = "0.1.0" +authors = ["Marko Korhonen "] edition = "2018" publish = false description = "Dims your screen smoothly" -repository = "https://git.korhonen.cc/FunctionalHacker/lqsd" +repository = "https://git.reekynet.com/ReekyMarko/lqsd" license = "MIT" [dependencies] -clap = { version = "4.1.8" } -serde = { version = "1.0.152", features = ["derive"] } -toml = "0.7.2" -xdg = "2.4.1" +clap = "2.33.0" +serde = {version = "1.0.104", features = ["derive"]} +toml = "0.5.6" +xdg = "2.2.0" diff --git a/LICENSE b/LICENCE similarity index 100% rename from LICENSE rename to LICENCE diff --git a/README.adoc b/README.adoc deleted file mode 100644 index f63fdc0..0000000 --- a/README.adoc +++ /dev/null @@ -1,108 +0,0 @@ -= LiQuid Screen Dim - -A simple utility which dims your screen. It saves the previous -brightness too, so you can restore to the point before dimming. - -This is useful if you are running a standalone screen locking setup like -swayidle/swaylock. Check out -https://git.korhonen.cc/FunctionalHacker/dotfiles/src/branch/main/home/.config/sway/scripts/idle.sh[my -configuration files] for an example use case. - -== Usage - -[source] ----- -USAGE: - lqsd [FLAGS] [OPTIONS] - -FLAGS: - -d, --dim Dims the screen to idle level set in configuration - -r, --resume Sets the backlight to the value it was before dimming - --copy-config Copies the default config file to $XDG_CONFIG_HOME/lqsd - -h, --help Prints help information - -V, --version Prints version information - -OPTIONS: - --config Sets a custom config file ----- - -The configuration file resides at `~/.config/lqsd/config.toml`. To copy -the default configuration file in place, you can use `--copy-config`. - -In the configuration file you can set the following values: - -[width="100%",cols="1,2,1",options="header"] -|=== -|Key|Explanation|Default - -|resume_file -|The location where the previous brightness is saved -|/tmp/lqsd-resume - -|idle_level -|The minimum brightness that will be dimmed to. Can be a value between 0-100 -|0 - -|dim_speed -|This sets the "sleep time" between each backlight command. It’s in milliseconds -|50 - -|resume_speed -|Same as dim_speed, but for the resume operation `-r` -|25 -|=== - -== Installation - -=== Dependencies - -The only external dependency is -https://github.com/haikarainen/light[light]. - -=== Building - -Clone this repository and run `cargo build --release` inside the project -to compile a static binary. - -=== Arch Linux - -So far, I have only packaged this for Arch Linux. Packages are in -https://aur.archlinux.org/packages/?K=lqsd[AUR]. - -To install it, use your favorite AUR helper, yay for example: - -[source,nosyntax] ----- -yay -S lqsd ----- - -Select if you want to [1] build from source [2] install a precompiled -binary: - -[source,nosyntax] ----- -:: There are 2 providers available for lqsd: -:: Repository AUR - 1) lqsd 2) lqsd-bin - -Enter a number (default=1): ----- - -== Releases - -Release notes and binaries can be found either in -https://git.korhonen.cc/FunctionalHacker/lqsd/releases[My Git server] or -https://github.com/FunctionalHacker/lqsd/releases[GitHub]. - -== Why Rust? - -I wanted start a small project to learn Rust. Before lqsd, I was using -https://github.com/Bonnee/dotfiles/blob/wayland/scripts/bin/dim.sh[this -script] and figured, why not rewrite it in Rust. - -== Mirrors - -This repository lives at -https://git.korhonen.cc/FunctionalHacker/lqsd[My Git server], but it is -also mirrored to https://github.com/FunctionalHacker/lqsd[GitHub] and -https://gitlab.com/FunctionalHacker/lqsd[GitLab] diff --git a/README.md b/README.md new file mode 100644 index 0000000..04d3a5e --- /dev/null +++ b/README.md @@ -0,0 +1,46 @@ +# LiQuid Screen Dim +A simple utility which dims your screen. It saves the previous brightness too, so you can restore to the point before dimming. + +This is useful if you are running a standalone screen locking setup like swayidle/swaylock. Check out [my configuration files](https://git.reekynet.com/ReekyMarko/dotfiles/src/branch/master/home/Scripts/swayidle.sh) for an example use case. + +## Usage +```nosyntax +USAGE: + lqsd [FLAGS] [OPTIONS] + +FLAGS: + -d, --dim Dims the screen to idle level set in configuration + -h, --help Prints help information + -r, --resume Sets the backlight to the value it was before dimming + -V, --version Prints version information + +OPTIONS: + -c, --config Sets a custom config file +``` +The configuration file resides at `~/.config/lqsd/config.toml`. There you can set these values: + +| Key | Explanation | Default | +| ---------------- | -------------------------------------------------------------------------------------------- | :-----------------: | +| resume_file | The location where the previous brightness is saved | "/tmp/lqsd-resume" | +| idle_level | The minimum brightness that will be dimmed to. Can be a value between 0-100 | 0 | +| dim_speed | This sets the "sleep time" between each backlight command. It's in milliseconds | 50 | +| resume_speed | Same as dim_speed, only for the resume operation `-r` | 25 | + +## Installation +So far, I have only packaged this for [Arch Linux](https://aur.archlinux.org/packages/lqsd) + +To install it, use your favorite AUR helper, yay for example: +```nosyntax +yay -S lqsd +``` + +Or if you don't want to build it from source, a binary version is also available: +```nosyntax +yay -S lqsd-bin +``` + +## Why Rust? +I wanted start a small project to learn Rust. Before lqsd, I was using [this script](https://github.com/Bonnee/dotfiles/blob/wayland/scripts/bin/dim.sh) and figured, why not rewrite it in Rust. + +# Mirrors +This repository lives at [ReekyNET Git](https://git.reekynet.com/ReekyMarko/lqsd), but it is also mirrored to [GitLab](https://gitlab.com/ReekyMarko/lqsd) and [GitHub](https://github.com/ReekyMarko/lqsd) diff --git a/build-release.sh b/build-release.sh deleted file mode 100755 index bb89320..0000000 --- a/build-release.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh - -if [ $# = 1 ]; then - TAG=$1 -else - TAG=$(git tag | tail -1) -fi - -VERSION_NR=$(echo "$TAG" | cut -c2-) - -printf "\e[34m Building release version %s\e[0m\n\n" "$VERSION_NR" - - -printf "\e[34m Checking out %s \e[0m\n\n" "$TAG" -git checkout "tags/$TAG" > /dev/null 2>&1 - -printf "\e[34m Building with cargo\e[0m\n" -cargo build --release --locked - -printf "\n\n" - -printf "\e[34m Copying needed files for release\e[0m\n\n" -mkdir release -cp target/release/lqsd release/ -cp LICENSE release/ -cp manpage.adoc release/ -cd release || return - -printf "\e[34m Signing binary with GPG\e[0m\n" -gpg --detach-sign --armor lqsd - -printf "\n" - -printf "\e[34m Calculating checksums\e[0m\n\n" -sha256sum lqsd > lqsd.sha256 -md5sum lqsd > lqsd.md5 - -printf "\e[34m Verifying GPG signature\e[0m\n" -gpg --verify lqsd.asc - -printf "\n\n" - -printf "\e[34m Validating checksums\e[0m\n" -sha256sum -c lqsd.sha256 -md5sum -c lqsd.md5 - -printf "\n\n" - -printf "\e[34m Building documentation\e[0m\n" -asciidoctor -b manpage manpage.adoc - -printf "\n\n" - -printf "\e[34m Compressing to tar.zst\e[0m\n\n" -tar cf lqsd_"${VERSION_NR}"_x86_64.tar.zst ./* --zstd - -mv ./*.tar.zst .. - -cd .. - -printf "\e[34m removing leftover files\e[0m\n\n" -rm -r release - -printf "\e[34m Returning to main\e[0m\n\n" -git checkout main > /dev/null 2>&1 diff --git a/manpage.adoc b/manpage.adoc deleted file mode 100644 index 2a7ec20..0000000 --- a/manpage.adoc +++ /dev/null @@ -1,31 +0,0 @@ -= lqsd(1) -Marko Korhonen -v0.1.1 -:doctype: manpage -:manmanual: LQSD -:mansource: LQSD -:man-linkstyle: pass:[blue R < >] - -== Name - -lqsd - dim your screen smoothly - -== Synopsis - -*lqsd* [_OPTION_] - -== Options - -*-d, --dim*:: - Dims the screen to idle level set in configuration -*-r, --resume*:: - Sets the backlight to the value it was before dimming -*--copy-config*:: - Copies the default config file to $XDG_CONFIG_HOME/lqsd -*-h, --help*:: - Prints help information -*-V, --version*:: - Prints version information - -== Resources -*Project source code:* https://git.korhonen.cc/FunctionalHacker/lqsd diff --git a/src/cli.rs b/src/cli.rs index f54089b..0f69a8c 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,47 +1,32 @@ extern crate clap; -use clap::{Command, Arg, ArgAction}; +use clap::{App, AppSettings, Arg}; -pub fn app() -> Command { - Command::new("LiQuid Screen Dim") +pub fn get_args() -> clap::ArgMatches<'static> { + App::new("LiQuid Screen Dim") .version(env!("CARGO_PKG_VERSION")) .author(env!("CARGO_PKG_AUTHORS")) .about(env!("CARGO_PKG_DESCRIPTION")) - .arg_required_else_help(true) + .setting(AppSettings::ArgRequiredElseHelp) .arg( - Arg::new("dim") + Arg::with_name("dim") .long("dim") - .short('d') - .action(ArgAction::SetTrue) - .display_order(1) + .short("d") + .takes_value(false) .help("Dims the screen to idle level set in configuration"), ) .arg( - Arg::new("resume") + Arg::with_name("resume") .long("resume") - .short('r') - .action(ArgAction::SetTrue) - .display_order(2) + .short("r") + .takes_value(false) .help("Sets the backlight to the value it was before dimming"), ) .arg( - Arg::new("copy-config") - .long("copy-config") - .action(ArgAction::SetTrue) - .display_order(3) - .help("Copies the default config file to $XDG_CONFIG_HOME/lqsd"), - ) - .arg( - Arg::new("config") - .short('c') + Arg::with_name("config") .long("config") - .num_args(1) - .number_of_values(1) - .value_name("FILE") + .short("c") + .takes_value(true) .help("Sets a custom config file"), ) -} - -#[test] -fn verify_app() { - app().debug_assert(); + .get_matches() } diff --git a/src/config.rs b/src/config.rs index 0aa799d..df90f69 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,84 +1,52 @@ -extern crate xdg; - use super::fs; -use serde::{Deserialize, Serialize}; +use super::Config; use std::path::PathBuf; use xdg::BaseDirectories; -#[derive(Deserialize, Serialize)] -#[serde(default)] -pub struct Config { - pub resume_file: PathBuf, - pub idle_level: i32, - pub dim_speed: u64, - pub resume_speed: u64, -} +extern crate xdg; -impl Default for Config { - fn default() -> Self { - Self { - resume_file: PathBuf::from("/tmp/lqsd-resume"), - idle_level: 0, - dim_speed: 50, - resume_speed: 25, - } +fn default_config() -> Config { + Config { + resume_file: PathBuf::from("/tmp/lqsd-resume"), + idle_level: 0, + dim_speed: 50, + resume_speed: 25, } } -fn read_parse(path: PathBuf) -> Config { - let mut _toml = String::from(""); - - match fs::read(&path) { - Ok(result) => _toml = result, - Err(err) => { - eprintln!("Failed to read config: {}", err); - println!("Using default config"); - return Config::default(); - } - } - - match toml::from_str(&_toml) { - Ok(result) => return result, - Err(err) => { - eprintln!("Failed to read config: {}", err); - println!("Using default config"); - return Config::default(); - } - } -} - -fn xdg_path() -> PathBuf { +fn xdg_config() -> PathBuf { BaseDirectories::with_prefix("lqsd") .expect("cannot create configuration directory") .place_config_file("config.toml") .unwrap() } -pub fn copy_config() { - let path = xdg_path(); +pub fn load_xdg() -> Config { + let path = xdg_config(); + if !path.exists() { - match fs::write(&path, toml::to_string(&Config::default()).unwrap()) { + println!( + "{} does not exist, writing default configuration", + path.display() + ); + match fs::write(&path, toml::to_string(&default_config()).unwrap()) { Ok(()) => println!("Default config saved to {}", path.display()), Err(err) => eprintln!("Failed to write default config: {}", err), }; + default_config() } else { - eprintln!( - "There is a file at {} already. Will not overwrite", - path.display() - ); - } -} - -pub fn load_xdg() -> Config { - let path = xdg_path(); - - if !path.exists() { - Config::default() - } else { - read_parse(xdg_path()) + let toml = fs::read(&path).unwrap(); + let config: Config = toml::from_str(&toml).unwrap(); + config } } pub fn load_user(path: PathBuf) -> Config { - read_parse(path) + if !path.exists() { + panic!("{} does not exist", path.display()); + } else { + let toml = fs::read(&path).unwrap(); + let config: Config = toml::from_str(&toml).unwrap(); + config + } } diff --git a/src/main.rs b/src/main.rs index 79fa066..a15b3b4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,14 +1,22 @@ extern crate clap; -use config::Config; -use std::path::PathBuf; -use std::process::Command; -use std::{thread, time}; - mod cli; mod config; mod fs; +use serde::{Deserialize, Serialize}; +use std::path::PathBuf; +use std::process::Command; +use std::{thread, time}; + +#[derive(Deserialize, Serialize)] +pub struct Config { + resume_file: PathBuf, + idle_level: i32, + dim_speed: u64, + resume_speed: u64, +} + fn transition(w_brightness: i32, speed: time::Duration) { let c_brightness = get_brightness(); println!("Transitioning from {}% to {}%", c_brightness, w_brightness); @@ -49,51 +57,32 @@ fn get_brightness() -> i32 { } fn main() { - let args = cli::app().get_matches(); + let args = cli::get_args(); let conf: Config; - if let Some(config_path) = args.get_one::("config") { - let config_path_buf = PathBuf::from(config_path); - conf = config::load_user(config_path_buf); + if args.is_present("config") { + let config_path = PathBuf::from(args.value_of("config").unwrap()); + conf = config::load_user(config_path); } else { conf = config::load_xdg(); } - let dim_speed = time::Duration::from_millis(conf.dim_speed); let resume_speed = time::Duration::from_millis(conf.resume_speed); - if args.get_flag("dim") { + if args.is_present("dim") { let current_brightness = get_brightness().to_string(); match fs::write(&conf.resume_file, current_brightness) { - Ok(()) => println!( - "Current brightness written to resume file at {}", - conf.resume_file.display() - ), + Ok(()) => println!("Current brightness written to resume file"), Err(err) => eprintln!("Error writing brightness to resume file: {}", err), } transition(conf.idle_level, dim_speed); } - - if args.get_flag("resume") { - let old_brightness: i32; - - match fs::read(&conf.resume_file) { - Ok(result) => old_brightness = result.parse().unwrap(), - Err(err) => { - eprintln!("Failed to read resume_file: {}", err); - old_brightness = 100; - } - } - + if args.is_present("resume") { + let old_brightness: i32 = fs::read(&conf.resume_file).unwrap().parse().unwrap(); transition(old_brightness, resume_speed); - match fs::remove(&conf.resume_file) { Ok(()) => println!("Resume file removed"), Err(err) => eprintln!("Failed to remove resume file: {}", err), } } - - if args.get_flag("copy-config") { - config::copy_config(); - } }