From e77996f02fe6519e0fa0d341d5a19b2ad38b6096 Mon Sep 17 00:00:00 2001 From: RJ Trujillo Date: Mon, 7 Aug 2023 20:27:41 -0600 Subject: [PATCH] feat(deck): Add (hidden) toggleable desktop Wayland session session support (#118) * feat(deck): Implement optional support for switching to GNOME on Wayland This adds a variable, DESKTOP_WAYLAND, to /etc/default/desktop-wayland that gets sourced by steamos-session-select and determines whether or not to use Wayland or X11. By default, this ships as false * feat(deck): Implement optional support for switching to Plasma on Wayland * feat(deck): Add hidden just script to toggle Wayland desktop session Omitted from 'just list' --- .../usr/bin/startplasma-steamos-oneshot | 15 +++++++-- .../kinoite/usr/bin/steamos-session-select | 32 ++++++++++++------- .../deck/shared/etc/default/desktop-wayland | 1 + .../usr/share/ublue-os/just/custom.just | 9 ++++++ ...ome-xorg-oneshot => gnome-session-oneshot} | 4 +-- .../silverblue/usr/bin/steamos-session-select | 30 +++++++++++++---- .../gnome-session-oneshot.desktop | 8 +++++ .../xsessions/gnome-xorg-oneshot.desktop | 4 +-- 8 files changed, 79 insertions(+), 24 deletions(-) create mode 100644 system_files/deck/shared/etc/default/desktop-wayland rename system_files/deck/silverblue/usr/bin/{gnome-xorg-oneshot => gnome-session-oneshot} (93%) create mode 100644 system_files/deck/silverblue/usr/share/wayland-sessions/gnome-session-oneshot.desktop diff --git a/system_files/deck/kinoite/usr/bin/startplasma-steamos-oneshot b/system_files/deck/kinoite/usr/bin/startplasma-steamos-oneshot index dc3ca704..3e0125cf 100755 --- a/system_files/deck/kinoite/usr/bin/startplasma-steamos-oneshot +++ b/system_files/deck/kinoite/usr/bin/startplasma-steamos-oneshot @@ -4,11 +4,22 @@ set -e die() { echo >&2 "!! $*"; exit 1; } +source /etc/default/desktop-wayland + SENTINEL_FILE="steamos-session-select" -SENTINEL_VALUE="x11" +if ${DESKTOP_WAYLAND}; then + SENTINEL_VALUE="wayland" +else + SENTINEL_VALUE="x11" +fi # If we proceed, execute this -CHAINED_SESSION="/usr/bin/startplasma-x11" +if ${DESKTOP_WAYLAND}; then + CHAINED_SESSION="/usr/bin/startplasma-wayland" +else + CHAINED_SESSION="/usr/bin/startplasma-x11" +fi + # If we decide the sentinel is consumed, execute this command instead and fail RESTORE_SESSION=(steamos-session-select) # No arguments restores the session diff --git a/system_files/deck/kinoite/usr/bin/steamos-session-select b/system_files/deck/kinoite/usr/bin/steamos-session-select index 34169f30..15542684 100755 --- a/system_files/deck/kinoite/usr/bin/steamos-session-select +++ b/system_files/deck/kinoite/usr/bin/steamos-session-select @@ -4,7 +4,7 @@ set -e die() { echo >&2 "!! $*"; exit 1; } -# FIXME Purge old files and use this one +source /etc/default/desktop-wayland # File this script will modify, in addition to (potentially) the per-user sentinel file CONF_FILE="/etc/sddm.conf.d/zz-steamos-autologin.conf" @@ -15,18 +15,22 @@ SENTINEL_FILE="steamos-session-select" CHECK_FILE="/etc/sddm.conf.d/steamos.conf" session="${1:-gamescope}" -session_type="x11" +if ${DESKTOP_WAYLAND}; then + session_type="wayland" +else + session_type="x11" +fi session_launcher="" create_sentinel="" if [[ "$2" == "--sentinel-created" ]]; then - SENTINEL_CREATED=1 - if [[ "$3" == "x11" ]]; then - session_type="x11" - elif [[ "$3" == "wayland" ]]; then - session_type="wayland" - fi + SENTINEL_CREATED=1 + if ${DESKTOP_WAYLAND}; then + session_type="wayland" + else + session_type="x11" + fi fi # Update config sentinel @@ -42,7 +46,11 @@ if [[ -z $SENTINEL_CREATED ]]; then if [[ -f "steamos-session-type" ]]; then cp steamos-session-type "$SENTINEL_FILE" else - echo "x11" > "$SENTINEL_FILE" + if ${DESKTOP_WAYLAND}; then + echo "wayland" > "$SENTINEL_FILE" + else + echo "x11" > "$SENTINEL_FILE" + fi fi cat "$SENTINEL_FILE" ) @@ -59,10 +67,10 @@ case "$session" in session_launcher="plasmax11.desktop" ;; plasma) - if [[ "$session_type" == "x11" ]]; then - session_launcher="plasma-steamos-oneshot.desktop" - else + if ${DESKTOP_WAYLAND}; then session_launcher="plasma-steamos-wayland-oneshot.desktop" + else + session_launcher="plasma-steamos-oneshot.desktop" fi create_sentinel=1 ;; diff --git a/system_files/deck/shared/etc/default/desktop-wayland b/system_files/deck/shared/etc/default/desktop-wayland new file mode 100644 index 00000000..9b890ce8 --- /dev/null +++ b/system_files/deck/shared/etc/default/desktop-wayland @@ -0,0 +1 @@ +DESKTOP_WAYLAND=false diff --git a/system_files/deck/shared/usr/share/ublue-os/just/custom.just b/system_files/deck/shared/usr/share/ublue-os/just/custom.just index ebc099bb..91a3fa3d 100644 --- a/system_files/deck/shared/usr/share/ublue-os/just/custom.just +++ b/system_files/deck/shared/usr/share/ublue-os/just/custom.just @@ -259,3 +259,12 @@ unhide-grub: else sudo grub2-mkconfig -o /boot/grub2/grub.cfg fi + +_toggle_wayland: + #!/usr/bin/env bash + source /etc/default/desktop-wayland + if ${DESKTOP_WAYLAND}; then + sudo sed -i 's/true/false/g' /etc/default/desktop-wayland + else + sudo sed -i 's/false/true/g' /etc/default/desktop-wayland + fi diff --git a/system_files/deck/silverblue/usr/bin/gnome-xorg-oneshot b/system_files/deck/silverblue/usr/bin/gnome-session-oneshot similarity index 93% rename from system_files/deck/silverblue/usr/bin/gnome-xorg-oneshot rename to system_files/deck/silverblue/usr/bin/gnome-session-oneshot index e39e0304..4d868005 100755 --- a/system_files/deck/silverblue/usr/bin/gnome-xorg-oneshot +++ b/system_files/deck/silverblue/usr/bin/gnome-session-oneshot @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/bash set -e @@ -25,7 +25,7 @@ function check_sentinel() cd "$HOME" cd "$config_dir" sentinel_value="$(cat "$SENTINEL_FILE")" - if [[ "$sentinel_value" == "x11" ]]; then + if [[ "$sentinel_value" == "x11" || "$sentinel_value" == "wayland" ]]; then echo "/usr/bin/gnome-session" else return 1 diff --git a/system_files/deck/silverblue/usr/bin/steamos-session-select b/system_files/deck/silverblue/usr/bin/steamos-session-select index c1148782..b68a5ebb 100755 --- a/system_files/deck/silverblue/usr/bin/steamos-session-select +++ b/system_files/deck/silverblue/usr/bin/steamos-session-select @@ -1,9 +1,11 @@ -#! /usr/bin/bash +#!/usr/bin/bash set -e die() { echo >&2 "!! $*"; exit 1; } +source /etc/default/desktop-wayland + # File this script will modify, in addition to (potentially) the per-user sentinel file CONF_FILE="/etc/sddm.conf.d/zz-steamos-autologin.conf" @@ -13,14 +15,22 @@ SENTINEL_FILE="steamos-session-select" CHECK_FILE="/etc/sddm.conf.d/steamos.conf" session="${1:-gamescope}" -session_type="x11" +if ${DESKTOP_WAYLAND}; then + session_type="wayland" +else + session_type="x11" +fi session_launcher="gamescope-session" create_sentinel="" if [[ "$2" == "--sentinel-created" ]]; then SENTINEL_CREATED=1 - session_type="x11" + if ${DESKTOP_WAYLAND}; then + session_type="wayland" + else + session_type="x11" + fi fi # Update config sentinel @@ -36,7 +46,11 @@ if [[ -z $SENTINEL_CREATED ]]; then if [[ -f "steamos-session-type" ]]; then cp steamos-session-type "$SENTINEL_FILE" else - echo "x11" > "$SENTINEL_FILE" + if ${DESKTOP_WAYLAND}; then + echo "wayland" > "$SENTINEL_FILE" + else + echo "x11" > "$SENTINEL_FILE" + fi fi cat "$SENTINEL_FILE" ) @@ -52,13 +66,17 @@ fi # We use "plasma" as "desktop" to hook up to SteamOS's scripts case "$session" in plasma-wayland-persistent) - session_launcher="gnome-xorg" + session_launcher="gnome-session" ;; plasma-x11-persistent) session_launcher="gnome-xorg" ;; desktop|plasma) - session_launcher="gnome-xorg-oneshot" + if ${DESKTOP_WAYLAND}; then + session_launcher="gnome-session-oneshot" + else + session_launcher="gnome-xorg-oneshot" + fi create_sentinel=1 ;; gamescope) diff --git a/system_files/deck/silverblue/usr/share/wayland-sessions/gnome-session-oneshot.desktop b/system_files/deck/silverblue/usr/share/wayland-sessions/gnome-session-oneshot.desktop new file mode 100644 index 00000000..b14cf625 --- /dev/null +++ b/system_files/deck/silverblue/usr/share/wayland-sessions/gnome-session-oneshot.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=GNOME on Wayland (single time session) +Comment=This session logs you into GNOME one time +Exec=/usr/bin/gnome-session-oneshot +TryExec=/usr/bin/gnome-session-oneshot +Type=Application +DesktopNames=GNOME +X-GDM-SessionRegisters=true diff --git a/system_files/deck/silverblue/usr/share/xsessions/gnome-xorg-oneshot.desktop b/system_files/deck/silverblue/usr/share/xsessions/gnome-xorg-oneshot.desktop index 4170efce..d7317dd8 100644 --- a/system_files/deck/silverblue/usr/share/xsessions/gnome-xorg-oneshot.desktop +++ b/system_files/deck/silverblue/usr/share/xsessions/gnome-xorg-oneshot.desktop @@ -1,8 +1,8 @@ [Desktop Entry] Name=GNOME on Xorg (single time session) Comment=This session logs you into GNOME one time -Exec=/usr/bin/gnome-xorg-oneshot -TryExec=/usr/bin/gnome-xorg-oneshot +Exec=/usr/bin/gnome-session-oneshot +TryExec=/usr/bin/gnome-session-oneshot Type=Application DesktopNames=GNOME X-GDM-SessionRegisters=true