Files
dotfiles/.config/polybar/scripts/modules/playerctl.sh
T
2020-12-30 18:54:45 +01:00

29 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
# Based on https://github.com/PrayagS/polybar-spotify/
# Set the max text length.
# Default is 10 characters
LENGTH=${1:-20}
# Set the source audio player here.
# Players supporting the MPRIS spec are supported.
# Examples: spotify, vlc, chrome, mpv and others.
# Use `playerctld` to always detect the latest player.
# See more here: https://github.com/altdesktop/playerctl/#selecting-players-to-control
PLAYER="playerctld"
# Format of the information displayed
# Eg. {{ artist }} - {{ album }} - {{ title }}
# See more attributes here: https://github.com/altdesktop/playerctl/#printing-properties-and-metadata
FORMAT="{{ title }} - {{ artist }}"
# see man zscroll for documentation of the following parameters
zscroll -l "$LENGTH" \
--delay 0.2 \
--scroll-padding " >> " \
--match-command "playerctl -s --player=$PLAYER status 2>/dev/null" \
--match-text "Playing" "--scroll 1" \
--match-text "Paused" "--scroll 0" \
--update-check true "playerctl -s --player=$PLAYER metadata --format '$FORMAT'" &
wait