Manage --host option for Kodi controller
This commit is contained in:
parent
a9b8c5ca94
commit
d4ee3807ef
|
@ -19,6 +19,7 @@ export DEBUG
|
||||||
## Default values for some vars
|
## Default values for some vars
|
||||||
readonly USER_MULTIMEDIA_COMMAND_DEFAULT="toggle"
|
readonly USER_MULTIMEDIA_COMMAND_DEFAULT="toggle"
|
||||||
readonly KODI_PROC_REGEXP="kodi.bin"
|
readonly KODI_PROC_REGEXP="kodi.bin"
|
||||||
|
readonly KODI_HOST_DEFAULT="127.0.0.1"
|
||||||
|
|
||||||
## Colors
|
## Colors
|
||||||
readonly PURPLE='\033[1;35m'
|
readonly PURPLE='\033[1;35m'
|
||||||
|
@ -43,9 +44,12 @@ EXAMPLES :
|
||||||
- Stop current current media
|
- Stop current current media
|
||||||
${PROGNAME} --command stop
|
${PROGNAME} --command stop
|
||||||
|
|
||||||
- Send default action (${USER_MULTIMEDIA_COMMAND_DEFAULT}) to Kodi instance
|
- Send default action (${USER_MULTIMEDIA_COMMAND_DEFAULT}) to default Kodi instance
|
||||||
${PROGNAME}
|
${PROGNAME}
|
||||||
|
|
||||||
|
- Toggle current status on remote host (default : ${KODI_HOST_DEFAULT})
|
||||||
|
${PROGNAME} --host 192.168.1.33 --command toggle
|
||||||
|
|
||||||
OPTIONS :
|
OPTIONS :
|
||||||
-c,--command
|
-c,--command
|
||||||
Send a command to running Kodi. Available commands :
|
Send a command to running Kodi. Available commands :
|
||||||
|
@ -55,10 +59,13 @@ OPTIONS :
|
||||||
* previous
|
* previous
|
||||||
* random, party, partymode
|
* random, party, partymode
|
||||||
|
|
||||||
|
-h,--host
|
||||||
|
Set the Kodi host to manage.
|
||||||
|
|
||||||
-d,--debug
|
-d,--debug
|
||||||
Enable debug messages.
|
Enable debug messages.
|
||||||
|
|
||||||
-h,--help
|
--help
|
||||||
Print this help message.
|
Print this help message.
|
||||||
HELP
|
HELP
|
||||||
|
|
||||||
|
@ -89,6 +96,12 @@ error_message() { # {{{
|
||||||
# }}}
|
# }}}
|
||||||
define_vars() { # {{{
|
define_vars() { # {{{
|
||||||
|
|
||||||
|
## If KODI_HOST wasn't defined (argument) {{{
|
||||||
|
if [ -z "${KODI_HOST}" ]; then
|
||||||
|
## Use default value
|
||||||
|
readonly KODI_HOST="${KODI_HOST_DEFAULT}"
|
||||||
|
fi
|
||||||
|
## }}}
|
||||||
## If USER_MULTIMEDIA_COMMAND wasn't defined (argument) {{{
|
## If USER_MULTIMEDIA_COMMAND wasn't defined (argument) {{{
|
||||||
if [ -z "${USER_MULTIMEDIA_COMMAND}" ]; then
|
if [ -z "${USER_MULTIMEDIA_COMMAND}" ]; then
|
||||||
## Use default value
|
## Use default value
|
||||||
|
@ -166,8 +179,8 @@ main() { # {{{
|
||||||
|
|
||||||
## Send Kodi action to running instance {{{
|
## Send Kodi action to running instance {{{
|
||||||
### And exit
|
### And exit
|
||||||
debug_message "Send ${RED}${USER_MULTIMEDIA_COMMAND}${COLOR_DEBUG} (${RED}${KODI_ACTION}${COLOR_DEBUG}) action to running Kodi instance." \
|
debug_message "Send ${RED}${USER_MULTIMEDIA_COMMAND}${COLOR_DEBUG} (${RED}${KODI_ACTION}${COLOR_DEBUG}) action to running Kodi instance (on ${RED}${KODI_HOST}${COLOR_DEBUG} host)." \
|
||||||
&& kodi-send --action="${KODI_ACTION}" > /dev/null \
|
&& kodi-send --host="${KODI_HOST}" --action="${KODI_ACTION}" > /dev/null \
|
||||||
&& exit 0
|
&& exit 0
|
||||||
## }}}
|
## }}}
|
||||||
|
|
||||||
|
@ -205,7 +218,13 @@ if [ ! "${NBARGS}" -eq "0" ]; then
|
||||||
-d|--debug ) ## debug
|
-d|--debug ) ## debug
|
||||||
DEBUG=0
|
DEBUG=0
|
||||||
;;
|
;;
|
||||||
-h|--help ) ## help
|
-h|--host ) ## Kodi host to manage
|
||||||
|
### Move to the next argument
|
||||||
|
shift
|
||||||
|
### Define var
|
||||||
|
KODI_HOST="${1}"
|
||||||
|
;;
|
||||||
|
--help ) ## help
|
||||||
usage
|
usage
|
||||||
## Exit after help informations
|
## Exit after help informations
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in New Issue