From 31db7d449c6b63561353bbecf5a6780670cfb2a2 Mon Sep 17 00:00:00 2001 From: xunuwu Date: Sun, 23 Nov 2025 15:39:07 +0100 Subject: [PATCH] add miao battery percentage thing --- home/desktop/sway/__waybar.nix | 6 ++++++ pkgs/default.nix | 1 + pkgs/miao-battery-percentage/default.nix | 23 +++++++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 pkgs/miao-battery-percentage/default.nix diff --git a/home/desktop/sway/__waybar.nix b/home/desktop/sway/__waybar.nix index 4e31ec5..4ac9618 100644 --- a/home/desktop/sway/__waybar.nix +++ b/home/desktop/sway/__waybar.nix @@ -22,6 +22,7 @@ ]; modules-right = [ "custom/keyboard-state" + "custom/miao-battery-percentage" "tray" "clock" ]; @@ -31,6 +32,11 @@ "sway/window" = { max-length = 80; }; + "custom/miao-battery-percentage" = { + return-type = "json"; + exec = "${lib.getExe self.packages.${pkgs.system}.miao-battery-percentage}"; + restart-interval = "60"; + }; "custom/keyboard-state" = { return-type = "json"; exec = "${lib.getExe self.packages.${pkgs.system}.keyboard-state}"; diff --git a/pkgs/default.nix b/pkgs/default.nix index 12662d5..14e3fbf 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -5,5 +5,6 @@ cartograph-cf = pkgs.callPackage ./cartograph-cf {}; keyboard-state = pkgs.callPackage ./keyboard-state {}; audio-abtest = pkgs.callPackage ./audio-abtest {}; + miao-battery-percentage = pkgs.callPackage ./miao-battery-percentage {}; }; } diff --git a/pkgs/miao-battery-percentage/default.nix b/pkgs/miao-battery-percentage/default.nix new file mode 100644 index 0000000..6a6fe14 --- /dev/null +++ b/pkgs/miao-battery-percentage/default.nix @@ -0,0 +1,23 @@ +{ + rustPlatform, + pkg-config, + udev, + fetchFromGitHub, +}: +rustPlatform.buildRustPackage rec { + pname = "miao-battery-percentage"; + version = "0.1.0"; + + src = fetchFromGitHub { + owner = "xunuwu"; + repo = "miao-battery-percentage"; + rev = "e14e72dce9d946503676121759ce6130e42bb637"; + hash = "sha256-NXJv8dChKPv695XMvmm+Xh0VJ1jdRhbdGMCM0LVIiD8="; + }; + cargoLock.lockFile = "${src}/Cargo.lock"; + + nativeBuildInputs = [pkg-config]; + buildInputs = [udev]; + + meta.mainProgram = "miao-battery-percentage"; +}