123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- # variables
- mpc="/usr/bin/mpc -h $mpd_host"
- # functions
- function 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 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 $value
- fi
- }
- function _ensure_volume_10 {
- if (( $($mpc volume | grep -o '...%' | tr -d '%') < 10 )); then
- mpd_set_volume 10
- fi
- }
|