Created
December 30, 2022 15:56
-
-
Save KasRoudra/6642c0950f23f6d96bec7a416b69202b to your computer and use it in GitHub Desktop.
Automate vnc setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "Installing tigervnc....." | |
sleep 1 | |
sudo pacman -S tigervnc | |
clear | |
echo "Set your password for VNC..." | |
sleep 2 | |
vncpasswd | |
display=$(xdpyinfo | awk '/dimensions/{print $2}') | |
sessions=$(ls /usr/share/xsessions) | |
desktop_sessions=$(echo "$sessions" | grep -E "plasma|gnome|xfce|lxqt|cinnamon|mate") | |
if [ -z "$desktop_sessions" ]; then | |
session_name=$(echo "$sessions" | head -n1) | |
else | |
session_name=$(echo "$desktop_sessions" | head -n1) | |
fi | |
session=$(echo "$session_name" | sed s/".desktop"/""/g) | |
echo "session=$session | |
geometry=$display | |
localhost=no | |
alwaysshared=yes | |
" > $HOME/.vnc/config | |
sleep 1 | |
echo "VNC session has been set to ${session} with geometry ${display}..." | |
echo ":1=$USER" | sudo tee -a /etc/tigervnc/vncserver.users > /dev/null | |
sleep 1 | |
echo "VNC user has been set to ${USER}..." | |
sed s/"Type=forking"/"Type=forking\nUser=root"/g /lib/systemd/system/[email protected] | sudo tee -a /etc/systemd/system/vncserver@:1.service > /dev/null | |
sleep 1 | |
echo "SystemCTL Service file has been written...." | |
sudo systemctl daemon-reload | |
sleep 1 | |
echo "Reloaded systemctl daemon" | |
sudo systemctl enable --now vncserver@:1 | |
sleep 1 | |
echo "VNC Server has started successfully!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment