notification configured

This commit is contained in:
Semere Meharena Mebrahtom 2026-07-19 22:17:48 +02:00
parent 6f3c035316
commit e9bdc40a28
Signed by: semere
GPG key ID: 7FC937214DF30488
6 changed files with 106 additions and 29 deletions

56
modules/osd.nix Normal file
View file

@ -0,0 +1,56 @@
{
config,
lib,
pkgs,
userVars,
...
}:
{
home-manager.users."${userVars.username}" = {
xdg.configFile."fnott/scripts/osd.sh" = {
text = ''
#!/usr/bin/env bash
# usage: osd.sh [volume|brightness] [raise|lower|mute]
ACTION=$1
DIRECTION=$2
if [ "$ACTION" = "volume" ]; then
if [ "$DIRECTION" = "raise" ]; then
pamixer -i 5
elif [ "$DIRECTION" = "lower" ]; then
pamixer -d 5
elif [ "$DIRECTION" = "mute" ]; then
pamixer -t
fi
# Query state
VOLUME=$(pamixer --get-volume)
MUTED=$(pamixer --get-mute-status)
if [ "$MUTED" = "true" ]; then
notify-send -h int:value:0 -h string:x-canonical-private-synchronous:volume -i audio-volume-muted -t 1000 "Muted"
else
notify-send -h int:value:"$VOLUME" -h string:x-canonical-private-synchronous:volume -i audio-volume-high -t 1000 "Volume: $VOLUME%"
fi
elif [ "$ACTION" = "brightness" ]; then
if [ "$DIRECTION" = "raise" ]; then
brightnessctl set 10%+
elif [ "$DIRECTION" = "lower" ]; then
brightnessctl set 10%-
fi
# Query state
CURR=$(brightnessctl get)
MAX=$(brightnessctl max)
PCT=$(( (CURR * 100) / MAX ))
notify-send -h int:value:"$PCT" -h string:x-canonical-private-synchronous:brightness -i display-brightness -t 1000 "Brightness: $PCT%"
fi
'';
executable = true;
};
};
}