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,13 +94,22 @@ in
on-scroll-up = "${mpc} vol +10";
on-scroll-down = "${mpc} vol -10";
};
"custom/playerctl" = {
format = "{}";
exec = "${pkgs.playerctl}/bin/playerctl --ignore-player=mpd metadata title";
on-click = "${pkgs.playerctl}/bin/playerctl --ignore-player=mpd play-pause";
interval = 1;
tooltip = false;
};
"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 = "{}";
exec = "${statusScript}";
on-click = "${playerctl} play-pause";
interval = 1;
tooltip = false;
};
"sway/language" = { format = "{short} {variant}"; };
"custom/caffeine" = {
format = "{}";