fix path resolution
This commit is contained in:
@@ -3,9 +3,17 @@ ct - custom timer
|
|||||||
|
|
||||||
# Prerequisites
|
# Prerequisites
|
||||||
|
|
||||||
|
- cargo
|
||||||
- zenity
|
- zenity
|
||||||
- pipewire
|
- pipewire
|
||||||
|
|
||||||
|
# Installing
|
||||||
|
|
||||||
|
1. Execute `cargo b --release`
|
||||||
|
2. Then, you can symlink executable file target/release/ct to wherever you feel comfortable.
|
||||||
|
|
||||||
|
Don't move it, though, since this will break the app!
|
||||||
|
|
||||||
# Summary
|
# Summary
|
||||||
|
|
||||||
ct is a timer application that play sound and display dialogue (with unconfigurable text, for now) on completion.
|
ct is a timer application that play sound and display dialogue (with unconfigurable text, for now) on completion.
|
||||||
|
|||||||
+36
-10
@@ -22,19 +22,45 @@ fn main() {
|
|||||||
'm' => Duration::from_mins(timeout),
|
'm' => Duration::from_mins(timeout),
|
||||||
_ => panic!("Invalid measurement of time! For now, only 's' and 'm' are supported"),
|
_ => panic!("Invalid measurement of time! For now, only 's' and 'm' are supported"),
|
||||||
};
|
};
|
||||||
let alert_path = args.get(3).map_or("assets/not_sussy_song.opus", |path| {
|
|
||||||
assert!(
|
|
||||||
Path::new(path).exists(),
|
|
||||||
"The path provided should point to an existing file"
|
|
||||||
);
|
|
||||||
path
|
|
||||||
});
|
|
||||||
|
|
||||||
let current_exe_path = env::current_exe().unwrap().canonicalize().unwrap();
|
let current_exe_path = env::current_exe().unwrap().canonicalize().unwrap();
|
||||||
Daemonize::new()
|
let root = current_exe_path
|
||||||
.working_directory(current_exe_path.parent().unwrap())
|
.parent()
|
||||||
.start()
|
.unwrap()
|
||||||
|
.parent()
|
||||||
|
.unwrap()
|
||||||
|
.parent()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
let alert_path = args.get(3).map_or_else(
|
||||||
|
|| {
|
||||||
|
let default = "assets/not_sussy_song.opus";
|
||||||
|
let default_path = root.join(default);
|
||||||
|
if !default_path.exists() {
|
||||||
|
let _ = Command::new("zenity")
|
||||||
|
.args([
|
||||||
|
"--error",
|
||||||
|
&format!(
|
||||||
|
"--text=Bundled alarm sound wasn't found! path: {}",
|
||||||
|
default_path.to_str().unwrap()
|
||||||
|
),
|
||||||
|
])
|
||||||
|
.spawn()
|
||||||
|
.unwrap()
|
||||||
|
.wait();
|
||||||
|
panic!("Didn't find bundled sound");
|
||||||
|
}
|
||||||
|
default
|
||||||
|
},
|
||||||
|
|path| {
|
||||||
|
assert!(
|
||||||
|
Path::new(path).exists(),
|
||||||
|
"The path provided should point to an existing file"
|
||||||
|
);
|
||||||
|
path
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
Daemonize::new().working_directory(root).start().unwrap();
|
||||||
|
|
||||||
sleep(sleeping_amount);
|
sleep(sleeping_amount);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user