add start_vnc

This commit is contained in:
Christian Ulrich 2023-12-28 10:02:44 +01:00
parent 92bcf622a9
commit 47d2132170
No known key found for this signature in database
GPG Key ID: 8241BE099775A097
2 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,9 @@
[Desktop Entry]
Name=Bildschirm für Techniker freigeben
Exec=/usr/local/bin/start_vnc.sh
Type=Application
Terminal=false
StartupWMClass=zenity
StartupNotify=true
Categories=Utility
Icon=/usr/share/icons/Adwaita/48x48/legacy/face-glasses.png

View File

@ -0,0 +1,25 @@
#!/bin/bash
USERNAME=${USER,,}
LOCK_FILE=/tmp/start_vnc_$USERNAME.lock
ICON=application-x-vnc
SSH_HOST=ulrich.earth
SSH_PORT=2222
SSH_USER=karin
(
flock -n 200 || { echo "already running, exiting."; exit 1; }
gsettings set org.gnome.desktop.remote-desktop.vnc auth-method 'password'
gsettings set org.gnome.desktop.remote-desktop.vnc view-only false
gsettings set org.gnome.desktop.remote-desktop.vnc enable true
password=$(echo -e $(od -vAn -N3 -tu4 < /dev/urandom))
info_text="Bildschirmfreigabe aktiv! Passwort: $password"
echo -n "$password" | secret-tool store --label="GNOME Remote Desktop VNC password" "xdg:schema" "org.gnome.RemoteDesktop.VncPassword"
systemctl --user start gnome-remote-desktop.service
ssh -C -N -R 5900:localhost:5900 -p $SSH_PORT $SSH_USER@$SSH_HOST &
ssh_pid="$!"
zenity --title="Bildschirmfreigabe auf $(hostname)" --info --text="$info_text" --width=230 --ok-label="Beenden" --icon-name="$ICON"
kill $ssh_pid
systemctl --user stop gnome-remote-desktop.service
gsettings set org.gnome.desktop.remote-desktop.vnc enable false
) 200>"$LOCK_FILE"