Skip to content

Commit

Permalink
feat: get shuffle status from d-bus
Browse files Browse the repository at this point in the history
  • Loading branch information
Malanius committed Jan 3, 2024
1 parent aba2ef6 commit 990bad3
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions scripts/spotify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ toggle_repeat() {
fi
}

get_shuffle_status() {
echo $(busctl -j --user get-property org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player Shuffle | jq -r '.data')
}

toggle_shuffle() {
if [ "$1" == "true" ]; then
$(osascript -e "tell application \"Spotify\" to set shuffling to false")
Expand Down Expand Up @@ -73,23 +77,23 @@ show_menu() {
local album=$(echo $metadata | jq -r '.data["xesam:album"].data')
local id=$(echo $metadata | jq -r '.data["mpris:trackid"].data')

local is_repeat_on=${arr[0]}
local is_shuffle_on=${arr[1]}
local is_shuffle_on=$(get_shuffle_status)
local shuffling_label=""
if [ "$is_shuffle_on" == "true" ]; then
shuffling_label="Turn off shuffle"
else
shuffling_label="Turn on shuffle"
fi

local is_repeat_on=${arr[0]}
local repeating_label=""
local shuffling_label=""

if [ "$is_repeat_on" == "true" ]; then
repeating_label="Turn off repeat"
else
repeating_label="Turn on repeat"
fi

if [ "$is_shuffle_on" == "true" ]; then
shuffling_label="Turn off shuffle"
else
shuffling_label="Turn on shuffle"
fi
$(
tmux display-menu -T "#[align=centre fg=green] Spotify " -x R -y P \
"" \
Expand Down

0 comments on commit 990bad3

Please sign in to comment.