From a807ef3ee20505caf9af818916575998a5636221 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Mon, 20 Jan 2020 00:12:26 +0200 Subject: [PATCH 01/32] Add info about prebuilt binaries Signed-off-by: Marko Korhonen --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 04d3a5e..711817d 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,8 @@ Or if you don't want to build it from source, a binary version is also available yay -S lqsd-bin ``` +Prebuilt binaries, their checksums and signatures live in [GitLab](https://gitlab.com/ReekyMarko/lqsd/releases) + ## 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. From 25db397560b4ffd6ed1bad94c26e8146f051b4cb Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Mon, 20 Jan 2020 02:02:32 +0200 Subject: [PATCH 02/32] Small fixes to readme Signed-off-by: Marko Korhonen --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 711817d..89f12cf 100644 --- a/README.md +++ b/README.md @@ -21,10 +21,10 @@ The configuration file resides at `~/.config/lqsd/config.toml`. There you can se | Key | Explanation | Default | | ---------------- | -------------------------------------------------------------------------------------------- | :-----------------: | -| resume_file | The location where the previous brightness is saved | "/tmp/lqsd-resume" | +| 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 | +| resume_speed | Same as dim_speed, but for the resume operation `-r` | 25 | ## Installation So far, I have only packaged this for [Arch Linux](https://aur.archlinux.org/packages/lqsd) From 4a440f22b53acc4dd507cf9f8b99d8dec71d0dc9 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Mon, 20 Jan 2020 19:45:43 +0200 Subject: [PATCH 03/32] Fix typo in license file name Signed-off-by: Marko Korhonen --- LICENCE => LICENSE | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename LICENCE => LICENSE (100%) diff --git a/LICENCE b/LICENSE similarity index 100% rename from LICENCE rename to LICENSE From 6404ae7463840b50e1ada89785d7dd166e488324 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Mon, 20 Jan 2020 19:51:35 +0200 Subject: [PATCH 04/32] Add information about dependencies and building Signed-off-by: Marko Korhonen --- README.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 89f12cf..928f346 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,17 @@ The configuration file resides at `~/.config/lqsd/config.toml`. There you can se | resume_speed | Same as dim_speed, but for the resume operation `-r` | 25 | ## Installation -So far, I have only packaged this for [Arch Linux](https://aur.archlinux.org/packages/lqsd) + +### Dependencies +The only external dependency is [light](https://github.com/haikarainen/light) + +### Building +Clone this repository and run `cargo build --release` inside the project to compile a static binary. + +Prebuilt binaries, their checksums and signatures live in [GitLab](https://gitlab.com/ReekyMarko/lqsd/releases) + +### Arch Linux +So far, I have only packaged this for Arch Linux. Packages are in [AUR](https://aur.archlinux.org/packages/?K=lqsd) To install it, use your favorite AUR helper, yay for example: ```nosyntax @@ -39,8 +49,6 @@ Or if you don't want to build it from source, a binary version is also available yay -S lqsd-bin ``` -Prebuilt binaries, their checksums and signatures live in [GitLab](https://gitlab.com/ReekyMarko/lqsd/releases) - ## 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. From 04e23c6144fc72c14b9e214d96387e4e24e0c879 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Mon, 20 Jan 2020 21:22:49 +0200 Subject: [PATCH 05/32] Move conf struct to config.rs and impl Default Signed-off-by: Marko Korhonen --- src/config.rs | 30 ++++++++++++++++++++---------- src/main.rs | 16 ++++------------ 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/config.rs b/src/config.rs index df90f69..d32b172 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,16 +1,26 @@ +extern crate xdg; + use super::fs; -use super::Config; +use serde::{Deserialize, Serialize}; use std::path::PathBuf; use xdg::BaseDirectories; -extern crate xdg; +#[derive(Deserialize, Serialize)] +pub struct Config { + pub resume_file: PathBuf, + pub idle_level: i32, + pub dim_speed: u64, + pub resume_speed: u64, +} -fn default_config() -> Config { - Config { - resume_file: PathBuf::from("/tmp/lqsd-resume"), - idle_level: 0, - dim_speed: 50, - resume_speed: 25, +impl Default for Config { + fn default() -> Self { + Self { + resume_file: PathBuf::from("/tmp/lqsd-resume"), + idle_level: 0, + dim_speed: 50, + resume_speed: 25, + } } } @@ -29,11 +39,11 @@ pub fn load_xdg() -> Config { "{} does not exist, writing default configuration", path.display() ); - match fs::write(&path, toml::to_string(&default_config()).unwrap()) { + match fs::write(&path, toml::to_string(&Config::default()).unwrap()) { Ok(()) => println!("Default config saved to {}", path.display()), Err(err) => eprintln!("Failed to write default config: {}", err), }; - default_config() + Config::default() } else { let toml = fs::read(&path).unwrap(); let config: Config = toml::from_str(&toml).unwrap(); diff --git a/src/main.rs b/src/main.rs index a15b3b4..a51992c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,21 +1,13 @@ extern crate clap; -mod cli; -mod config; -mod fs; - -use serde::{Deserialize, Serialize}; +use config::Config; 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, -} +mod cli; +mod config; +mod fs; fn transition(w_brightness: i32, speed: time::Duration) { let c_brightness = get_brightness(); From 242c98256500f5be059fa20e6596e8dbf607e3f5 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Tue, 21 Jan 2020 17:22:17 +0200 Subject: [PATCH 06/32] Begin working on more graceful error handling NOTE: This does not work currently Signed-off-by: Marko Korhonen --- src/config.rs | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/config.rs b/src/config.rs index d32b172..e077d12 100644 --- a/src/config.rs +++ b/src/config.rs @@ -39,15 +39,33 @@ pub fn load_xdg() -> Config { "{} does not exist, writing default configuration", path.display() ); + match fs::write(&path, toml::to_string(&Config::default()).unwrap()) { Ok(()) => println!("Default config saved to {}", path.display()), Err(err) => eprintln!("Failed to write default config: {}", err), }; + Config::default() } else { - let toml = fs::read(&path).unwrap(); - let config: Config = toml::from_str(&toml).unwrap(); - config + let toml: String; + + match fs::read(&path) { + Ok(string) => toml = string, + Err(err) => { + eprintln!("Failed to read config: {}", err); + eprintln!("Using default config"); + return Config::default(); + } + } + + match toml::from_str(&toml) { + Ok(parsed_conf) = parsed_conf, + Err(err) => { + eprintln!("Failed to parse config: {}", err); + eprintln!("Using default config"); + config + } + } } } @@ -56,7 +74,9 @@ pub fn load_user(path: PathBuf) -> Config { panic!("{} does not exist", path.display()); } else { let toml = fs::read(&path).unwrap(); - let config: Config = toml::from_str(&toml).unwrap(); + match toml::from_str(&toml) { + Ok(parsed_conf) -> + } config } } From afe45729881a15aee2d217bfd5280ebf691a4bb3 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Tue, 21 Jan 2020 20:59:06 +0200 Subject: [PATCH 07/32] Added --copy-config and set order within help --- src/cli.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/cli.rs b/src/cli.rs index 0f69a8c..f525130 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -12,6 +12,7 @@ pub fn get_args() -> clap::ArgMatches<'static> { .long("dim") .short("d") .takes_value(false) + .display_order(1) .help("Dims the screen to idle level set in configuration"), ) .arg( @@ -19,13 +20,22 @@ pub fn get_args() -> clap::ArgMatches<'static> { .long("resume") .short("r") .takes_value(false) + .display_order(2) .help("Sets the backlight to the value it was before dimming"), ) + .arg( + Arg::with_name("copy-config") + .long("copy-config") + .takes_value(false) + .display_order(3) + .help("Copies the default config file to $XDG_CONFIG_HOME/lqsd"), + ) .arg( Arg::with_name("config") .long("config") - .short("c") .takes_value(true) + .number_of_values(1) + .value_name("FILE") .help("Sets a custom config file"), ) .get_matches() From c1878b1fab4b07b22a04f372781a272942f94245 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Tue, 21 Jan 2020 20:59:29 +0200 Subject: [PATCH 08/32] Better error handling Now when the configuration file fails to read/parse, we use default config --- src/config.rs | 74 +++++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 40 deletions(-) diff --git a/src/config.rs b/src/config.rs index e077d12..34bc986 100644 --- a/src/config.rs +++ b/src/config.rs @@ -24,59 +24,53 @@ impl Default for Config { } } -fn xdg_config() -> PathBuf { +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 { BaseDirectories::with_prefix("lqsd") .expect("cannot create configuration directory") .place_config_file("config.toml") .unwrap() } +pub fn copy_config() { + let path = xdg_path(); + match fs::write(&path, toml::to_string(&Config::default()).unwrap()) { + Ok(()) => println!("Default config saved to {}", path.display()), + Err(err) => eprintln!("Failed to write default config: {}", err), + }; +} + pub fn load_xdg() -> Config { - let path = xdg_config(); + let path = xdg_path(); if !path.exists() { - println!( - "{} does not exist, writing default configuration", - path.display() - ); - - match fs::write(&path, toml::to_string(&Config::default()).unwrap()) { - Ok(()) => println!("Default config saved to {}", path.display()), - Err(err) => eprintln!("Failed to write default config: {}", err), - }; - Config::default() } else { - let toml: String; - - match fs::read(&path) { - Ok(string) => toml = string, - Err(err) => { - eprintln!("Failed to read config: {}", err); - eprintln!("Using default config"); - return Config::default(); - } - } - - match toml::from_str(&toml) { - Ok(parsed_conf) = parsed_conf, - Err(err) => { - eprintln!("Failed to parse config: {}", err); - eprintln!("Using default config"); - config - } - } + read_parse(xdg_path()) } } pub fn load_user(path: PathBuf) -> Config { - if !path.exists() { - panic!("{} does not exist", path.display()); - } else { - let toml = fs::read(&path).unwrap(); - match toml::from_str(&toml) { - Ok(parsed_conf) -> - } - config - } + read_parse(path) } From 1a016546d817e0bf2d4f62777621ba047c1b9d05 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Tue, 21 Jan 2020 21:00:09 +0200 Subject: [PATCH 09/32] Improve error handling --- src/main.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index a51992c..132ef72 100644 --- a/src/main.rs +++ b/src/main.rs @@ -58,23 +58,42 @@ fn main() { } 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.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"), + Ok(()) => println!( + "Current brightness written to resume file at {}", + conf.resume_file.display() + ), Err(err) => eprintln!("Error writing brightness to resume file: {}", err), } transition(conf.idle_level, dim_speed); } + if args.is_present("resume") { - let old_brightness: i32 = fs::read(&conf.resume_file).unwrap().parse().unwrap(); + 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; + } + } + 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.is_present("copy-config") { + config::copy_config(); + } } From 46092dfe3af207425a376acdc9927820534c5325 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Tue, 21 Jan 2020 21:43:18 +0200 Subject: [PATCH 10/32] Use default value if key is missing --- src/config.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/config.rs b/src/config.rs index 34bc986..5ed933c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -6,6 +6,7 @@ use std::path::PathBuf; use xdg::BaseDirectories; #[derive(Deserialize, Serialize)] +#[serde(default)] pub struct Config { pub resume_file: PathBuf, pub idle_level: i32, From 28f1bc021acda7a9f99d0e112c21b992880c001d Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Tue, 21 Jan 2020 21:50:03 +0200 Subject: [PATCH 11/32] Ignore unused variable --- src/config.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/config.rs b/src/config.rs index 5ed933c..6be1d43 100644 --- a/src/config.rs +++ b/src/config.rs @@ -26,10 +26,10 @@ impl Default for Config { } fn read_parse(path: PathBuf) -> Config { - let mut toml = String::from(""); + let mut _toml = String::from(""); match fs::read(&path) { - Ok(result) => toml = result, + Ok(result) => _toml = result, Err(err) => { eprintln!("Failed to read config: {}", err); println!("Using default config"); @@ -37,7 +37,7 @@ fn read_parse(path: PathBuf) -> Config { } } - match toml::from_str(&toml) { + match toml::from_str(&_toml) { Ok(result) => return result, Err(err) => { eprintln!("Failed to read config: {}", err); From 9740b62d5d51712d135d5c30c031bf885f5a0a2c Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Tue, 21 Jan 2020 21:50:19 +0200 Subject: [PATCH 12/32] Update usage --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 928f346..e6e3801 100644 --- a/README.md +++ b/README.md @@ -9,13 +9,14 @@ 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 + -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: - -c, --config Sets a custom config file + --config Sets a custom config file ``` The configuration file resides at `~/.config/lqsd/config.toml`. There you can set these values: From b17bc4a449695a5f0763ab6d24c8e2714f96c449 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Tue, 21 Jan 2020 22:21:24 +0200 Subject: [PATCH 13/32] Do not overwrite with --copy-config --- src/config.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/config.rs b/src/config.rs index 6be1d43..0aa799d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -56,10 +56,17 @@ fn xdg_path() -> PathBuf { pub fn copy_config() { let path = xdg_path(); - match fs::write(&path, toml::to_string(&Config::default()).unwrap()) { - Ok(()) => println!("Default config saved to {}", path.display()), - Err(err) => eprintln!("Failed to write default config: {}", err), - }; + if !path.exists() { + match fs::write(&path, toml::to_string(&Config::default()).unwrap()) { + Ok(()) => println!("Default config saved to {}", path.display()), + Err(err) => eprintln!("Failed to write default config: {}", err), + }; + } else { + eprintln!( + "There is a file at {} already. Will not overwrite", + path.display() + ); + } } pub fn load_xdg() -> Config { From 86fb3eed8cd0845d6d54e1a2cf7aa71fb0ed9fe5 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Tue, 21 Jan 2020 22:39:58 +0200 Subject: [PATCH 14/32] Moved binaries to GitHub --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e6e3801..928ebd3 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ The only external dependency is [light](https://github.com/haikarainen/light) ### Building Clone this repository and run `cargo build --release` inside the project to compile a static binary. -Prebuilt binaries, their checksums and signatures live in [GitLab](https://gitlab.com/ReekyMarko/lqsd/releases) +Prebuilt binaries, their checksums and signatures live in [GitHub](https://github.com/ReekyMarko/lqsd/releases) ### Arch Linux So far, I have only packaged this for Arch Linux. Packages are in [AUR](https://aur.archlinux.org/packages/?K=lqsd) From 5e995c3549e9bbf0af6b35f12ec0d8d52979545c Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Tue, 21 Jan 2020 23:03:45 +0200 Subject: [PATCH 15/32] Update version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 137b668..a0653fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lqsd" -version = "0.1.0" +version = "0.1.1" authors = ["Marko Korhonen "] edition = "2018" publish = false From 34a4ad997430b8b6f44e085403afd588ca744804 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Tue, 21 Jan 2020 23:03:53 +0200 Subject: [PATCH 16/32] Update dependencies --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6ecf30d..d5e0bbb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -52,7 +52,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "lqsd" -version = "0.1.0" +version = "0.1.1" dependencies = [ "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)", @@ -91,7 +91,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "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)", + "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -101,7 +101,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "syn" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -176,7 +176,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "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 syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5" "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" From 213ac33139c98467a133d80742abcdda63770850 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 22 Jan 2020 00:30:39 +0200 Subject: [PATCH 17/32] Added release build script --- .gitignore | 1 + build-release.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100755 build-release.sh diff --git a/.gitignore b/.gitignore index 53eaa21..c1ee1a3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target +*.tar.zst **/*.rs.bk diff --git a/build-release.sh b/build-release.sh new file mode 100755 index 0000000..a34f60e --- /dev/null +++ b/build-release.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +if (( $# == 1 )); then + TAG=$1 +else + TAG=$(git tag | tail -n1) +fi + +VERSION_NR=$(printf $TAG | cut -c2-) + +printf "\e[34m Building release version $VERSION_NR\e[0m\n\n" + + +printf "\e[34m Checking out $TAG\e[0m\n\n" +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/ +cd release + +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 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 master\e[0m\n\n" +git checkout master > /dev/null 2>&1 From 4ecd409c27e2c003df15d8008d24734f8e9ebd32 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 22 Jan 2020 00:38:15 +0200 Subject: [PATCH 18/32] Add information about release notes --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 928ebd3..7e6d8c9 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,9 @@ The only external dependency is [light](https://github.com/haikarainen/light) ### Building Clone this repository and run `cargo build --release` inside the project to compile a static binary. -Prebuilt binaries, their checksums and signatures live in [GitHub](https://github.com/ReekyMarko/lqsd/releases) +### Releases +Release notes can be found in [GitHub](https://github.com/ReekyMarko/lqsd/releases) (Gitea does not support editing tags yet) +Prebuilt binaries, their checksums and signatures can also be found there ### Arch Linux So far, I have only packaged this for Arch Linux. Packages are in [AUR](https://aur.archlinux.org/packages/?K=lqsd) From b707a298819ec4579bd8d118d89e24cf8372e344 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 22 Jan 2020 00:39:54 +0200 Subject: [PATCH 19/32] Move releases section --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7e6d8c9..22f4ccd 100644 --- a/README.md +++ b/README.md @@ -35,10 +35,6 @@ The only external dependency is [light](https://github.com/haikarainen/light) ### Building Clone this repository and run `cargo build --release` inside the project to compile a static binary. -### Releases -Release notes can be found in [GitHub](https://github.com/ReekyMarko/lqsd/releases) (Gitea does not support editing tags yet) -Prebuilt binaries, their checksums and signatures can also be found there - ### Arch Linux So far, I have only packaged this for Arch Linux. Packages are in [AUR](https://aur.archlinux.org/packages/?K=lqsd) @@ -51,6 +47,10 @@ Or if you don't want to build it from source, a binary version is also available ```nosyntax yay -S lqsd-bin ``` +## Releases +Release notes can be found in [GitHub](https://github.com/ReekyMarko/lqsd/releases) (Gitea does not support editing tags yet) + +Prebuilt binaries, their checksums and signatures can also be found there ## 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. From b15845c62d85dacea03899386ed4ae4d6f1fe5ee Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 22 Jan 2020 00:45:04 +0200 Subject: [PATCH 20/32] Small fixes --- README.md | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 22f4ccd..5d26e1f 100644 --- a/README.md +++ b/README.md @@ -30,30 +30,34 @@ The configuration file resides at `~/.config/lqsd/config.toml`. There you can se ## Installation ### Dependencies -The only external dependency is [light](https://github.com/haikarainen/light) +The only external dependency is [light](https://github.com/haikarainen/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 [AUR](https://aur.archlinux.org/packages/?K=lqsd) +So far, I have only packaged this for Arch Linux. Packages are in [AUR](https://aur.archlinux.org/packages/?K=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: +Select if you want to [1] build from source [2] install a precompiled binary: ```nosyntax -yay -S lqsd-bin -``` -## Releases -Release notes can be found in [GitHub](https://github.com/ReekyMarko/lqsd/releases) (Gitea does not support editing tags yet) +:: There are 2 providers available for lqsd: +:: Repository AUR + 1) lqsd 2) lqsd-bin -Prebuilt binaries, their checksums and signatures can also be found there +Enter a number (default=1): +``` + +## Releases +Release notes can be found in [GitHub](https://github.com/ReekyMarko/lqsd/releases) (Gitea does not support editing tags yet). + +Prebuilt binaries, their checksums and signatures can also be found there. ## 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) +This repository lives at [My Git server](https://git.reekynet.com/ReekyMarko/lqsd), but it is also mirrored to [GitHub](https://github.com/ReekyMarko/lqsd) and [GitLab](https://gitlab.com/ReekyMarko/lqsd) From 7fa060e89654ceeb4d32cfdfd2cb4b9e71b5531a Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 22 Jan 2020 00:47:22 +0200 Subject: [PATCH 21/32] Fix indentation --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5d26e1f..750e196 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ FLAGS: -V, --version Prints version information OPTIONS: - --config Sets a custom config file + --config Sets a custom config file ``` The configuration file resides at `~/.config/lqsd/config.toml`. There you can set these values: From a753dad9f581f2ea5e4e7f54623b08cd54226558 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 22 Jan 2020 00:49:25 +0200 Subject: [PATCH 22/32] Add information about --copy-config --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 750e196..2e84372 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,9 @@ FLAGS: OPTIONS: --config Sets a custom config file ``` -The configuration file resides at `~/.config/lqsd/config.toml`. There you can set these values: +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: | Key | Explanation | Default | | ---------------- | -------------------------------------------------------------------------------------------- | :-----------------: | From 66b4093440ab5a673e7bdc7eaa54d86a82f34da8 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Fri, 4 Dec 2020 18:44:30 +0200 Subject: [PATCH 23/32] Update usernames in some links --- Cargo.toml | 4 ++-- README.md | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a0653fc..06df1ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "lqsd" version = "0.1.1" -authors = ["Marko Korhonen "] +authors = ["Marko Korhonen "] edition = "2018" publish = false description = "Dims your screen smoothly" -repository = "https://git.reekynet.com/ReekyMarko/lqsd" +repository = "https://git.korhonen.cc/FunctionalHacker/lqsd" license = "MIT" [dependencies] diff --git a/README.md b/README.md index 2e84372..08825a5 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # 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. +This is useful if you are running a standalone screen locking setup like swayidle/swaylock. Check out [my configuration files](https://git.korhonen.cc/FunctionalHacker/dotfiles/src/branch/master/home/.config/sway/scripts/idle.sh) for an example use case. ## Usage ```nosyntax @@ -54,7 +54,7 @@ Enter a number (default=1): ``` ## Releases -Release notes can be found in [GitHub](https://github.com/ReekyMarko/lqsd/releases) (Gitea does not support editing tags yet). +Release notes can be found in [GitHub](https://github.com/FunctionalHacker/lqsd/releases) (Gitea does not support editing tags yet). Prebuilt binaries, their checksums and signatures can also be found there. @@ -62,4 +62,4 @@ Prebuilt binaries, their checksums and signatures can also be found there. 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 [My Git server](https://git.reekynet.com/ReekyMarko/lqsd), but it is also mirrored to [GitHub](https://github.com/ReekyMarko/lqsd) and [GitLab](https://gitlab.com/ReekyMarko/lqsd) +This repository lives at [My Git server](https://git.korhonen.cc/FunctionalHacker/lqsd), but it is also mirrored to [GitHub](https://github.com/FunctionalHacker/lqsd) and [GitLab](https://gitlab.com/FunctionalHacker/lqsd) From 493ca5139eac8c50aa5709bbc0868ca2b6892002 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Sun, 12 Jun 2022 11:16:28 +0300 Subject: [PATCH 24/32] Convert README to AsciiDoc --- README.adoc | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 65 -------------------------------- 2 files changed, 104 insertions(+), 65 deletions(-) create mode 100644 README.adoc delete mode 100644 README.md diff --git a/README.adoc b/README.adoc new file mode 100644 index 0000000..846ebdf --- /dev/null +++ b/README.adoc @@ -0,0 +1,104 @@ += 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/master/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 can be found in +https://github.com/FunctionalHacker/lqsd/releases[GitHub] (Gitea does +not support editing tags yet). + +Prebuilt binaries, their checksums and signatures can also be found +there. + +== 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 deleted file mode 100644 index 08825a5..0000000 --- a/README.md +++ /dev/null @@ -1,65 +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 [my configuration files](https://git.korhonen.cc/FunctionalHacker/dotfiles/src/branch/master/home/.config/sway/scripts/idle.sh) for an example use case. - -## Usage -```nosyntax -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: - -| 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 [light](https://github.com/haikarainen/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 [AUR](https://aur.archlinux.org/packages/?K=lqsd). - -To install it, use your favorite AUR helper, yay for example: -```nosyntax -yay -S lqsd -``` -Select if you want to [1] build from source [2] install a precompiled binary: -```nosyntax -:: There are 2 providers available for lqsd: -:: Repository AUR - 1) lqsd 2) lqsd-bin - -Enter a number (default=1): -``` - -## Releases -Release notes can be found in [GitHub](https://github.com/FunctionalHacker/lqsd/releases) (Gitea does not support editing tags yet). - -Prebuilt binaries, their checksums and signatures can also be found there. - -## 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 [My Git server](https://git.korhonen.cc/FunctionalHacker/lqsd), but it is also mirrored to [GitHub](https://github.com/FunctionalHacker/lqsd) and [GitLab](https://gitlab.com/FunctionalHacker/lqsd) From 78cc2ba87d61d226a6054f1d2cc05a23a432d1a2 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Sun, 12 Jun 2022 11:25:44 +0300 Subject: [PATCH 25/32] Use recommended AsciiDoc style of blank lines after section title --- README.adoc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.adoc b/README.adoc index 846ebdf..b06ce04 100644 --- a/README.adoc +++ b/README.adoc @@ -53,15 +53,19 @@ In the configuration file you can set the following values: |=== == 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]. @@ -85,6 +89,7 @@ Enter a number (default=1): ---- == Releases + Release notes can be found in https://github.com/FunctionalHacker/lqsd/releases[GitHub] (Gitea does not support editing tags yet). @@ -93,11 +98,13 @@ Prebuilt binaries, their checksums and signatures can also be found there. == 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 From e262e9a50602c848e560bfa81931d6216eddace7 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Sun, 12 Jun 2022 11:48:51 +0300 Subject: [PATCH 26/32] Add manpage --- build-release.sh | 5 +++++ manpage.adoc | 31 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 manpage.adoc diff --git a/build-release.sh b/build-release.sh index a34f60e..fa615a5 100755 --- a/build-release.sh +++ b/build-release.sh @@ -23,6 +23,7 @@ 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 printf "\e[34m Signing binary with GPG\e[0m\n" @@ -45,6 +46,10 @@ md5sum -c lqsd.md5 printf "\n\n" +printf "\e[34m Building documentation\e[0m\n" +asciidoc -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 diff --git a/manpage.adoc b/manpage.adoc new file mode 100644 index 0000000..2a7ec20 --- /dev/null +++ b/manpage.adoc @@ -0,0 +1,31 @@ += 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 From eb3398f044e3f8224f0282d78b2b3030e61019b6 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Sun, 12 Jun 2022 11:52:47 +0300 Subject: [PATCH 27/32] Fix typo in build-release.sh --- build-release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-release.sh b/build-release.sh index fa615a5..2efc22a 100755 --- a/build-release.sh +++ b/build-release.sh @@ -47,7 +47,7 @@ md5sum -c lqsd.md5 printf "\n\n" printf "\e[34m Building documentation\e[0m\n" -asciidoc -b manpage manpage.adoc +asciidoctor -b manpage manpage.adoc printf "\n\n" From f1502551d865664e427072e6bc0845822dcbd948 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Sun, 12 Jun 2022 11:59:59 +0300 Subject: [PATCH 28/32] Update information about releases --- README.adoc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/README.adoc b/README.adoc index b06ce04..5351adc 100644 --- a/README.adoc +++ b/README.adoc @@ -90,12 +90,9 @@ Enter a number (default=1): == Releases -Release notes can be found in -https://github.com/FunctionalHacker/lqsd/releases[GitHub] (Gitea does -not support editing tags yet). - -Prebuilt binaries, their checksums and signatures can also be found -there. +Release notes and binaries can be found either in +https://git.korhonen.cc/FunctionalHacker/lqsd[My Git server] or +https://github.com/FunctionalHacker/lqsd/releases[GitHub]. == Why Rust? From 6f513d0dd9406a1bdbab16bd419283bdf45aa928 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Sun, 12 Jun 2022 12:01:01 +0300 Subject: [PATCH 29/32] Update releases url --- README.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.adoc b/README.adoc index 5351adc..0a938c4 100644 --- a/README.adoc +++ b/README.adoc @@ -91,7 +91,7 @@ Enter a number (default=1): == Releases Release notes and binaries can be found either in -https://git.korhonen.cc/FunctionalHacker/lqsd[My Git server] or +https://git.korhonen.cc/FunctionalHacker/lqsd/releases[My Git server] or https://github.com/FunctionalHacker/lqsd/releases[GitHub]. == Why Rust? From 87ccec2f5acc1cea12d74827d2530f52f6c82e9b Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Sun, 12 Jun 2022 12:26:12 +0300 Subject: [PATCH 30/32] Update dotfile link --- README.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.adoc b/README.adoc index 0a938c4..f63fdc0 100644 --- a/README.adoc +++ b/README.adoc @@ -5,7 +5,7 @@ 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/master/home/.config/sway/scripts/idle.sh[my +https://git.korhonen.cc/FunctionalHacker/dotfiles/src/branch/main/home/.config/sway/scripts/idle.sh[my configuration files] for an example use case. == Usage From 8401602f32f9eeb8000ff0616867df5371bf8886 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 1 Mar 2023 22:21:15 +0200 Subject: [PATCH 31/32] Conver build-release to POSIX sh and fix issues reported by shellcheck --- build-release.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/build-release.sh b/build-release.sh index 2efc22a..bb89320 100755 --- a/build-release.sh +++ b/build-release.sh @@ -1,18 +1,18 @@ -#!/bin/bash +#!/bin/sh -if (( $# == 1 )); then +if [ $# = 1 ]; then TAG=$1 else - TAG=$(git tag | tail -n1) + TAG=$(git tag | tail -1) fi -VERSION_NR=$(printf $TAG | cut -c2-) +VERSION_NR=$(echo "$TAG" | cut -c2-) -printf "\e[34m Building release version $VERSION_NR\e[0m\n\n" +printf "\e[34m Building release version %s\e[0m\n\n" "$VERSION_NR" -printf "\e[34m Checking out $TAG\e[0m\n\n" -git checkout tags/$TAG > /dev/null 2>&1 +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 @@ -24,7 +24,7 @@ mkdir release cp target/release/lqsd release/ cp LICENSE release/ cp manpage.adoc release/ -cd release +cd release || return printf "\e[34m Signing binary with GPG\e[0m\n" gpg --detach-sign --armor lqsd @@ -52,14 +52,14 @@ 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 +tar cf lqsd_"${VERSION_NR}"_x86_64.tar.zst ./* --zstd -mv *.tar.zst .. +mv ./*.tar.zst .. cd .. printf "\e[34m removing leftover files\e[0m\n\n" rm -r release -printf "\e[34m Returning to master\e[0m\n\n" -git checkout master > /dev/null 2>&1 +printf "\e[34m Returning to main\e[0m\n\n" +git checkout main > /dev/null 2>&1 From 4bbffbbdd871ebef3b3de45fc66608264de903d6 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Thu, 2 Mar 2023 00:16:01 +0200 Subject: [PATCH 32/32] Update all dependencies Lots of breaking changes in clap --- Cargo.lock | 449 ++++++++++++++++++++++++++++++++++++++++++---------- Cargo.toml | 8 +- src/cli.rs | 35 ++-- src/main.rs | 14 +- 4 files changed, 395 insertions(+), 111 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d5e0bbb..6c36d9f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,188 +1,467 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -[[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)", -] +version = 3 [[package]] -name = "atty" -version = "0.2.14" +name = "autocfg" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -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)", -] +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "bitflags" -version = "1.2.1" +version = "1.3.2" 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 = "2.33.0" +version = "4.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d7ae14b20b94cb02149ed21a86c423859cbe18dc7ed69845cace50e52b40a5" dependencies = [ - "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)", + "bitflags", + "clap_lex", + "is-terminal", + "strsim", + "termcolor", ] [[package]] -name = "hermit-abi" -version = "0.1.6" +name = "clap_lex" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "350b9cf31731f9957399229e9b2adc51eeabdfbe9d71d9a0552275fd12710d09" dependencies = [ - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "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" +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", ] [[package]] name = "libc" -version = "0.2.66" +version = "0.2.139" 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" dependencies = [ - "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)", + "clap", + "serde", + "toml", + "xdg", ] [[package]] -name = "proc-macro2" -version = "1.0.8" +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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" dependencies = [ - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-ident", ] [[package]] name = "quote" -version = "1.0.2" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" dependencies = [ - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "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", ] [[package]] name = "serde" -version = "1.0.104" +version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" dependencies = [ - "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.104" +version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" dependencies = [ - "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.14 (registry+https://github.com/rust-lang/crates.io-index)", + "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", ] [[package]] name = "strsim" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "1.0.14" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "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)", + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] -name = "textwrap" -version = "0.11.0" +name = "termcolor" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" dependencies = [ - "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "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", ] [[package]] name = "toml" -version = "0.5.6" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7afcae9e3f0fe2c370fd4657108972cbb2fa9db1b9f84849cefd80741b01cb6" dependencies = [ - "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", ] [[package]] -name = "unicode-width" -version = "0.1.7" +name = "toml_datetime" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" +dependencies = [ + "serde", +] [[package]] -name = "unicode-xid" -version = "0.2.0" +name = "toml_edit" +version = "0.19.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a1eb0622d28f4b9c90adc4ea4b2b46b47663fde9ac5fafcb14a1369d5508825" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] [[package]] -name = "vec_map" -version = "0.8.1" +name = "unicode-ident" +version = "1.0.6" 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.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ - "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)", + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", ] [[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.2.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" - -[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.14 (registry+https://github.com/rust-lang/crates.io-index)" = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5" -"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" +checksum = "0c4583db5cbd4c4c0303df2d15af80f0539db703fa1c68802d4cbbd2dd0f88f6" +dependencies = [ + "dirs", +] diff --git a/Cargo.toml b/Cargo.toml index 06df1ea..f1b433c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ repository = "https://git.korhonen.cc/FunctionalHacker/lqsd" license = "MIT" [dependencies] -clap = "2.33.0" -serde = {version = "1.0.104", features = ["derive"]} -toml = "0.5.6" -xdg = "2.2.0" +clap = { version = "4.1.8" } +serde = { version = "1.0.152", features = ["derive"] } +toml = "0.7.2" +xdg = "2.4.1" diff --git a/src/cli.rs b/src/cli.rs index f525130..f54089b 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,42 +1,47 @@ extern crate clap; -use clap::{App, AppSettings, Arg}; +use clap::{Command, Arg, ArgAction}; -pub fn get_args() -> clap::ArgMatches<'static> { - App::new("LiQuid Screen Dim") +pub fn app() -> Command { + Command::new("LiQuid Screen Dim") .version(env!("CARGO_PKG_VERSION")) .author(env!("CARGO_PKG_AUTHORS")) .about(env!("CARGO_PKG_DESCRIPTION")) - .setting(AppSettings::ArgRequiredElseHelp) + .arg_required_else_help(true) .arg( - Arg::with_name("dim") + Arg::new("dim") .long("dim") - .short("d") - .takes_value(false) + .short('d') + .action(ArgAction::SetTrue) .display_order(1) .help("Dims the screen to idle level set in configuration"), ) .arg( - Arg::with_name("resume") + Arg::new("resume") .long("resume") - .short("r") - .takes_value(false) + .short('r') + .action(ArgAction::SetTrue) .display_order(2) .help("Sets the backlight to the value it was before dimming"), ) .arg( - Arg::with_name("copy-config") + Arg::new("copy-config") .long("copy-config") - .takes_value(false) + .action(ArgAction::SetTrue) .display_order(3) .help("Copies the default config file to $XDG_CONFIG_HOME/lqsd"), ) .arg( - Arg::with_name("config") + Arg::new("config") + .short('c') .long("config") - .takes_value(true) + .num_args(1) .number_of_values(1) .value_name("FILE") .help("Sets a custom config file"), ) - .get_matches() +} + +#[test] +fn verify_app() { + app().debug_assert(); } diff --git a/src/main.rs b/src/main.rs index 132ef72..79fa066 100644 --- a/src/main.rs +++ b/src/main.rs @@ -49,12 +49,12 @@ fn get_brightness() -> i32 { } fn main() { - let args = cli::get_args(); + let args = cli::app().get_matches(); let conf: Config; - if args.is_present("config") { - let config_path = PathBuf::from(args.value_of("config").unwrap()); - conf = config::load_user(config_path); + if let Some(config_path) = args.get_one::("config") { + let config_path_buf = PathBuf::from(config_path); + conf = config::load_user(config_path_buf); } else { conf = config::load_xdg(); } @@ -62,7 +62,7 @@ fn main() { let dim_speed = time::Duration::from_millis(conf.dim_speed); let resume_speed = time::Duration::from_millis(conf.resume_speed); - if args.is_present("dim") { + if args.get_flag("dim") { let current_brightness = get_brightness().to_string(); match fs::write(&conf.resume_file, current_brightness) { Ok(()) => println!( @@ -74,7 +74,7 @@ fn main() { transition(conf.idle_level, dim_speed); } - if args.is_present("resume") { + if args.get_flag("resume") { let old_brightness: i32; match fs::read(&conf.resume_file) { @@ -93,7 +93,7 @@ fn main() { } } - if args.is_present("copy-config") { + if args.get_flag("copy-config") { config::copy_config(); } }