diff --git a/network/start_vnc/start_vnc.desktop b/network/start_vnc/start_vnc.desktop new file mode 100644 index 0000000..6fbf278 --- /dev/null +++ b/network/start_vnc/start_vnc.desktop @@ -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 diff --git a/network/start_vnc/start_vnc.sh b/network/start_vnc/start_vnc.sh new file mode 100644 index 0000000..b9f4e49 --- /dev/null +++ b/network/start_vnc/start_vnc.sh @@ -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"