This commit is contained in:
2025-09-28 17:33:28 +03:00
commit c2596fb0ad
4 changed files with 45 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target

7
Cargo.lock generated Normal file
View File

@@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "ct"
version = "0.1.0"

7
Cargo.toml Normal file
View File

@@ -0,0 +1,7 @@
[package]
name = "ct"
version = "0.1.0"
edition = "2024"
description = "Custom Timer"
[dependencies]

30
src/main.rs Normal file
View File

@@ -0,0 +1,30 @@
use std::{
env::{self, args},
process::Command,
thread::sleep,
time::Duration,
};
fn main() {
let args: Vec<String> = args().collect();
let timeout_secs: u64 = args.get(1)
.expect("There should be 1 argument, which specifies amount of time (in seconds) for timer to work!")
.parse()
.expect("The first argument should be a non-negative number");
let home = env::var("HOME").unwrap();
sleep(Duration::from_secs(timeout_secs));
let mut sound_alert = Command::new("pw-play")
.arg(format!("{home}/Music/not_sussy_song.opus"))
.spawn()
.expect("pw-play utility should be installed");
let _ = Command::new("zenity")
.args(["--warning", "--text=Take a break from computer!"])
.spawn()
.unwrap()
.wait();
sound_alert.kill().unwrap();
}