playerctl: update playerctl config

This commit is contained in:
lelgenio 2023-02-08 17:12:54 -03:00
parent bd31b35e6b
commit 775181e570
4 changed files with 34 additions and 18 deletions

View file

@ -34,6 +34,7 @@ create_scripts
showkeys =
[ ]; # This will not work unless programs.wshowkeys is enabled systemwide
terminal = [ alacritty ];
playerctl-status = [ playerctl ];
wpass = [ final.wdmenu fd pass sd wl-clipboard wtype ];
screenshotsh =
[ capitaine-cursors grim slurp jq sway wl-clipboard xdg-user-dirs ];

14
scripts/playerctl-status Normal file
View file

@ -0,0 +1,14 @@
#!/bin/sh
PLAYERCTL="playerctl --ignore-player=mpd"
STATUS="$(env LC_ALL=C $PLAYERCTL status title)"
TITLE="$($PLAYERCTL metadata title)"
ARTIST="$($PLAYERCTL metadata artist)"
test "$STATUS" = "Playing" \
&& printf " %s" "$TITLE" \
&& test -n "$ARTIST" \
&& printf " - %s" "$ARTIST"
echo ""

View file

@ -136,6 +136,7 @@ in
code_binds =
lib.mapAttrs' (k: v: lib.nameValuePair "--to-code ${k}" v);
return_mode = lib.mapAttrs (k: v: "${v}; mode default");
playerctl = "exec ${pkgs.playerctl}/bin/playerctl";
in
{
audio = code_binds
@ -166,11 +167,20 @@ in
"Ctrl+c" = "exec musmenu pclear";
};
playerctl = code_binds
((locked_binds
{
${key.left} = "${playerctl} previous";
${key.right} = "${playerctl} next";
${key.up} = "${playerctl} volume 10+";
${key.down} = "${playerctl} volume 10-";
${key.tabR} = "${playerctl} volume 10+";
${key.tabL} = "${playerctl} volume 10-";
}) //
(return_mode {
"space" = "exec ${pkgs.playerctl}/bin/playerctl toggle";
"space" = "${playerctl} play-pause";
"escape" = "";
"q" = "";
});
}));
passthrough = {
"${mod}+escape" = "mode default;exec notify-send 'Passthrough off'";
};

View file

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