nixos/home/common/optional/desktop/dwm/scripts/sb-volume.nix

50 lines
1.4 KiB
Nix

{ pkgs, ... }:
{
home.packages = with pkgs; [
(writeShellScriptBin "sb-volume" ''
# Prints the current volume or if muted.
case $BLOCK_BUTTON in
1) setsid -f "$TERMINAL" -e pulsemixer ;;
2) pamixer -t && pkill -RTMIN+10 dwmblocks && exit 1 ;;
4) pamixer --set-limit 150 --allow-boost -i 1 && pkill -RTMIN+10 dwmblocks && exit 1 ;;
5) pamixer --set-limit 150 --allow-boost -d 1 && pkill -RTMIN+10 dwmblocks && exit 1 ;;
3) notify-send "Volume module" "\- Shows volume , if muted.
- Middle click to mute.
- Scroll to change." ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
get_mic_status=$(pamixer --default-source --get-mute)
vol="$(pamixer --get-volume)"
if [ $get_mic_status == false ]; then
mic_status=""
else
mic_status=""
fi
if [ "$vol" -gt "90" ]; then
icon=""
elif [ "$vol" -gt "50" ]; then
icon="󰕾"
elif [ "$vol" -gt "30" ]; then
icon=""
elif [ "$vol" -gt "0" ]; then
icon="󰕿"
else
icon="󰝟"
fi
if [ $(pamixer --get-mute) = true ]; then
icon="󰸈"
vol="0"
fi
print_string="$mic_status $icon $vol%"
printf '%s' "''${print_string}"
'')
];
}