Hi,
Maybe someone can use it…
Cheekily copied from volumio.sh
- Copy the code into a file on your Unix box
- save it under “yourname”
- make it executable
- call it with “yourname” remote_volumio_host command [option]
Example: “yourname” remote_host volume 50
[code]#!/bin/bash
needs jq - “sudo apt install jq” for Ubuntu
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PRG=basename $0
doc()
{
echo "
Usage : $PRG host command [argument]
<>
status Gives Playback status information
volume Gives Current Volume Information
volume [desired volume] Sets Volume at desired level 0-100 in steps of 10
volume mute Mutes
volume unmute Unmutes
volume plus Increases Volume of one step
volume minus Decreases Volume of one step
seek plus Forwards 10 seconds in the song
seek minus Backwards 10 seconds in the song
seek [seconds] Plays song from selected time
repeat Toggles repetition of queue
random Toggles randomization of queue
<>
play
pause
next
previous
stop
clear
"
exit 1
}
host=$1
ping -c 1 -n -q $host > /dev/null 2>&1
[ $? -ne 0 ] && doc
case “$2” in
play)
/usr/bin/curl “http://$host/api/v1/commands/?cmd=play”
echo “”
;;
toggle)
/usr/bin/curl “http://$host/api/v1/commands/?cmd=toggle”
echo “”
;;
pause)
/usr/bin/curl “http://$host/api/v1/commands/?cmd=pause”
echo “”
;;
next)
/usr/bin/curl “http://$host/api/v1/commands/?cmd=next”
echo “”
;;
previous)
/usr/bin/curl “http://$host/api/v1/commands/?cmd=prev”
echo “”
;;
stop)
/usr/bin/curl “http://$host/api/v1/commands/?cmd=stop”
echo “”
;;
clear)
/usr/bin/curl “http://$host/api/v1/commands/?cmd=clearQueue”
echo “”
;;
seek)
if [ “$3” != “” ]; then
/usr/bin/curl “http://$host/api/v1/commands/?cmd=seek&position=$3”
echo “”
else
/usr/bin/curl -sS “http://$host/api/v1/getstate” | /usr/bin/jq -r ‘.seek’
echo “”
fi
;;
repeat)
if [ “$3” != “” ]; then
/usr/bin/curl “http://$host/api/v1/commands/?cmd=repeat&value=$3”
echo “”
else
/usr/bin/curl “http://$host/api/v1/commands/?cmd=repeat”
echo “”
fi
;;
random)
if [ “$3” != “” ]; then
/usr/bin/curl “http://$host/api/v1/commands/?cmd=random&value=$3”
echo “”
else
/usr/bin/curl “http://$host/api/v1/commands/?cmd=random”
echo “”
fi
;;
status)
/usr/bin/curl -sS “http://$host/api/v1/getstate” | /usr/bin/jq -r ‘.’
echo “”
;;
volume)
if [ “$3” != “” ]; then
/usr/bin/curl “http://$host/api/v1/commands/?cmd=volume&volume=$3”
echo “”
else
/usr/bin/curl -sS “http://$host/api/v1/getstate” | /usr/bin/jq -r ‘.volume’
echo “”
fi
;;
*)
doc
esac
vim: set noai ts=3 sw=3 sts=3 et :
[/code]