Add a -n/--now flag to only print the current hour’s name
This commit is contained in:
parent
ccaa902be8
commit
b63d4cbac8
@ -16,6 +16,14 @@ longitude = 19.286
|
|||||||
|
|
||||||
If you don’t provide a configuration file, the day parts (day/night time and the golden/blue hours) won’t be visible on the clock face.
|
If you don’t provide a configuration file, the day parts (day/night time and the golden/blue hours) won’t be visible on the clock face.
|
||||||
|
|
||||||
|
## Command line arguments
|
||||||
|
|
||||||
|
### Just print the current hour’s name
|
||||||
|
|
||||||
|
You can pass `-n` or `--now` to the app to only print the current hour’s name.
|
||||||
|
|
||||||
|
This can be used in scripts, or in i3/sway panels, for example.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
### Seasonal hours!
|
### Seasonal hours!
|
||||||
|
14
src/main.rs
14
src/main.rs
@ -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 hour’s 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);
|
||||||
|
Loading…
Reference in New Issue
Block a user