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

36 lines
865 B
Nix

{ pkgs, ... }:
{
home.packages = with pkgs; [
(writeShellScriptBin "sb-volume" ''
# Prints the current volume or if muted.
get_mic_status=$(${pamixer}/bin/pamixer --default-source --get-mute)
vol="$(${pamixer}/bin/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 "0" ]; then
icon="󰕿"
else
icon="󰝟"
fi
if [ $(${pamixer}/bin/pamixer --get-mute) = true ]; then
icon="󰸈"
vol="0"
fi
print_string="$mic_status $icon $vol%"
printf '%s' "[''${print_string}] "
'')
];
}