Browse Source

Add dwm_mpc

patch-fontkeys
joestandring 4 years ago
parent
commit
80bbe5d640
3 changed files with 57 additions and 1 deletions
  1. +7
    -0
      README.md
  2. +48
    -0
      bar-functions/dwm_mpc.sh
  3. +2
    -1
      dwm_bar.sh

+ 7
- 0
README.md View File

@ -11,6 +11,7 @@ A modular statusbar for DWM
- [dwm_keyboard](#dwm_keyboard)
- [dwm_resources](#dwm_resources)
- [dwm_cmus](#dwm_cmus)
- [dwm_mpc](#dwm_mpc)
- [dwm_date](#dwm_date)
- [dwm_mail](#dwm_mail)
- [dwm_weather](#dwm_weather)
@ -71,6 +72,12 @@ displays current cmus status, artist, track, position, duration, and shuffle
[▶ The Unicorns - Tuff Ghost 0:43/2:56 🔀]
```
Dependencies: ```cmus```
### dwm_mpc
displays current mpc status, artist, track, position, duration, and shuffle
```
[▶ The Unicorns - Tuff Ghost 0:43/2:56 🔀]
```
Dependencies: ```mpc```
### dwm_date
Displays the current date and time
```


+ 48
- 0
bar-functions/dwm_mpc.sh View File

@ -0,0 +1,48 @@
#!/bin/sh
# A dwm_bar function that shows the current artist, track, position, duration, and status from mpc
# Joe Standring <git@joestandring.com>
# GNU GPLv3
# Dependencies: mpc
dwm_mpc () {
if ps -C mpd > /dev/null; then
ARTIST=$(mpc current -f %artist%)
TRACK=$(mpc current -f %title%)
POSITION=$(mpc status | grep "%)" | awk '{ print $3 }' | awk -F/ '{ print $1 }')
DURATION=$(mpc current -f %time%)
STATUS=$(mpc status | sed -n 2p | awk '{print $1;}')
SHUFFLE=$(mpc status | tail -n 1 | awk '{print $6}')
if [ "$IDENTIFIER" = "unicode" ]; then
if [ "$STATUS" = "[playing]" ]; then
STATUS="▶"
else
STATUS="⏸"
fi
if [ "$SHUFFLE" = "on" ]; then
SHUFFLE=" 🔀"
else
SHUFFLE=""
fi
else
if [ "$STATUS" = "[playing]" ]; then
STATUS="PLA"
else
STATUS="PAU"
fi
if [ "$SHUFFLE" = "on" ]; then
SHUFFLE=" S"
else
SHUFFLE=""
fi
fi
printf "%s%s %s - %s %s/%s%s%s" "$SEP1" "$STATUS" "$ARTIST" "$TRACK" "$POSITION" "$DURATION" "$SHUFFLE" "$SEP2"
fi
}
dwm_mpc

+ 2
- 1
dwm_bar.sh View File

@ -26,6 +26,7 @@ export SEP2="]"
. "$DIR/bar-functions/dwm_alarm.sh"
. "$DIR/bar-functions/dwm_transmission.sh"
. "$DIR/bar-functions/dwm_cmus.sh"
. "$DIR/bar-functions/dwm_mpc.sh"
. "$DIR/bar-functions/dwm_resources.sh"
. "$DIR/bar-functions/dwm_battery.sh"
. "$DIR/bar-functions/dwm_mail.sh"
@ -42,6 +43,6 @@ export SEP2="]"
# Update dwm status bar every second
while true
do
xsetroot -name "$(dwm_countdown)$(dwm_alarm.sh)$(dwm_transmission)$(dwm_cmus)$(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_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
done

Loading…
Cancel
Save