diff --git a/hm/desktop/default.nix b/hm/desktop/default.nix index b9770d1..4eaef75 100644 --- a/hm/desktop/default.nix +++ b/hm/desktop/default.nix @@ -100,6 +100,14 @@ }; services = { blueman-applet.enable = true; + batsignal = { + # Battery notifications + enable = true; + extraArgs = [ + "-i" # Ignore missing batteries (for cranberry, and desktops hopefully?) + "-p" # Inform when battery is charging/discharging + ]; + }; dunst = { enable = true; settings = with config.lib.stylix.colors.withHashtag; { diff --git a/hm/desktop/lock/default.nix b/hm/desktop/lock/default.nix index f34f94e..3a32d6c 100644 --- a/hm/desktop/lock/default.nix +++ b/hm/desktop/lock/default.nix @@ -50,7 +50,9 @@ in { # Warn timeout = (idleTime - 1) * 60; - command = ''${lib.getExe pkgs.libnotify} "Screen turns off in 1 minute"''; + # Arbitrary id. Might cause issues but simplify things + command = ''${lib.getExe pkgs.libnotify} -r 87 -t 60000 "Screen turns off in 1 minute"''; + resumeCommand = ''${lib.getExe pkgs.libnotify} -r 87 -t 1 ""''; } { # Screen off diff --git a/hm/desktop/sway/batteryNotify.sh b/hm/desktop/sway/batteryNotify.sh deleted file mode 100755 index 73376a5..0000000 --- a/hm/desktop/sway/batteryNotify.sh +++ /dev/null @@ -1,53 +0,0 @@ -BATT="/sys/class/power_supply/BAT0" -LOW=10 -CRIT=3 -LASTSTATE="$HOME/.cache/batteryState" - -function setState() { # state [...notify-send arguments] - state="$1" - last="$(cat "$LASTSTATE" 2> /dev/null)" - shift - - echo "Battery state: $state" - - if [ "$state" != "$last" ] - then - notify-send "$@" - echo "$state" > "$LASTSTATE" - fi -} - -function computeState() { - acpiStatus="$(cat "$BATT/status")" - acpiCapacity="$(cat "$BATT/capacity")" - - if [ "$acpiStatus" == "Discharging" ] - then - if [ "$acpiCapacity" -le $CRIT ] - then - setState "CRIT" -u critical -i battery-caution "Battery level is critical" "$acpiCapacity %" - elif [ "$acpiCapacity" -le $LOW ] - then - setState "LOW" -u critical -i battery-low "Battery level is low" "$acpiCapacity %" - else - setState "DISCHARGING" -i battery-good "Battery is discharging" "$acpiCapacity %" - fi - elif [ "$acpiStatus" == "Charging" ] - then - setState "CHARGING" -u normal -i battery-good-charging "Battery is charging" "$acpiCapacity %" - elif [ "$acpiStatus" == "Full" ] - then - setState "FULL" -u low -i battery-full-charged "Battery is full" "$acpiCapacity %" - fi -} - -if [ "$1" == "-d" ] -then - while true - do - computeState - sleep 10 - done -else - computeState -fi diff --git a/hm/desktop/sway/default.nix b/hm/desktop/sway/default.nix index 84e5e27..b05989d 100644 --- a/hm/desktop/sway/default.nix +++ b/hm/desktop/sway/default.nix @@ -239,20 +239,6 @@ in command = "${pkgs.systemd}/bin/systemctl --user restart kanshi"; always = true; } - { - command = "${ - pkgs.writeShellApplication { - name = "batteryNotify"; - runtimeInputs = with pkgs; [ - coreutils - libnotify - ]; - text = builtins.readFile ./batteryNotify.sh; - # TODO Use batsignal instead? - # TODO Only on computers with battery - } - }/bin/batteryNotify"; - } ]; workspaceLayout = "tabbed"; workspaceOutputAssign = lib.mkIf (builtins.length screenCombinations > 0) (