display spotify song info in tmux

This commit is contained in:
Oliver Ladner 2024-02-05 15:06:15 +01:00
commit c22188f54c
5 changed files with 85 additions and 58 deletions

View file

@ -35,10 +35,10 @@ set -g status-style fg=#9d7cd8,bg=#16161e
set-window-option -g window-status-current-style bg=#3e3158
set -g status-position top
set -g status-interval 10
set -g status-left "#( ~/tmux_left.sh )"
set -g status-left-length 60
set -g status-left ' Remember tmux layer'
set -g status-justify centre
set -g status-right "#( ~/tmux.sh )"
set -g status-right "#( ~/tmux_right.sh )"
set -g status-right-length 60
# Get good colors

21
spotify.applescript Executable file
View file

@ -0,0 +1,21 @@
#!/usr/bin/env osascript
# Returns the current playing song in Spotify for OSX
tell application "Spotify"
if it is running then
if player state is playing then
set track_name to name of current track
set artist_name to artist of current track
if artist_name > 0
# If the track has an artist set and is therefore most likely a song rather than an advert
"♫ " & artist_name & " - " & track_name
else
# If the track doesn't have an artist set and is therefore most likely an advert rather than a song
"~ " & track_name
end if
else
"⏸︎ Spotify is paused"
end if
end if
end tell

6
tmux_left.sh Executable file
View file

@ -0,0 +1,6 @@
#!/usr/bin/env bash
# Trigger Applescript when on macOS
if [[ "$OSTYPE" == "darwin"* ]]; then
~/git/dotfiles/spotify.applescript
fi