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;
grep = "${pkgs.gnugrep}/bin/grep";
cut = "${pkgs.coreutils}/bin/cut";
head = "${pkgs.coreutils}/bin/head";
pavucontrol = "${pkgs.pavucontrol}/bin/pavucontrol";
pgrep = "${pkgs.procps}/bin/pgrep";
pkill = "${pkgs.procps}/bin/pkill";
playerCtl = "${pkgs.playerctl}/bin/playerctl";
dunstctl = "${pkgs.dunst}/bin/dunstctl";
zscroll = "${pkgs.zscroll}/bin/zscroll";
notificationStatus = pkgs.writeShellScript "notificationStatus" ''
PATH=$PATH:"${lib.makeBinPath [ pkgs.dbus ]}"
if [[ `${dunstctl} is-paused` == "true" ]]; then echo ; else echo ; fi
@ -23,8 +23,16 @@ let
${dunstctl} set-paused false
for i in {1..10}; do ${dunstctl} history-pop; done
'';
playerStatus =
"${playerCtl} -f '{{emoji(status)}} {{title}} - {{artist}}' metadata | ${head} -c 50";
playerStatusSrc = pkgs.writeShellScript "playerStatusSrc" ''
${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 }:
lib.concatStringsSep " " [
"${pkgs.yad}/bin/yad --question --center --on-top --sticky --timeout=30 --timeout-indicator=bottom"
@ -137,7 +145,7 @@ in
modules-left = "bspwm";
# modules-center =
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 = {
position = "right";
padding = 1;
@ -148,7 +156,7 @@ in
modules-left = "bspwm";
# modules-center =
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" = {
@ -351,14 +359,33 @@ in
"module/player" = {
type = "custom/script";
format = recursiveUpdate colors.normal { padding = 0; };
format = colors.normal;
exec = playerStatus;
tail = true;
click.left = "${playerCtl} play-pause";
clicl.right = "${playerCtl} stop";
scroll = {
up = "${playerCtl} previous";
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";
};
};
};