Use X11 greeter for Linux RustDesk access

This commit is contained in:
2026-09-08 10:58:37 -06:00
parent 5f5772f8cd
commit f87495f21c
2 changed files with 85 additions and 1 deletions
+84
View File
@@ -218,6 +218,89 @@ EOF
wait_for_rustdesk_server
}
configure_x11_login_screen() {
local display_manager=''
local configuration_changed=false
local configuration_path=''
local temporary_configuration=''
if [[ -L /etc/systemd/system/display-manager.service ]]; then
display_manager=$(basename "$(readlink -f /etc/systemd/system/display-manager.service)")
fi
case "$display_manager" in
gdm3.service|gdm.service)
if [[ $display_manager == gdm3.service ]]; then
configuration_path='/etc/gdm3/custom.conf'
else
configuration_path='/etc/gdm/custom.conf'
fi
install -d -o root -g root -m 755 "$(dirname "$configuration_path")"
[[ -f $configuration_path ]] || printf '[daemon]\n' >"$configuration_path"
temporary_configuration=$(mktemp)
python3 - "$configuration_path" "$temporary_configuration" <<'PY'
import re
import sys
from pathlib import Path
source = Path(sys.argv[1])
destination = Path(sys.argv[2])
lines = source.read_text(encoding='utf-8').splitlines()
daemon_start = None
daemon_end = len(lines)
for index, line in enumerate(lines):
if re.match(r'^\s*\[daemon\]\s*$', line, re.IGNORECASE):
daemon_start = index
continue
if daemon_start is not None and index > daemon_start and re.match(r'^\s*\[[^]]+\]\s*$', line):
daemon_end = index
break
if daemon_start is None:
if lines and lines[-1]:
lines.append('')
lines.extend(['[daemon]', 'WaylandEnable=false'])
else:
setting = re.compile(r'^\s*[#;]?\s*WaylandEnable\s*=.*$', re.IGNORECASE)
for index in range(daemon_start + 1, daemon_end):
if setting.match(lines[index]):
lines[index] = 'WaylandEnable=false'
break
else:
lines.insert(daemon_end, 'WaylandEnable=false')
destination.write_text('\n'.join(lines) + '\n', encoding='utf-8')
PY
if ! cmp -s "$temporary_configuration" "$configuration_path"; then
install -o root -g root -m 644 "$temporary_configuration" "$configuration_path"
configuration_changed=true
fi
rm -f "$temporary_configuration"
;;
sddm.service)
configuration_path='/etc/sddm.conf.d/91-sgu-rustdesk-x11.conf'
install -d -o root -g root -m 755 "$(dirname "$configuration_path")"
temporary_configuration=$(mktemp)
printf '%s\n' '[General]' 'DisplayServer=x11' >"$temporary_configuration"
if ! cmp -s "$temporary_configuration" "$configuration_path"; then
install -o root -g root -m 644 "$temporary_configuration" "$configuration_path"
configuration_changed=true
fi
rm -f "$temporary_configuration"
;;
lightdm.service)
# LightDM's greeter already runs on X11, which RustDesk supports.
;;
*)
printf 'WARNING: Could not identify a supported display manager; RustDesk login-screen access may require X11 configuration.\n' >&2
;;
esac
if [[ $configuration_changed == true ]]; then
printf 'RustDesk login-screen support was configured for X11; reboot after enrollment to activate it.\n'
fi
}
wait_for_rustdesk_server() {
local attempt
local candidate_id
@@ -326,6 +409,7 @@ resolve_registration_share
initialize_machine_kerberos
install_rustdesk
read_server_configuration
configure_x11_login_screen
configure_rustdesk
set_access_password
register_with_controller