Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #=======================================================================================================================
- # Description
- # Script to control MPD (music player daemon) using MPC.
- # Parameters
- # 1 - Command, one of the following:
- # prev
- # next
- # toggle
- # random
- # update
- # Version
- # 1.00
- # History
- # 11-03-2010 yktoo Initial version.
- #=======================================================================================================================
- # Setup vars
- cmd=$1
- notify_title="MPD Control"
- #-----------------------------------------------------------------------------------------------------------------------
- # Functions
- #-----------------------------------------------------------------------------------------------------------------------
- #-----------------------------------------------------------------------------------------------------------------------
- # Displays usage info and exits
- # Parameters:
- # none
- usage() {
- echo "Usage: $0 [prev|next|toggle|random|update]"
- exit 1
- }
- #-----------------------------------------------------------------------------------------------------------------------
- # Main routine
- #-----------------------------------------------------------------------------------------------------------------------
- unset notify_text notify_icon
- case "$cmd" in
- prev)
- mpc --no-status prev
- notify_text="$(mpc status | sed '1 ! d')"
- notify_icon='media-skip-backward'
- ;;
- next)
- mpc --no-status next
- notify_text="$(mpc status | sed '1 ! d')"
- notify_icon='media-skip-forward'
- ;;
- toggle)
- mpc --no-status toggle
- if mpc status | grep '\[playing\]' >/dev/null; then
- notify_text="$(mpc status | sed '1 ! d')"
- notify_icon='media-playback-start'
- else
- notify_text='Paused'
- notify_icon='media-playback-pause'
- fi
- ;;
- random)
- mpc --no-status random
- notify_text="$(mpc status | grep -o -r 'random: (on|off)')"
- notify_icon='media-playlist-shuffle'
- ;;
- update)
- mpc --no-status update
- notify_text='Media library has been reloaded'
- notify_icon='reload'
- ;;
- *)
- usage
- esac
- if [[ ! -z "$notify_text" ]]; then
- notify-send -i "$notify_icon" "$notify_title" "$notify_text"
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement