sh: Fix graphical session start for ssh sessions

The autostart function would accidentally start multiple new graphical
sessions in one terminal when connected to the machine over sshd.

This should fix multiple starts while keeping the old functionality and
speed of checking intact.
This commit is contained in:
Marty Oehme 2022-01-28 10:15:47 +01:00
parent 792e0b930a
commit 5ee71ae705
Signed by: Marty
GPG key ID: B7538B8F50A1C800

View file

@ -1,9 +1,22 @@
#!/usr/bin/env sh
# simple check for running graphical session
if [ -n "$DISPLAY" ] || [ -z "$XDG_VTNR" ] || [ "$XDG_VTNR" -ne 1 ]; then
return
fi
# more involved check for running graphical session
# but figures it out for weird sshd sessions as well
if [ "$(loginctl show-session "$(loginctl show-user "$(whoami)" -p Display --value)" -p Type --value)" = 'wayland' ]; then
return
fi
# just in case we are running x11 and this wants
# to automatically start wayland, stop it from doing so
if [ "$(loginctl show-session "$(loginctl show-user "$(whoami)" -p Display --value)" -p Type --value)" = 'x11' ]; then
return
fi
if command -v river >/dev/null 2>&1; then
river
fi