Compare commits

..

No commits in common. "6ad5e289e102fc619725f7152e0f46eb042efa01" and "7c6e663ee366f11f63ec16ac0c2d6663017cb5fa" have entirely different histories.

2 changed files with 27 additions and 74 deletions

View file

@ -1,76 +1,33 @@
#!/bin/sh
# cd to the local VNC directory, exit if it fails
cd "${HOME}/.vnc" || exit 5
#!/bin/bash
# Variables
file_base="./$(hostname):1."
declare -a vncctl
systemctl=systemctl
systemd_unit=vncserver
verb="${1:-status}"; shift
display="${1:-1}" ; shift
error() {
>&2 printf '\033[1;31m%s\033[0m %s\n' "ERROR:" "$1"
shift
exit "$1"
}
help() {
name="$(basename "$0")"
cat << EOF
${name} - Start a VNC server
Usage:
${name} start|status|stop|help
EOF
}
usage() {
>&2 help
error "Invalid usage: ${1}" 1
}
is_running() {
vncserver -list | grep -q '^:1'
}
start() {
if ! is_running; then
vncserver
else
error "The VNC server is already running!" 4
fi
}
status() {
log_f="${file_base}log"
if is_running; then
tail -f "$log_f"
else
echo "The VNC server is not running."
fi
}
stop() {
if is_running; then
vncserver -kill :1
else
error "The VNC server is not running!" 3
fi
}
# Argument parsing
set -e; trap 'set +e; error "$error" "$?"' EXIT
error="You must give an argument"
[ -n "$1" ]; arg="$1"; shift
unset error
set +e; trap - EXIT
# Main case statement
case "$arg" in
start|status|stop|help)
"$arg"
;;
*)
usage "Invalid argument \"$arg\""
# 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[@]}"

View file

@ -1,4 +0,0 @@
#!/bin/sh
artix-pipewire-loader &
exec xfwm4