dotfiles/local/bin/vncctl

34 lines
469 B
Text
Raw Normal View History

2023-04-13 00:04:20 +02:00
#!/bin/bash
# Variables
declare -a vncctl
systemctl=systemctl
systemd_unit=vncserver
verb="${1:-status}"; shift
display="${1:-1}" ; shift
# Prepending sudo if necessary
case "$verb" in
start|restart|stop)
sudo=sudo
;;
esac
# Command building
[[ -n $sudo ]] && vncctl+=("$sudo")
vncctl+=(
"$systemctl"
"$@"
"$verb"
"${systemd_unit}@:${display}"
)
# Debug
#echo "${vncctl[@]}"
#exit 0
# Command execution
set -xe
"${vncctl[@]}"