Add a -n/--now flag to only print the current hour’s name

This commit is contained in:
Gergely Polonkai 2022-05-24 17:14:51 +02:00
parent ccaa902be8
commit b63d4cbac8
No known key found for this signature in database
GPG Key ID: 2D2885533B869ED4
2 changed files with 20 additions and 2 deletions

View File

@ -16,6 +16,14 @@ longitude = 19.286
If you dont provide a configuration file, the day parts (day/night time and the golden/blue hours) wont be visible on the clock face. If you dont provide a configuration file, the day parts (day/night time and the golden/blue hours) wont be visible on the clock face.
## Command line arguments
### Just print the current hours name
You can pass `-n` or `--now` to the app to only print the current hours name.
This can be used in scripts, or in i3/sway panels, for example.
## Features ## Features
### Seasonal hours! ### Seasonal hours!

View File

@ -11,17 +11,27 @@ mod clock;
mod config; mod config;
mod svg_clock; mod svg_clock;
use clock::get_current_hour_name;
use config::{get_config, Config}; use config::{get_config, Config};
use svg_clock::{cache_hour_name_paths, gen_svg, svg_to_usvg}; use svg_clock::{cache_hour_name_paths, gen_svg, svg_to_usvg};
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
#[clap(author, version, about, long_about = None)] #[clap(author, version, about, long_about = None)]
struct Args {} struct Args {
/// Print the current hours name and exit
#[clap(short, long)]
now: bool,
}
sctk::default_environment!(SeasonalClock, desktop); sctk::default_environment!(SeasonalClock, desktop);
fn main() { fn main() {
Args::parse(); let args = Args::parse();
if args.now {
println!("{}", get_current_hour_name());
std::process::exit(0);
}
let config = get_config(); let config = get_config();
run_windowed(&config); run_windowed(&config);