1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- # variables
- mpc="/usr/bin/mpc -h $mpd_host"
- # functions
- function mpd_play_folder {
- tag = $1
- mkdir -p /music/$tag
- # Update the directory timestamp to indicate what was the last tag found
- # Touch the file alone will not update the directory timestamp,
- # so we'll need delete and recreate the file
- rm /music/$tag/.lastplay
- touch /music/$tag/.lastplay
- $mpc stop
- $mpc clear
- $mpc add $mpd_folder$tag
- _ensure_volume_10
- $mpc play
- }
- function mpd_play {
- $mpc stop
- $mpc clear
- $mpc add "$1"
- _ensure_volume_10
- $mpc play 1
- }
- function mpd_play_shuffle {
- $mpc stop
- $mpc clear
- $mpc add "$1"
- $mpc shuffle
- _ensure_volume_10
- $mpc play 1
- }
- function mpd_stop {
- $mpc stop
- }
- function mpd_pause_play {
- if ($mpc | grep -q playing); then # when playing
- $mpc pause
- else
- $mpc play
- fi
- }
- function vol_min {
- mpd_set_volume 5
- }
- function mpd_med {
- mpd_set_volume 50
- }
- function mpd_vol_max {
- mpd_set_volume 75
- }
- function mpd_set_volume {
- if [ -n "$1" ]; then # non-zero length
- $mpc volume $1
- fi
- }
- function _ensure_volume_10 {
- if (( $($mpc volume | grep -o '...%' | tr -d '%') < 10 )); then
- mpd_set_volume 10
- fi
- }
|