mirror of
https://git.adityakumar.xyz/dwmbar.git
synced 2024-11-09 14:19:43 +00:00
Added volumebar and mpd modules.
This commit is contained in:
parent
63399b3319
commit
e611703e03
3 changed files with 63 additions and 4 deletions
8
TODO.org
8
TODO.org
|
@ -11,15 +11,15 @@ Each module writes to stdout.
|
|||
|
||||
* Todo List
|
||||
|
||||
Modules:
|
||||
- MPD (archie)
|
||||
Modules to Write:
|
||||
- Disk Usage
|
||||
- Mail
|
||||
- CPU Usage
|
||||
- Volume Bar (archie)
|
||||
- Memory Usage
|
||||
|
||||
Finished Modules:
|
||||
Working Modules:
|
||||
- Volume Bar
|
||||
- MPD
|
||||
- Backlight
|
||||
- Network
|
||||
- Volume
|
||||
|
|
24
modules/mpd
Executable file
24
modules/mpd
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/bin/bash
|
||||
|
||||
PREFIX_PLAY=' '
|
||||
PREFIX_PAUSE=' '
|
||||
|
||||
get_mpd()
|
||||
{
|
||||
current_song=$(mpc current)
|
||||
|
||||
if [[ "$current_song" = "" ]]; then
|
||||
exit 0
|
||||
else
|
||||
playpause=$(mpc | awk '/\[.*]/{split($0, a, " "); print a[1]}')
|
||||
if [[ "$playpause" = "[playing]" ]]; then
|
||||
current_song=$PREFIX_PLAY$current_song
|
||||
elif [[ "$playpause" = "[paused]" ]]; then
|
||||
current_song=$PREFIX_PAUSE$current_song
|
||||
fi
|
||||
fi
|
||||
|
||||
echo $current_song
|
||||
}
|
||||
|
||||
get_mpd
|
35
modules/volumebar
Executable file
35
modules/volumebar
Executable file
|
@ -0,0 +1,35 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Prints out the volume percentage
|
||||
|
||||
VOLUME_WIDTH=15
|
||||
VOLUME_SLIDER='|'
|
||||
VOLUME_RAIL='-'
|
||||
VOLUME_MUTED='muted'
|
||||
|
||||
PREFIX='VOL'
|
||||
|
||||
get_volume(){
|
||||
active_sink=$(pacmd list-sinks | awk '/* index:/{print $3}')
|
||||
curStatus=$(pacmd list-sinks | grep -A 15 "index: $active_sink$" | awk '/muted/{ print $2}')
|
||||
volume=$(pacmd list-sinks | grep -A 15 "index: $active_sink$" | grep 'volume:' | grep -E -v 'base volume:' | awk -F : '{print $3}' | grep -o -P '.{0,3}%'| sed s/.$// | tr -d ' ')
|
||||
slider_position=$(( $volume / $VOLUME_WIDTH ))
|
||||
|
||||
if [ "${curStatus}" = 'yes' ]
|
||||
then
|
||||
echo "$VOLUME_MUTED"
|
||||
exit 0
|
||||
else
|
||||
for i in $(seq 1 $slider_position); do
|
||||
BAR=$BAR$VOLUME_RAIL
|
||||
done
|
||||
BAR=$BAR$VOLUME_SLIDER
|
||||
for i in $(seq $slider_position $VOLUME_WIDTH); do
|
||||
BAR=$BAR$VOLUME_RAIL
|
||||
done
|
||||
fi
|
||||
|
||||
echo "$PREFIX$BAR"
|
||||
}
|
||||
|
||||
get_volume
|
Loading…
Reference in a new issue