Skip to content

Commit

Permalink
add support for date formatting of the commandline
Browse files Browse the repository at this point in the history
  • Loading branch information
gabm committed Dec 28, 2023
1 parent 2ab20b6 commit faf8266
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
//"/home/gabm/Pictures/Wallpaper/torres_1.jpg",
"/home/gabm/Pictures/Screenshots/satty-20231116-10:35:51.png",
//"--fullscreen",
"--output-filename",
"/tmp/out.png",
//"--output-filename",
//"/tmp/out.png",
"--copy-command",
"wl-copy",
],
Expand Down
77 changes: 77 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ toml = "0.8.8"
serde = "1.0"
serde_derive = "1.0"
hex_color = {version = "3", features = ["serde"]}
chrono = "0.4.31"


[dependencies.relm4-icons]
version = "0.6.0"
Expand Down
5 changes: 4 additions & 1 deletion src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ impl Configuration {
if let Some(v) = general.copy_command {
self.copy_command = Some(v);
}
// output_filename is not yet supported
if let Some(v) = general.output_filename {
self.output_filename = Some(v);
}
if let Some(v) = general.annotation_size_factor {
self.annotation_size_factor = v;
}
Expand Down Expand Up @@ -247,6 +249,7 @@ struct ConfiguationFileGeneral {
initial_tool: Option<Tools>,
copy_command: Option<String>,
annotation_size_factor: Option<f64>,
output_filename: Option<String>,
}

#[derive(Deserialize)]
Expand Down
4 changes: 4 additions & 0 deletions src/sketch_board.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use anyhow::anyhow;
use chrono::format::strftime;
use gdk_pixbuf::Pixbuf;
use std::cell::RefCell;
use std::fs;
Expand Down Expand Up @@ -151,6 +152,9 @@ impl SketchBoard {
Some(o) => o.clone(),
};

// run the output filename by "chrono date format"
let output_filename = format!("{}", chrono::Local::now().format(&output_filename));

if !output_filename.ends_with(".png") {
let msg = "The only supported format is png, but the filename does not end in png";
println!("{msg}");
Expand Down

0 comments on commit faf8266

Please sign in to comment.