From 14101dc7db669064bfb4a7a3d85808933e5abce6 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Sat, 25 Jun 2022 22:28:56 -0700 Subject: [PATCH] Install battery applet, and make it work in the panel --- Cargo.toml | 2 +- .../Cargo.lock | 2 +- .../Cargo.toml | 2 +- .../com.system76.CosmicAppletBattery.desktop | 12 ++++ .../com.system76.CosmicAppletBattery.svg | 60 +++++++++++++++++++ .../src/backlight.rs | 0 .../src/main.rs | 4 ++ .../src/power_daemon.rs | 0 .../src/upower.rs | 0 .../src/upower_device.rs | 0 .../src/upower_kbdbacklight.rs | 0 debian/rules | 5 +- justfile | 7 +++ 13 files changed, 89 insertions(+), 5 deletions(-) rename applets/{cosmic-applet-power-battery => cosmic-applet-battery}/Cargo.lock (99%) rename applets/{cosmic-applet-power-battery => cosmic-applet-battery}/Cargo.toml (88%) create mode 100644 applets/cosmic-applet-battery/data/com.system76.CosmicAppletBattery.desktop create mode 100644 applets/cosmic-applet-battery/data/icons/com.system76.CosmicAppletBattery.svg rename applets/{cosmic-applet-power-battery => cosmic-applet-battery}/src/backlight.rs (100%) rename applets/{cosmic-applet-power-battery => cosmic-applet-battery}/src/main.rs (99%) rename applets/{cosmic-applet-power-battery => cosmic-applet-battery}/src/power_daemon.rs (100%) rename applets/{cosmic-applet-power-battery => cosmic-applet-battery}/src/upower.rs (100%) rename applets/{cosmic-applet-power-battery => cosmic-applet-battery}/src/upower_device.rs (100%) rename applets/{cosmic-applet-power-battery => cosmic-applet-battery}/src/upower_kbdbacklight.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index 9121be1a..c085b67b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,5 +13,5 @@ members = [ ] exclude = [ - "applets/cosmic-applet-power-battery", + "applets/cosmic-applet-battery", ] diff --git a/applets/cosmic-applet-power-battery/Cargo.lock b/applets/cosmic-applet-battery/Cargo.lock similarity index 99% rename from applets/cosmic-applet-power-battery/Cargo.lock rename to applets/cosmic-applet-battery/Cargo.lock index c0f34d64..9ea8e380 100644 --- a/applets/cosmic-applet-power-battery/Cargo.lock +++ b/applets/cosmic-applet-battery/Cargo.lock @@ -203,7 +203,7 @@ dependencies = [ ] [[package]] -name = "cosmic-applet-power-battery" +name = "cosmic-applet-battery" version = "0.1.0" dependencies = [ "futures", diff --git a/applets/cosmic-applet-power-battery/Cargo.toml b/applets/cosmic-applet-battery/Cargo.toml similarity index 88% rename from applets/cosmic-applet-power-battery/Cargo.toml rename to applets/cosmic-applet-battery/Cargo.toml index d6fef239..95b564f9 100644 --- a/applets/cosmic-applet-power-battery/Cargo.toml +++ b/applets/cosmic-applet-battery/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "cosmic-applet-power-battery" +name = "cosmic-applet-battery" version = "0.1.0" edition = "2021" diff --git a/applets/cosmic-applet-battery/data/com.system76.CosmicAppletBattery.desktop b/applets/cosmic-applet-battery/data/com.system76.CosmicAppletBattery.desktop new file mode 100644 index 00000000..03c1a8a6 --- /dev/null +++ b/applets/cosmic-applet-battery/data/com.system76.CosmicAppletBattery.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Name=Cosmic Applet Battery +Comment=Write a GTK + Rust application +Type=Application +Exec=cosmic-applet-battery +Terminal=false +Categories=GNOME;GTK; +Keywords=Gnome;GTK; +# Translators: Do NOT translate or transliterate this text (this is an icon file name)! +Icon=com.system76.CosmicAppletBattery.svg +StartupNotify=true +NoDisplay=true diff --git a/applets/cosmic-applet-battery/data/icons/com.system76.CosmicAppletBattery.svg b/applets/cosmic-applet-battery/data/icons/com.system76.CosmicAppletBattery.svg new file mode 100644 index 00000000..c2bd5b1b --- /dev/null +++ b/applets/cosmic-applet-battery/data/icons/com.system76.CosmicAppletBattery.svg @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/applets/cosmic-applet-power-battery/src/backlight.rs b/applets/cosmic-applet-battery/src/backlight.rs similarity index 100% rename from applets/cosmic-applet-power-battery/src/backlight.rs rename to applets/cosmic-applet-battery/src/backlight.rs diff --git a/applets/cosmic-applet-power-battery/src/main.rs b/applets/cosmic-applet-battery/src/main.rs similarity index 99% rename from applets/cosmic-applet-power-battery/src/main.rs rename to applets/cosmic-applet-battery/src/main.rs index 4150254b..b5e6f1f8 100644 --- a/applets/cosmic-applet-power-battery/src/main.rs +++ b/applets/cosmic-applet-battery/src/main.rs @@ -109,6 +109,10 @@ impl SimpleComponent for AppModel { view! { gtk4::Window { + set_decorated: false, + set_resizable: false, + set_width_request: 1, + set_height_request: 1, gtk4::MenuButton { set_has_frame: false, #[watch] diff --git a/applets/cosmic-applet-power-battery/src/power_daemon.rs b/applets/cosmic-applet-battery/src/power_daemon.rs similarity index 100% rename from applets/cosmic-applet-power-battery/src/power_daemon.rs rename to applets/cosmic-applet-battery/src/power_daemon.rs diff --git a/applets/cosmic-applet-power-battery/src/upower.rs b/applets/cosmic-applet-battery/src/upower.rs similarity index 100% rename from applets/cosmic-applet-power-battery/src/upower.rs rename to applets/cosmic-applet-battery/src/upower.rs diff --git a/applets/cosmic-applet-power-battery/src/upower_device.rs b/applets/cosmic-applet-battery/src/upower_device.rs similarity index 100% rename from applets/cosmic-applet-power-battery/src/upower_device.rs rename to applets/cosmic-applet-battery/src/upower_device.rs diff --git a/applets/cosmic-applet-power-battery/src/upower_kbdbacklight.rs b/applets/cosmic-applet-battery/src/upower_kbdbacklight.rs similarity index 100% rename from applets/cosmic-applet-power-battery/src/upower_kbdbacklight.rs rename to applets/cosmic-applet-battery/src/upower_kbdbacklight.rs diff --git a/debian/rules b/debian/rules index c903bfe4..aaa756a9 100755 --- a/debian/rules +++ b/debian/rules @@ -13,11 +13,12 @@ override_dh_shlibdeps: override_dh_auto_clean: if test "${CLEAN}" = "1"; then \ cargo clean; \ + cargo clean --manifest-path applets/cosmic-applet-battery/Cargo.toml; \ fi if ! ischroot && test "${VENDOR}" = "1"; then \ mkdir -p .cargo; \ - cargo vendor --sync Cargo.toml | head -n -1 > .cargo/config; \ + cargo vendor --sync Cargo.toml --sync applets/cosmic-applet-battery/Cargo.toml | head -n -1 > .cargo/config; \ echo 'directory = "vendor"' >> .cargo/config; \ tar pcf vendor.tar vendor; \ rm -rf vendor; \ @@ -27,4 +28,4 @@ override_dh_auto_build: just rootdir=$(DESTDIR) debug=$(DEBUG) vendor=$(VENDOR) override_dh_auto_install: - just rootdir=$(DESTDIR) install \ No newline at end of file + just rootdir=$(DESTDIR) install diff --git a/justfile b/justfile index 15e97ea4..ee45c06b 100644 --- a/justfile +++ b/justfile @@ -15,6 +15,7 @@ bindir := rootdir + prefix + '/bin' app_list_id := 'com.system76.CosmicAppList' audio_id := 'com.system76.CosmicAppletAudio' +battery_id := 'com.system76.CosmicAppletBattery' graphics_id := 'com.system76.CosmicAppletGraphics' network_id := 'com.system76.CosmicAppletNetwork' notifications_id := 'com.system76.CosmicAppletNotifications' @@ -27,6 +28,7 @@ workspaces_button_id := 'com.system76.CosmicPanelWorkspacesButton' all: _extract_vendor cargo build {{cargo_args}} + cargo build --manifest-path applets/cosmic-applet-battery/Cargo.toml {{cargo_args}} # Installs files into the system install: @@ -42,6 +44,11 @@ install: install -Dm0644 applets/cosmic-applet-audio/data/{{audio_id}}.desktop {{sharedir}}/applications/{{audio_id}}.desktop install -Dm0755 target/release/cosmic-applet-audio {{bindir}}/cosmic-applet-audio + # battery + install -Dm0644 applets/cosmic-applet-battery/data/icons/{{battery_id}}.svg {{iconsdir}}/{{battery_id}}.svg + install -Dm0644 applets/cosmic-applet-battery/data/{{battery_id}}.desktop {{sharedir}}/applications/{{battery_id}}.desktop + install -Dm0755 applets/cosmic-applet-battery/target/release/cosmic-applet-battery {{bindir}}/cosmic-applet-battery + # graphics install -Dm0644 applets/cosmic-applet-graphics/data/icons/{{graphics_id}}.svg {{iconsdir}}/{{graphics_id}}.svg install -Dm0644 applets/cosmic-applet-graphics/data/{{graphics_id}}.desktop {{sharedir}}/applications/{{graphics_id}}.desktop