waybar: only show playerctl status when playing

This commit is contained in:
Leonardo Eugênio 2023-02-08 12:41:46 -03:00
parent 884a8df73c
commit a846f50b42

View file

@ -94,10 +94,19 @@ in
on-scroll-up = "${mpc} vol +10"; on-scroll-up = "${mpc} vol +10";
on-scroll-down = "${mpc} vol -10"; on-scroll-down = "${mpc} vol -10";
}; };
"custom/playerctl" = { "custom/playerctl" =
let
playerctl = "${pkgs.playerctl}/bin/playerctl --ignore-player=mpd";
statusScript = pkgs.writeShellScript "waybar-playerctl-status" ''
test "$(env LC_ALL=C ${playerctl} status title)" = "Playing" \
&& ${playerctl} metadata title \
|| echo ""
'';
in
{
format = "{}"; format = "{}";
exec = "${pkgs.playerctl}/bin/playerctl --ignore-player=mpd metadata title"; exec = "${statusScript}";
on-click = "${pkgs.playerctl}/bin/playerctl --ignore-player=mpd play-pause"; on-click = "${playerctl} play-pause";
interval = 1; interval = 1;
tooltip = false; tooltip = false;
}; };