dotfiles/local/bin/vncctl
Hippolyte Chauvin c1c1d8adbd Scripts
2023-04-13 00:04:20 +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[@]}"