dotfiles/bin/vncctl
2023-04-13 00:25:00 +02:00

33 lines
469 B
Bash
Executable file

#!/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[@]}"