Browse Source

Add dwm_spotify

patch-fontkeys
joestandring 4 years ago
parent
commit
3ea0216410
3 changed files with 51 additions and 3 deletions
  1. +11
    -2
      README.md
  2. +38
    -0
      bar-functions/dwm_spotify.sh
  3. +2
    -1
      dwm_bar.sh

+ 11
- 2
README.md View File

@ -12,6 +12,7 @@ A modular statusbar for DWM
- [dwm_resources](#dwm_resources) - [dwm_resources](#dwm_resources)
- [dwm_cmus](#dwm_cmus) - [dwm_cmus](#dwm_cmus)
- [dwm_mpc](#dwm_mpc) - [dwm_mpc](#dwm_mpc)
- [dwm_spotify](#dwm_mpc)
- [dwm_date](#dwm_date) - [dwm_date](#dwm_date)
- [dwm_mail](#dwm_mail) - [dwm_mail](#dwm_mail)
- [dwm_weather](#dwm_weather) - [dwm_weather](#dwm_weather)
@ -67,17 +68,25 @@ Displays information regarding memory, CPU temperature, and storage
[🖥 MEM 1.3Gi/15Gi CPU 45C STO 2.3G/200G: 2%] [🖥 MEM 1.3Gi/15Gi CPU 45C STO 2.3G/200G: 2%]
``` ```
### dwm_cmus ### dwm_cmus
displays current cmus status, artist, track, position, duration, and shuffle
Displays current cmus status, artist, track, position, duration, and shuffle
``` ```
[▶ The Unicorns - Tuff Ghost 0:43/2:56 🔀] [▶ The Unicorns - Tuff Ghost 0:43/2:56 🔀]
``` ```
Dependencies: ```cmus``` Dependencies: ```cmus```
### dwm_mpc ### dwm_mpc
displays current mpc status, artist, track, position, duration, and shuffle
Displays current mpc status, artist, track, position, duration, and shuffle
``` ```
[▶ The Unicorns - Tuff Ghost 0:43/2:56 🔀] [▶ The Unicorns - Tuff Ghost 0:43/2:56 🔀]
``` ```
Dependencies: ```mpc``` Dependencies: ```mpc```
### dwm_mpc
Displays current Spotify status, artist, track, and duration
Unfortunatley a method to display the track position and shuffle status have not been found
```
[▶ The Unicorns - Tuff Ghost 2:56]
```
Dependencies: ```spotify, playerctl```
### dwm_date ### dwm_date
Displays the current date and time Displays the current date and time
``` ```


+ 38
- 0
bar-functions/dwm_spotify.sh View File

@ -0,0 +1,38 @@
#!/bin/sh
# A dwm_bar function that shows the current artist, track, duration, and status from Spotify using playerctl
# Joe Standring <git@joestandring.com>
# GNU GPLv3
# Dependencies: spotify, playerctl
# TODO: Find a method to get track position data and shuffle status (currently playerctl does not work for this)
dwm_spotify () {
if ps -C spotify > /dev/null; then
ARTIST=$(playerctl -p spotify metadata artist)
TRACK=$(playerctl -p spotify metadata title)
DURATION=$(playerctl -p spotify metadata mpris:length | sed 's/.\{6\}$//')
STATUS=$(playerctl -p spotify status)
if [ "$IDENTIFIER" = "unicode" ]; then
if [ "$STATUS" = "Playing" ]; then
STATUS="▶"
else
STATUS="⏸"
fi
else
if [ "$STATUS" = "Playing" ]; then
STATUS="PLA"
else
STATUS="PAU"
fi
fi
printf "%s%s %s - %s " "$SEP1" "$STATUS" "$ARTIST" "$TRACK"
printf "%0d:%02d" $((DURATION%3600/60)) $((DURATION%60))
printf "%s\n" "$SEP2"
fi
}
dwm_spotify

+ 2
- 1
dwm_bar.sh View File

@ -27,6 +27,7 @@ export SEP2="]"
. "$DIR/bar-functions/dwm_transmission.sh" . "$DIR/bar-functions/dwm_transmission.sh"
. "$DIR/bar-functions/dwm_cmus.sh" . "$DIR/bar-functions/dwm_cmus.sh"
. "$DIR/bar-functions/dwm_mpc.sh" . "$DIR/bar-functions/dwm_mpc.sh"
. "$DIR/bar-functions/dwm_spotify.sh"
. "$DIR/bar-functions/dwm_resources.sh" . "$DIR/bar-functions/dwm_resources.sh"
. "$DIR/bar-functions/dwm_battery.sh" . "$DIR/bar-functions/dwm_battery.sh"
. "$DIR/bar-functions/dwm_mail.sh" . "$DIR/bar-functions/dwm_mail.sh"
@ -43,6 +44,6 @@ export SEP2="]"
# Update dwm status bar every second # Update dwm status bar every second
while true while true
do do
xsetroot -name "$(dwm_countdown)$(dwm_alarm.sh)$(dwm_transmission)$(dwm_cmus)$(dwm_mpc)$(dwm_resources)$(dwm_battery)$(dwm_mail)$(dwm_backlight)$(dwm_alsa)$(dwm_pulse)$(dwm_weather)$(dwm_vpn)$(dwm_network)$(dwm_keyboard)$(dwm_ccurse)$(dwm_date)"
xsetroot -name "$(dwm_countdown)$(dwm_alarm.sh)$(dwm_transmission)$(dwm_cmus)$(dwm_mpc)$(dwm_spotify)$(dwm_resources)$(dwm_battery)$(dwm_mail)$(dwm_backlight)$(dwm_alsa)$(dwm_pulse)$(dwm_weather)$(dwm_vpn)$(dwm_network)$(dwm_keyboard)$(dwm_ccurse)$(dwm_date)"
sleep 1 sleep 1
done done

Loading…
Cancel
Save