diff --git a/install.sh b/install.sh index 695291a..6801ea9 100755 --- a/install.sh +++ b/install.sh @@ -25,6 +25,9 @@ # SUMMIT_REPO clone and update from this git URL instead (testing) set -eu +# Files and folders it makes under the prefix must be readable by everyone, whatever umask the caller has (with +# 077, sudo made /usr/local/share/summit root-only and the engine's venv went to the wrong place). +umask 022 REPO_API="https://git.molberg.cloud/api/v1/repos/alex/summit" REPO_GIT="${SUMMIT_REPO:-https://git.molberg.cloud/alex/summit.git}" @@ -167,14 +170,23 @@ detect_gpu() { SESSION_TYPE=unknown # wayland, x11 detect_session() { - if [ -n "${XDG_SESSION_TYPE:-}" ]; then - SESSION_TYPE="$XDG_SESSION_TYPE" - elif [ -n "${WAYLAND_DISPLAY:-}" ]; then + SESSION_TYPE="${XDG_SESSION_TYPE:-}" + case "$SESSION_TYPE" in + wayland|x11) return ;; + esac + if [ -n "${WAYLAND_DISPLAY:-}" ]; then SESSION_TYPE=wayland elif [ -n "${DISPLAY:-}" ]; then SESSION_TYPE=x11 else + # From a text console or ssh (XDG_SESSION_TYPE=tty): the type of this user's graphical session, if any. SESSION_TYPE=unknown + if command -v loginctl >/dev/null 2>&1; then + for s in $(loginctl list-sessions --no-legend 2>/dev/null | awk -v u="$(id -un)" '$3 == u {print $1}'); do + t="$(loginctl show-session "$s" -p Type --value 2>/dev/null || true)" + case "$t" in wayland|x11) SESSION_TYPE="$t"; break ;; esac + done + fi fi }