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

36 lines
862 B
Nix
Raw Normal View History

2024-06-14 21:48:43 +01:00
{ pkgs, ... }:
{
home.packages = with pkgs; [
(writeShellScriptBin "sb-volume" ''
# Prints the current volume or 婢 if muted.
2024-06-14 22:00:56 +01:00
get_mic_status=$(${pamixer}/bin/pamixer --default-source --get-mute)
vol="$(${pamixer}/bin/pamixer --get-volume)"
2024-06-14 21:48:43 +01:00
if [ $get_mic_status == false ]; then
mic_status=""
else
mic_status=""
fi
if [ "$vol" -gt "90" ]; then
icon="󰕾"
2024-06-15 17:25:54 +01:00
elif [ "$vol" -gt "50" ]; then
icon="󰖀"
2024-06-14 21:48:43 +01:00
elif [ "$vol" -gt "0" ]; then
icon="󰕿"
else
icon="󰝟"
fi
2024-06-14 22:00:56 +01:00
if [ $(${pamixer}/bin/pamixer --get-mute) = true ]; then
2024-06-14 21:48:43 +01:00
icon="󰸈"
vol="0"
fi
print_string="$mic_status $icon $vol%"
printf '%s' "''${print_string}"
'')
];
}