-
Notifications
You must be signed in to change notification settings - Fork 0
/
pause
executable file
·30 lines (21 loc) · 850 Bytes
/
pause
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
# nb: the swp file that editscript relies on is provided by nano
editscript(){
local scriptpath script path swp; scriptpath=$(realpath "$0" 2>/dev/null); script="${scriptpath##*/}"; path="${scriptpath%/*}"; swp="$path/.$script.swp"
[[ ! -e "$swp" ]] && printf "\n\n%s\n\n" "$swp" && (/usr/bin/nano "$scriptpath") && exit
printf "\n%s is already being edited.\n%s exists; try fg or look in another window.\n" "$scriptpath" "$swp"; exit ;}
pause(){ read -rp "$*" < /dev/tty; }
mpcnotify=false
notify(){
notify-send -a "mpctitle toggle" -i audio-x-generic "MPD $state" "<b>$title</b> by <b>$artist</b>"
}
[[ "$1" = @(edit|e|-e) ]] && editscript
[[ "$1" = notify ]] && mpcnotify=true && shift
. mpdignore.functions
mpcp -q toggle &
if "$mpcnotify"; then
source <(mpd-current.py)
notify
exit "$?"
fi
mpctitle "$@"