batman
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/target
|
||||||
7
Cargo.lock
generated
Normal file
7
Cargo.lock
generated
Normal 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
7
Cargo.toml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
[package]
|
||||||
|
name = "ct"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
description = "Custom Timer"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
30
src/main.rs
Normal file
30
src/main.rs
Normal 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();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user