From 05a5d8f865b5dc6e906ebc51bdc66c3e1c51c1f9 Mon Sep 17 00:00:00 2001 From: ElnuDev Date: Sun, 9 Oct 2022 19:25:06 -0700 Subject: [PATCH] Only display battery and CPU temp modules on ThinkPad --- hosts/elnupad/home.nix | 4 +++- hosts/elnupad/polybar.nix | 31 +++++++++++++++++++++++++++++++ polybar/default.nix | 25 ------------------------- 3 files changed, 34 insertions(+), 26 deletions(-) create mode 100644 hosts/elnupad/polybar.nix diff --git a/hosts/elnupad/home.nix b/hosts/elnupad/home.nix index f02f359..c68ffd9 100644 --- a/hosts/elnupad/home.nix +++ b/hosts/elnupad/home.nix @@ -1,3 +1,5 @@ { pkgs, ... }: { - + imports = [ + ./polybar.nix + ]; } diff --git a/hosts/elnupad/polybar.nix b/hosts/elnupad/polybar.nix new file mode 100644 index 0000000..f9c9228 --- /dev/null +++ b/hosts/elnupad/polybar.nix @@ -0,0 +1,31 @@ +{ pkgs, lib, ... } + +{ + home.packages = with pkgs; [ lm_sensors ]; + services.polybar.config = { + "module/cputemp" = { + type = "custom/script"; + + interval = 2; + + exec = "/etc/profiles/per-user/elnu/bin/sensors | /run/current-system/sw/bin/grep \"Package id 0:\" | /run/current-system/sw/bin/tr -d '+' | /run/current-system/sw/bin/awk '{print $4}'"; + }; + "module/battery" = { + type = "internal/battery"; + battery = "BAT0"; + adapter = "AC"; + + format-low = " "; + + label-charging = "%{F${primary}}AC%{F-} %percentage%%"; + label-discharging = "%{F${primary}}BAT%{F-} %percentage%%"; + label-full = "%{F${primary}}AC%{F-}"; + + animation-low-0 = "%{F${primary}}BAT%{F-}"; + animation-low-1 = "%{F${alert}}LOW%{F-}"; + + full-at = 96; + low-at = 10; # default + }; + }; +} diff --git a/polybar/default.nix b/polybar/default.nix index 67dceee..1872f01 100644 --- a/polybar/default.nix +++ b/polybar/default.nix @@ -125,31 +125,6 @@ in format-prefix = "CPU "; format-prefix-foreground = "${primary}"; }; - "module/cputemp" = { - type = "custom/script"; - - interval = 2; - - exec = "/etc/profiles/per-user/elnu/bin/sensors | /run/current-system/sw/bin/grep \"Package id 0:\" | /run/current-system/sw/bin/tr -d '+' | /run/current-system/sw/bin/awk '{print $4}'"; - }; - # TODO: Only build battery module on ThinkPad host - "module/battery" = { - type = "internal/battery"; - battery = "BAT0"; - adapter = "AC"; - - format-low = " "; - - label-charging = "%{F${primary}}AC%{F-} %percentage%%"; - label-discharging = "%{F${primary}}BAT%{F-} %percentage%%"; - label-full = "%{F${primary}}AC%{F-}"; - - animation-low-0 = "%{F${primary}}BAT%{F-}"; - animation-low-1 = "%{F${alert}}LOW%{F-}"; - - full-at = 96; - low-at = 10; # default - }; "module/date" = { type = "internal/date";