Improve notifications
This commit is contained in:
parent
1843c63924
commit
a70cb66771
4 changed files with 11 additions and 68 deletions
|
@ -100,6 +100,14 @@
|
||||||
};
|
};
|
||||||
services = {
|
services = {
|
||||||
blueman-applet.enable = true;
|
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 = {
|
dunst = {
|
||||||
enable = true;
|
enable = true;
|
||||||
settings = with config.lib.stylix.colors.withHashtag; {
|
settings = with config.lib.stylix.colors.withHashtag; {
|
||||||
|
|
|
@ -50,7 +50,9 @@ in
|
||||||
{
|
{
|
||||||
# Warn
|
# Warn
|
||||||
timeout = (idleTime - 1) * 60;
|
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
|
# Screen off
|
||||||
|
|
|
@ -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
|
|
|
@ -239,20 +239,6 @@ in
|
||||||
command = "${pkgs.systemd}/bin/systemctl --user restart kanshi";
|
command = "${pkgs.systemd}/bin/systemctl --user restart kanshi";
|
||||||
always = true;
|
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";
|
workspaceLayout = "tabbed";
|
||||||
workspaceOutputAssign = lib.mkIf (builtins.length screenCombinations > 0) (
|
workspaceOutputAssign = lib.mkIf (builtins.length screenCombinations > 0) (
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue