Manage Kodi API port option

This commit is contained in:
Jeremy Gardais 2022-07-04 17:35:22 +02:00
parent d4ee3807ef
commit 3a9cc468fa
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 16 additions and 0 deletions

View File

@ -20,6 +20,7 @@ export DEBUG
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" readonly KODI_HOST_DEFAULT="127.0.0.1"
readonly KODI_PORT_DEFAULT="8080"
## Colors ## Colors
readonly PURPLE='\033[1;35m' readonly PURPLE='\033[1;35m'
@ -62,6 +63,9 @@ OPTIONS:
-h,--host -h,--host
Set the Kodi host to manage. Set the Kodi host to manage.
-p,--port
Set the Kodi API's port to use.
-d,--debug -d,--debug
Enable debug messages. Enable debug messages.
@ -102,6 +106,12 @@ define_vars() { # {{{
readonly KODI_HOST="${KODI_HOST_DEFAULT}" readonly KODI_HOST="${KODI_HOST_DEFAULT}"
fi fi
## }}} ## }}}
## If KODI_PORT wasn't defined (argument) {{{
if [ -z "${KODI_PORT}" ]; then
## Use default value
readonly KODI_PORT="${KODI_PORT_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
@ -224,6 +234,12 @@ if [ ! "${NBARGS}" -eq "0" ]; then
### Define var ### Define var
KODI_HOST="${1}" KODI_HOST="${1}"
;; ;;
-p|--port ) ## Kodi API port
### Move to the next argument
shift
### Define var
KODI_PORT="${1}"
;;
--help ) ## help --help ) ## help
usage usage
## Exit after help informations ## Exit after help informations