-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd
executable file
·31 lines (23 loc) · 997 Bytes
/
add
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
30
31
#!/bin/bash
scriptname=$(realpath "$0")
function editscript(){
local script path; script="${scriptname##*/}"; path="${scriptname%/*}"; swp="$path/.$script.swp"
if [[ ! -e "$swp" ]]; then printf "\n\n%s\n\n" "$swp"; (/usr/bin/nano "$scriptname"); exit
else printf "\n%s is already being edited.\n%s exists; try fg or look in another window.\n" "$scriptname" "$swp"; exit;
fi; }
function pause(){ read -p "$*" ; }
if [[ "$1" == @(edit|e|nano) ]]; then editscript; fi
. "$HOME/.config/mpd-local.conf"
mpccmd=( mpc -h "$mpdpass@$mpchost" )
#. <(mpd-current.py) #using mpc instead.
startlength="$("${mpccmd[@]}" status %length%)"
printf 'Previos playlist lentgth: %s\nItem(s) added: %s\n' "$startlength" "${@:1:1}"
[[ "${@:2:1}" ]] && printf ' %s\n' "${@:2}"
addout="$("${mpccmd[@]}" add "$@")"; ec="$?"
if (( ec )); then
mpctitle -t "$addout"
else
endlength="$("${mpccmd[@]}" status %length%)"
exec mpctitle -h "playlist: $startlength > $endlength"
fi
exit 0