diff --git a/Cargo.lock b/Cargo.lock index e6de683..f43c6ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,12 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "alphanumeric-sort" -version = "1.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77e9c9abb82613923ec78d7a461595d52491ba7240f3c64c0bbe0e6d98e0fce0" - [[package]] name = "anyhow" version = "1.0.66" @@ -89,68 +83,13 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "core-foundation-sys" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" - -[[package]] -name = "crossbeam-channel" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" -dependencies = [ - "cfg-if", - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96bf8df95e795db1a4aca2957ad884a2df35413b24bbeb3114422f3cc21498e8" -dependencies = [ - "autocfg", - "cfg-if", - "crossbeam-utils", - "memoffset 0.7.1", - "scopeguard", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "422f23e724af1240ec469ea1e834d87a4b59ce2efe2c6a96256b0c47e2fd86aa" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "either" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" - [[package]] name = "field-offset" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e1c54951450cbd39f3dbcf1005ac413b49487dabf18a720ad2383eccfeffb92" dependencies = [ - "memoffset 0.6.5", + "memoffset", "rustc_version", ] @@ -411,15 +350,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "libappindicator" version = "0.7.1" @@ -478,34 +408,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "memoffset" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" -dependencies = [ - "autocfg", -] - -[[package]] -name = "ntapi" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc51db7b362b205941f71232e56c625156eb9a929f8cf74a428fd5bc094a4afc" -dependencies = [ - "winapi", -] - -[[package]] -name = "num_cpus" -version = "1.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "once_cell" version = "1.16.0" @@ -541,11 +443,8 @@ dependencies = [ name = "parrotd" version = "0.1.0" dependencies = [ - "alphanumeric-sort", - "glib", "gtk", "libappindicator", - "sysinfo", ] [[package]] @@ -629,29 +528,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rayon" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e060280438193c554f654141c9ea9417886713b7acd75974c85b18a69a88e0b" -dependencies = [ - "crossbeam-deque", - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cac410af5d00ab6884528b4ab69d1e8e146e8d471201800fa1b4524126de6ad3" -dependencies = [ - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-utils", - "num_cpus", -] - [[package]] name = "rustc_version" version = "0.3.3" @@ -661,12 +537,6 @@ dependencies = [ "semver", ] -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - [[package]] name = "semver" version = "0.11.0" @@ -717,21 +587,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "sysinfo" -version = "0.26.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c375d5fd899e32847b8566e10598d6e9f1d9b55ec6de3cdf9e7da4bdc51371bc" -dependencies = [ - "cfg-if", - "core-foundation-sys", - "libc", - "ntapi", - "once_cell", - "rayon", - "winapi", -] - [[package]] name = "system-deps" version = "6.0.3" diff --git a/Cargo.toml b/Cargo.toml index 11f771c..567480e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,3 @@ edition = "2021" [dependencies] libappindicator = "0.7" gtk = "0.15" -glib = "0.15" -sysinfo = "0.26" -alphanumeric-sort = "1.4" diff --git a/res/cat/dark_cat_0.png b/res/cat/dark_cat_0.png deleted file mode 100644 index 814d895..0000000 Binary files a/res/cat/dark_cat_0.png and /dev/null differ diff --git a/res/cat/dark_cat_1.png b/res/cat/dark_cat_1.png deleted file mode 100644 index 08afd92..0000000 Binary files a/res/cat/dark_cat_1.png and /dev/null differ diff --git a/res/cat/dark_cat_2.png b/res/cat/dark_cat_2.png deleted file mode 100644 index e4c124e..0000000 Binary files a/res/cat/dark_cat_2.png and /dev/null differ diff --git a/res/cat/dark_cat_3.png b/res/cat/dark_cat_3.png deleted file mode 100644 index 68e5886..0000000 Binary files a/res/cat/dark_cat_3.png and /dev/null differ diff --git a/res/cat/dark_cat_4.png b/res/cat/dark_cat_4.png deleted file mode 100644 index 38bfe80..0000000 Binary files a/res/cat/dark_cat_4.png and /dev/null differ diff --git a/res/cat/light_cat_0.png b/res/cat/light_cat_0.png deleted file mode 100644 index e2090ff..0000000 Binary files a/res/cat/light_cat_0.png and /dev/null differ diff --git a/res/cat/light_cat_1.png b/res/cat/light_cat_1.png deleted file mode 100644 index d267c16..0000000 Binary files a/res/cat/light_cat_1.png and /dev/null differ diff --git a/res/cat/light_cat_2.png b/res/cat/light_cat_2.png deleted file mode 100644 index 04675f9..0000000 Binary files a/res/cat/light_cat_2.png and /dev/null differ diff --git a/res/cat/light_cat_3.png b/res/cat/light_cat_3.png deleted file mode 100644 index 901e69c..0000000 Binary files a/res/cat/light_cat_3.png and /dev/null differ diff --git a/res/cat/light_cat_4.png b/res/cat/light_cat_4.png deleted file mode 100644 index 93b70a9..0000000 Binary files a/res/cat/light_cat_4.png and /dev/null differ diff --git a/res/horse/dark_horse_0.png b/res/horse/dark_horse_0.png deleted file mode 100644 index c82fde1..0000000 Binary files a/res/horse/dark_horse_0.png and /dev/null differ diff --git a/res/horse/dark_horse_1.png b/res/horse/dark_horse_1.png deleted file mode 100644 index 336c5c3..0000000 Binary files a/res/horse/dark_horse_1.png and /dev/null differ diff --git a/res/horse/dark_horse_10.png b/res/horse/dark_horse_10.png deleted file mode 100644 index 06a03e7..0000000 Binary files a/res/horse/dark_horse_10.png and /dev/null differ diff --git a/res/horse/dark_horse_11.png b/res/horse/dark_horse_11.png deleted file mode 100644 index 81eb91c..0000000 Binary files a/res/horse/dark_horse_11.png and /dev/null differ diff --git a/res/horse/dark_horse_12.png b/res/horse/dark_horse_12.png deleted file mode 100644 index c0eaa5b..0000000 Binary files a/res/horse/dark_horse_12.png and /dev/null differ diff --git a/res/horse/dark_horse_13.png b/res/horse/dark_horse_13.png deleted file mode 100644 index 6476897..0000000 Binary files a/res/horse/dark_horse_13.png and /dev/null differ diff --git a/res/horse/dark_horse_2.png b/res/horse/dark_horse_2.png deleted file mode 100644 index a04f4c9..0000000 Binary files a/res/horse/dark_horse_2.png and /dev/null differ diff --git a/res/horse/dark_horse_3.png b/res/horse/dark_horse_3.png deleted file mode 100644 index 8402d07..0000000 Binary files a/res/horse/dark_horse_3.png and /dev/null differ diff --git a/res/horse/dark_horse_4.png b/res/horse/dark_horse_4.png deleted file mode 100644 index 3d2311a..0000000 Binary files a/res/horse/dark_horse_4.png and /dev/null differ diff --git a/res/horse/dark_horse_5.png b/res/horse/dark_horse_5.png deleted file mode 100644 index 57ab46d..0000000 Binary files a/res/horse/dark_horse_5.png and /dev/null differ diff --git a/res/horse/dark_horse_6.png b/res/horse/dark_horse_6.png deleted file mode 100644 index 7581027..0000000 Binary files a/res/horse/dark_horse_6.png and /dev/null differ diff --git a/res/horse/dark_horse_7.png b/res/horse/dark_horse_7.png deleted file mode 100644 index 7aeabab..0000000 Binary files a/res/horse/dark_horse_7.png and /dev/null differ diff --git a/res/horse/dark_horse_8.png b/res/horse/dark_horse_8.png deleted file mode 100644 index dd84632..0000000 Binary files a/res/horse/dark_horse_8.png and /dev/null differ diff --git a/res/horse/dark_horse_9.png b/res/horse/dark_horse_9.png deleted file mode 100644 index 17df297..0000000 Binary files a/res/horse/dark_horse_9.png and /dev/null differ diff --git a/res/horse/light_horse_0.png b/res/horse/light_horse_0.png deleted file mode 100644 index d12aff8..0000000 Binary files a/res/horse/light_horse_0.png and /dev/null differ diff --git a/res/horse/light_horse_1.png b/res/horse/light_horse_1.png deleted file mode 100644 index ced221e..0000000 Binary files a/res/horse/light_horse_1.png and /dev/null differ diff --git a/res/horse/light_horse_10.png b/res/horse/light_horse_10.png deleted file mode 100644 index 5727f5c..0000000 Binary files a/res/horse/light_horse_10.png and /dev/null differ diff --git a/res/horse/light_horse_11.png b/res/horse/light_horse_11.png deleted file mode 100644 index 14e3672..0000000 Binary files a/res/horse/light_horse_11.png and /dev/null differ diff --git a/res/horse/light_horse_12.png b/res/horse/light_horse_12.png deleted file mode 100644 index 1405384..0000000 Binary files a/res/horse/light_horse_12.png and /dev/null differ diff --git a/res/horse/light_horse_13.png b/res/horse/light_horse_13.png deleted file mode 100644 index 776445d..0000000 Binary files a/res/horse/light_horse_13.png and /dev/null differ diff --git a/res/horse/light_horse_2.png b/res/horse/light_horse_2.png deleted file mode 100644 index a53f115..0000000 Binary files a/res/horse/light_horse_2.png and /dev/null differ diff --git a/res/horse/light_horse_3.png b/res/horse/light_horse_3.png deleted file mode 100644 index 10fb170..0000000 Binary files a/res/horse/light_horse_3.png and /dev/null differ diff --git a/res/horse/light_horse_4.png b/res/horse/light_horse_4.png deleted file mode 100644 index 42f94cf..0000000 Binary files a/res/horse/light_horse_4.png and /dev/null differ diff --git a/res/horse/light_horse_5.png b/res/horse/light_horse_5.png deleted file mode 100644 index 13eab34..0000000 Binary files a/res/horse/light_horse_5.png and /dev/null differ diff --git a/res/horse/light_horse_6.png b/res/horse/light_horse_6.png deleted file mode 100644 index c0bdc07..0000000 Binary files a/res/horse/light_horse_6.png and /dev/null differ diff --git a/res/horse/light_horse_7.png b/res/horse/light_horse_7.png deleted file mode 100644 index 17bf73f..0000000 Binary files a/res/horse/light_horse_7.png and /dev/null differ diff --git a/res/horse/light_horse_8.png b/res/horse/light_horse_8.png deleted file mode 100644 index 3a0a6d0..0000000 Binary files a/res/horse/light_horse_8.png and /dev/null differ diff --git a/res/horse/light_horse_9.png b/res/horse/light_horse_9.png deleted file mode 100644 index f66abf1..0000000 Binary files a/res/horse/light_horse_9.png and /dev/null differ diff --git a/src/main.rs b/src/main.rs index 15aac16..f3bf7e1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,29 +7,13 @@ pub use err::*; use libappindicator::*; use gtk::prelude::*; use pack::*; -use std::cell::RefCell; -use std::time::{Duration, Instant}; -use sysinfo::*; -thread_local! { - static SYSTEM: RefCell = RefCell::new(System::new_all()); -} - -fn update_frame_time() -> Duration { - return SYSTEM.with(|system| { - let mut system = system.borrow_mut(); - system.refresh_cpu_specifics(CpuRefreshKind::new().with_cpu_usage()); - let num_cpus = system.cpus().len(); - let load: f32 = system.cpus().iter() - .map(|cpu| cpu.cpu_usage() / num_cpus as f32) - .sum(); - return Duration::from_millis(10 + 2 * load as u64); // min 10 (~100Hz), max 210 (~5Hz) - }) -} - -fn init_indicator(icon_pack: &IconPack) -> AppIndicator { +fn main() { + gtk::init().unwrap(); + let mut icon_pack = IconPack::new("./res", "parrot", PackVariant::Dark).unwrap(); let mut indicator = AppIndicator::new("parrotd", ""); indicator.set_icon_theme_path(icon_pack.pack_path()); + indicator.set_icon_full(icon_pack.next_icon_path(), "parrotd"); indicator.set_status(AppIndicatorStatus::Active); let mut m = gtk::Menu::new(); let mi = gtk::CheckMenuItem::with_label("I'm a parrot"); @@ -39,40 +23,5 @@ fn init_indicator(icon_pack: &IconPack) -> AppIndicator { m.append(&mi); indicator.set_menu(&mut m); m.show_all(); - return indicator; -} - -fn main() { - gtk::init().unwrap(); - - let res_dir = std::env::var("PARROTD_RESOURCE_DIR").unwrap_or("./res".to_owned()); - let pack_name = std::env::var("PARROTD_ICON_PACK").unwrap_or("parrot".to_owned()); - let variant = PackVariant::parse( - &std::env::var("PARROTD_VARIANT").unwrap_or("dark".to_owned())).expect("Invalid variant name"); - - let mut icon_pack = IconPack::new(res_dir, &pack_name, variant).unwrap(); - let mut indicator = init_indicator(&icon_pack); - - // Animation task - let mut last_update = Instant::now(); - let mut last_update_frame_time = Instant::now(); - let mut frame_time = update_frame_time(); - glib::timeout_add_local(Duration::from_millis(1) /* we need granularity */, move || { - let now = Instant::now(); - - if now - last_update_frame_time >= Duration::from_millis(100) { - // Update frame time - frame_time = update_frame_time(); - last_update_frame_time = now; - } - - if now - last_update >= frame_time { - // Update animation - indicator.set_icon(icon_pack.next_icon_path()); - last_update = now; - } - Continue(true) - }); - gtk::main(); } diff --git a/src/pack.rs b/src/pack.rs index 7875859..c591787 100644 --- a/src/pack.rs +++ b/src/pack.rs @@ -2,7 +2,6 @@ use crate::*; use std::path::{Path, PathBuf}; #[allow(dead_code)] -#[derive(Debug)] pub enum PackVariant { Light, Dark, @@ -15,14 +14,6 @@ impl PackVariant { PackVariant::Dark => "dark", } } - - pub fn parse(s: &str) -> Option { - match s { - "light" => Some(PackVariant::Light), - "dark" => Some(PackVariant::Dark), - _ => None - } - } } #[allow(unused)] @@ -69,7 +60,7 @@ impl IconPack { icons.push(name.split_at(name.len() - ".png".len()).0.to_string()); } - alphanumeric_sort::sort_str_slice(&mut icons); // Alphanumerical ordering + icons.sort(); // Alphanumerical ordering let num_icons = icons.len();