aboutsummaryrefslogtreecommitdiff
path: root/.config/polybar/scripts/get_spotify_status.sh
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2025-08-30 19:22:59 +0200
committersrdusr <trevorgray@srdusr.com>2025-08-30 19:22:59 +0200
commit19120d4f9761c67d99ed1ce3da6084b83f5a49c9 (patch)
treef234cad1bdad88114a63c9702144da487024967a /.config/polybar/scripts/get_spotify_status.sh
parent5928998af5404ae2be84c6cecc10ebf84bd3f3ed (diff)
downloaddotfiles-19120d4f9761c67d99ed1ce3da6084b83f5a49c9.tar.gz
dotfiles-19120d4f9761c67d99ed1ce3da6084b83f5a49c9.zip
Linux-specific dotfiles
Diffstat (limited to '.config/polybar/scripts/get_spotify_status.sh')
-rwxr-xr-x.config/polybar/scripts/get_spotify_status.sh52
1 files changed, 0 insertions, 52 deletions
diff --git a/.config/polybar/scripts/get_spotify_status.sh b/.config/polybar/scripts/get_spotify_status.sh
deleted file mode 100755
index f04400d..0000000
--- a/.config/polybar/scripts/get_spotify_status.sh
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/bin/bash
-
-# The name of polybar bar which houses the main spotify module and the control modules.
-PARENT_BAR="now-playing"
-PARENT_BAR_PID=$(pgrep -a "polybar" | grep "$PARENT_BAR" | cut -d" " -f1)
-
-# 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="spotify"
-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 }}"
-
-# Sends $2 as message to all polybar PIDs that are part of $1
-update_hooks() {
- while IFS= read -r id
- do
- polybar-msg -p "$id" hook spotify-play-pause $2 1>/dev/null 2>&1
- done < <(echo "$1")
-}
-
-PLAYERCTL_STATUS=$(playerctl --player=$PLAYER status 2>/dev/null)
-EXIT_CODE=$?
-
-if [ $EXIT_CODE -eq 0 ]; then
- STATUS=$PLAYERCTL_STATUS
-else
- STATUS="No player is running"
-fi
-
-if [ "$1" == "--status" ]; then
- echo "$STATUS"
-else
- if [ "$STATUS" = "Stopped" ]; then
- echo "No music is playing"
- elif [ "$STATUS" = "Paused" ]; then
- update_hooks "$PARENT_BAR_PID" 2
- playerctl --player=$PLAYER metadata --format "$FORMAT"
- elif [ "$STATUS" = "No player is running" ]; then
- echo ""
- else
- update_hooks "$PARENT_BAR_PID" 1
- playerctl --player=$PLAYER metadata --format "$FORMAT"
- fi
-fi
-