Skip to content

Instantly share code, notes, and snippets.

@Pieter81
Forked from greyltc/launch-GRD.sh
Last active December 3, 2023 03:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Pieter81/78a3a087f142d712951f8352bb9ab2ba to your computer and use it in GitHub Desktop.
Save Pieter81/78a3a087f142d712951f8352bb9ab2ba to your computer and use it in GitHub Desktop.
configures then activates gnome-remote-desktop from the command line
#!/usr/bin/env bash
# this will overwrite all the settings it touches
# the name of the user to run these commands as
TARGET_USER=ClausTheInsane
# to start the desktop session remotely
echo -e "[daemon]\nAutomaticLogin=${TARGET_USER}\nAutomaticLoginEnable=true\n" | sudo tee /run/gdm/custom.conf
sudo systemctl restart gdm
# print the session type
busctl get-property org.freedesktop.Accounts /org/freedesktop/Accounts/User$(id -u) org.freedesktop.Accounts.User Session
# the password for that target user (needed to unlock their keyring)
TUP="IWillKillBilions@2030"
# password to use for VNC server
VNC_PASS="IWillKillBilions@2030"
# TODO: unlock the keyring (probably by first killing it and then re-launching it like PAM would)
killall gnome-keyring-daemon
echo -n ${TUP} | gnome-keyring-daemon --daemonize --login
# write vnc password to the keychain
sudo -i -u ${TARGET_USER} VNC_PASS="${VNC_PASS}" DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$(id -u ${TARGET_USER})/bus" bash -c 'echo -n ${VNC_PASS} | secret-tool store --label "GRD VNC pass" xdg:schema org.gnome.RemoteDesktop.VncPassword'
# or if you want you can print the existing password with
# secret-tool lookup xdg:schema org.gnome.RemoteDesktop.VncPassword
# allow screen control
sudo -i -u ${TARGET_USER} DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$(id -u ${TARGET_USER})/bus" bash -c 'gsettings set org.gnome.desktop.remote-desktop.vnc view-only false'
# use password authentication
sudo -i -u ${TARGET_USER} DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$(id -u ${TARGET_USER})/bus" bash -c 'gsettings set org.gnome.desktop.remote-desktop.vnc auth-method password'
# now launch the server
systemctl start --user gnome-remote-desktop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment