ironbar: Replace volume polling with watch script

Makes changes instantaneous and avoids polling.
This commit is contained in:
Donovan Glover 2024-04-08 08:12:40 -04:00
parent a83409f8e6
commit e0606c4590
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65

View File

@ -8,6 +8,8 @@ let
mullvadScript = "ironbar/mullvad.fish";
mullvadNotification = "ironbar/mullvad-notification.fish";
volumeScript = "ironbar/volume.fish";
volumeGet = "ironbar/volume-get.fish";
in
{
home.packages = [ ironbar ];
@ -51,9 +53,8 @@ in
}
{
type = "script";
cmd = "fish -c 'echo \"$(math \"$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | choose 1) * 100\")%\"'";
mode = "poll";
interval = 2500;
cmd = "~/.config/${volumeScript}";
mode = "watch";
}
{
type = "clock";
@ -239,4 +240,30 @@ in
end
'';
};
xdg.configFile.${volumeScript} = {
executable = true;
text = /* fish */ ''
#!/usr/bin/env fish
function get_volume
set VOLUME (wpctl get-volume @DEFAULT_AUDIO_SINK@ | choose 1)
echo "$(math "$VOLUME * 100")%"
end
~/.config/${volumeGet}
pactl subscribe | grep --line-buffered -e "" | xargs -L 1 ~/.config/${volumeGet}
'';
};
xdg.configFile.${volumeGet} = {
executable = true;
text = /* fish */ ''
#!/usr/bin/env fish
set VOLUME (wpctl get-volume @DEFAULT_AUDIO_SINK@ | choose 1)
echo "$(math "$VOLUME * 100")%"
'';
};
}