Polybar: scrolling player status

This commit is contained in:
Filippo Berto 2023-05-01 21:44:01 +02:00
parent a5baf087be
commit 1e76d6ca8c
Signed by: bertof
GPG key ID: 9DBF7E6A1D2CE9ED

View file

@ -4,12 +4,12 @@ let
inherit (pkgs.rice) colorPalette opacity; inherit (pkgs.rice) colorPalette opacity;
grep = "${pkgs.gnugrep}/bin/grep"; grep = "${pkgs.gnugrep}/bin/grep";
cut = "${pkgs.coreutils}/bin/cut"; cut = "${pkgs.coreutils}/bin/cut";
head = "${pkgs.coreutils}/bin/head";
pavucontrol = "${pkgs.pavucontrol}/bin/pavucontrol"; pavucontrol = "${pkgs.pavucontrol}/bin/pavucontrol";
pgrep = "${pkgs.procps}/bin/pgrep"; pgrep = "${pkgs.procps}/bin/pgrep";
pkill = "${pkgs.procps}/bin/pkill"; pkill = "${pkgs.procps}/bin/pkill";
playerCtl = "${pkgs.playerctl}/bin/playerctl"; playerCtl = "${pkgs.playerctl}/bin/playerctl";
dunstctl = "${pkgs.dunst}/bin/dunstctl"; dunstctl = "${pkgs.dunst}/bin/dunstctl";
zscroll = "${pkgs.zscroll}/bin/zscroll";
notificationStatus = pkgs.writeShellScript "notificationStatus" '' notificationStatus = pkgs.writeShellScript "notificationStatus" ''
PATH=$PATH:"${lib.makeBinPath [ pkgs.dbus ]}" PATH=$PATH:"${lib.makeBinPath [ pkgs.dbus ]}"
if [[ `${dunstctl} is-paused` == "true" ]]; then echo ; else echo ; fi if [[ `${dunstctl} is-paused` == "true" ]]; then echo ; else echo ; fi
@ -23,8 +23,16 @@ let
${dunstctl} set-paused false ${dunstctl} set-paused false
for i in {1..10}; do ${dunstctl} history-pop; done for i in {1..10}; do ${dunstctl} history-pop; done
''; '';
playerStatus = playerStatusSrc = pkgs.writeShellScript "playerStatusSrc" ''
"${playerCtl} -f '{{emoji(status)}} {{title}} - {{artist}}' metadata | ${head} -c 50"; ${playerCtl} -f '{{title}} - {{artist}}' metadata
'';
playerStatus = pkgs.writeShellScript "playerStatus" ''
${zscroll} -l 20 -M '${playerCtl} status' -n -s 1 \
-m "Playing" -b ' ' \
-m "Paused" -b ' ' \
-u ${playerStatusSrc} &
wait
'';
confirm_command = { cmd, title ? null, text ? null, image ? null }: confirm_command = { cmd, title ? null, text ? null, image ? null }:
lib.concatStringsSep " " [ lib.concatStringsSep " " [
"${pkgs.yad}/bin/yad --question --center --on-top --sticky --timeout=30 --timeout-indicator=bottom" "${pkgs.yad}/bin/yad --question --center --on-top --sticky --timeout=30 --timeout-indicator=bottom"
@ -137,7 +145,7 @@ in
modules-left = "bspwm"; modules-left = "bspwm";
# modules-center = # modules-center =
modules-right = modules-right =
"player pulseaudio temperature cpu memory battery notifications powermenu date"; "player player-prev player-play-pause player-next pulseaudio temperature cpu memory battery notifications powermenu date";
tray = { tray = {
position = "right"; position = "right";
padding = 1; padding = 1;
@ -148,7 +156,7 @@ in
modules-left = "bspwm"; modules-left = "bspwm";
# modules-center = # modules-center =
modules-right = modules-right =
"player pulseaudio temperature cpu memory battery notifications powermenu date"; "player player-prev player-play-pause player-next pulseaudio temperature cpu memory battery notifications powermenu date";
}; };
"module/battery" = { "module/battery" = {
@ -351,14 +359,33 @@ in
"module/player" = { "module/player" = {
type = "custom/script"; type = "custom/script";
format = recursiveUpdate colors.normal { padding = 0; }; format = colors.normal;
exec = playerStatus; exec = playerStatus;
tail = true;
click.left = "${playerCtl} play-pause"; click.left = "${playerCtl} play-pause";
clicl.right = "${playerCtl} stop";
scroll = { scroll = {
up = "${playerCtl} previous"; up = "${playerCtl} previous";
down = "${playerCtl} next"; down = "${playerCtl} next";
}; };
interval = 1; };
"module/player-prev" = {
type = "custom/script";
format = colors.normal;
exec = "echo 󰒮";
click.left = "${playerCtl} previous";
};
"module/player-next" = {
type = "custom/script";
format = colors.normal;
exec = "echo 󰒭";
click.left = "${playerCtl} next";
};
"module/player-play-pause" = {
type = "custom/script";
format = colors.normal;
exec = "echo 󰐎";
click.left = "${playerCtl} play-pause";
}; };
}; };
}; };