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 = showkeys =
[ ]; # This will not work unless programs.wshowkeys is enabled systemwide [ ]; # This will not work unless programs.wshowkeys is enabled systemwide
terminal = [ alacritty ]; terminal = [ alacritty ];
playerctl-status = [ playerctl ];
wpass = [ final.wdmenu fd pass sd wl-clipboard wtype ]; wpass = [ final.wdmenu fd pass sd wl-clipboard wtype ];
screenshotsh = screenshotsh =
[ capitaine-cursors grim slurp jq sway wl-clipboard xdg-user-dirs ]; [ 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 = code_binds =
lib.mapAttrs' (k: v: lib.nameValuePair "--to-code ${k}" v); lib.mapAttrs' (k: v: lib.nameValuePair "--to-code ${k}" v);
return_mode = lib.mapAttrs (k: v: "${v}; mode default"); return_mode = lib.mapAttrs (k: v: "${v}; mode default");
playerctl = "exec ${pkgs.playerctl}/bin/playerctl";
in in
{ {
audio = code_binds audio = code_binds
@ -166,11 +167,20 @@ in
"Ctrl+c" = "exec musmenu pclear"; "Ctrl+c" = "exec musmenu pclear";
}; };
playerctl = code_binds 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 { (return_mode {
"space" = "exec ${pkgs.playerctl}/bin/playerctl toggle"; "space" = "${playerctl} play-pause";
"escape" = ""; "escape" = "";
"q" = ""; "q" = "";
}); }));
passthrough = { passthrough = {
"${mod}+escape" = "mode default;exec notify-send 'Passthrough off'"; "${mod}+escape" = "mode default;exec notify-send 'Passthrough off'";
}; };

View file

@ -94,22 +94,13 @@ 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 format = "{}";
playerctl = "${pkgs.playerctl}/bin/playerctl --ignore-player=mpd"; exec = "${pkgs.playerctl-status}/bin/playerctl-status";
statusScript = pkgs.writeShellScript "waybar-playerctl-status" '' on-click = "${pkgs.playerctl}/bin/playerctl --ignore-player=mpd play-pause";
test "$(env LC_ALL=C ${playerctl} status title)" = "Playing" \ interval = 1;
&& ${playerctl} metadata title \ tooltip = false;
|| echo "" };
'';
in
{
format = "{}";
exec = "${statusScript}";
on-click = "${playerctl} play-pause";
interval = 1;
tooltip = false;
};
"sway/language" = { format = "{short} {variant}"; }; "sway/language" = { format = "{short} {variant}"; };
"custom/caffeine" = { "custom/caffeine" = {
format = "{}"; format = "{}";