diff --git a/kodi.controller.sh b/kodi.controller.sh index add07a7..f33c1dc 100755 --- a/kodi.controller.sh +++ b/kodi.controller.sh @@ -19,6 +19,7 @@ export DEBUG ## Default values for some vars readonly USER_MULTIMEDIA_COMMAND_DEFAULT="toggle" readonly KODI_PROC_REGEXP="kodi.bin" +readonly KODI_HOST_DEFAULT="127.0.0.1" ## Colors readonly PURPLE='\033[1;35m' @@ -43,9 +44,12 @@ EXAMPLES : - Stop current current media ${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} + - Toggle current status on remote host (default : ${KODI_HOST_DEFAULT}) + ${PROGNAME} --host 192.168.1.33 --command toggle + OPTIONS : -c,--command Send a command to running Kodi. Available commands : @@ -55,10 +59,13 @@ OPTIONS : * previous * random, party, partymode + -h,--host + Set the Kodi host to manage. + -d,--debug Enable debug messages. - -h,--help + --help Print this help message. HELP @@ -89,6 +96,12 @@ error_message() { # {{{ # }}} 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 [ -z "${USER_MULTIMEDIA_COMMAND}" ]; then ## Use default value @@ -166,8 +179,8 @@ main() { # {{{ ## Send Kodi action to running instance {{{ ### And exit - debug_message "Send ${RED}${USER_MULTIMEDIA_COMMAND}${COLOR_DEBUG} (${RED}${KODI_ACTION}${COLOR_DEBUG}) action to running Kodi instance." \ - && kodi-send --action="${KODI_ACTION}" > /dev/null \ + 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 --host="${KODI_HOST}" --action="${KODI_ACTION}" > /dev/null \ && exit 0 ## }}} @@ -205,7 +218,13 @@ if [ ! "${NBARGS}" -eq "0" ]; then -d|--debug ) ## debug 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 ## Exit after help informations exit 0