2 ## Wrapper for mpd-state to make it behave like state-utils.
3 ## Copyright (c) 2005 by Michal Nazareicz <mina86@mina86.com>
5 ## This program is free software; you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or
8 ## (at your option) any later version.
10 ## This program is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ## GNU General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with this program; if not, see <http://www.gnu.org/licenses/>.
18 ## This is part of Tiny Applications Collection
19 ## -> http://tinyapps.sourceforge.net/
23 # To install copy this file to (eg.) /usr/local/bin and make the
24 # fallowing symlinks: state-save, state-restore, state-sync and
25 # state-amend all pointing to this wrapper.
28 if [ "$1" = "--help" ]; then
30 usage: state-save [ <state-name> ]
31 state-restore [ <state-name> ]
32 state-sync [ <mpd-host> [ <mpd-port> ] ]
33 state-amend [ <state-name> ]
34 state-save saves MPD state to a file.
35 state-restores resotres saved state to MPD.
36 state-sync tries to sync two MPD servers as close as possible.
37 state-amend adds playlist from specified state to MPD.
45 while true
; do case "$ARG0" in
47 mkdir
-p ~
/.mpd_states
&& mpd-state
>~
/.mpd_states
/"${1-default}"
51 (state-restore|restore
)
52 if [ -f ~
/".mpd_states/${1-default}" ]; then
53 mpd-state
-r <~
/.mpd_sates
/"${1-default}"
56 # shellcheck disable=SC2088
57 echo File
"~/.mpd_states/${1-default}" does not exist
>&2
63 mpd-state | mpd-state
-r "${1-localhost}" "${2-6600}"
68 if [ -f ~
/".mpd_states/${1-default}" ]; then
69 mpd-state
-raP <~
/.mpd_sates
/"${1-default}"
72 # shellcheck disable=SC2088
73 echo File
"~/.mpd_states/${1-default}" does not exist
>&2
79 if [ -z "$SHIFTED" ] && [ $# -ne 0 ]; then
84 echo 'This script should be run as one of:'
85 echo ' state-save, state-restore, state-sync or state-amend'
86 echo 'or with one of those strings as firt argument optionaly w/o state- prefix'