feat: replace the LXQt desktop with SteamOS-style KDE Plasma (#473)

* feat: replace the LXQt desktop with SteamOS-style KDE Plasma

* feat: leaving the KDE desktop logs out through Plasma and returns to gaming mode

* feat: DroidDeck logo wallpaper as the KDE desktop default

* feat: build the KDE wallpaper from the DroidDeck mark artwork

* ci: keep the built desktop package as a short-lived artifact for device testing

* fix: the desktop loading screen no longer promises Steam on the desktop

* docs: the output resize comments name the desktop's KWin

* fix: the desktop package verifies every package's Arch Linux ARM signature and never replaces a published tag

* fix: programs sent to the GPU from the desktop drop its software rendering overrides

* fix: an interrupted desktop install no longer counts as installed

* feat: pin the desktop package to its DroidDeck-Components release instead of the catalog
This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-10-09 10:39:50 -04:00
1 parent 0a96767657
commit eaf26c8a20
94 files changed
+1904 -1182

No files matched your search

-57
View File
@@ -1,57 +0,0 @@
# What the desktop is made of, started once labwc is up. Everything logs into the session log.
# With ~/.droiddeck-desktop-debug present, the panel and the file manager also log what they
# say to the compositor about their windows (shell, layer, output), capped so it stays readable.
run() {
local tag=$1; shift
if [ -f "$HOME/.droiddeck-desktop-debug" ]; then
# Everything it says goes to ~/.cache/droiddeck/<tag>.log; the window-related protocol
# traffic also goes into the session log, capped.
mkdir -p "$HOME/.cache/droiddeck"
WAYLAND_DEBUG=1 "$@" 2>&1 | tee "$HOME/.cache/droiddeck/$tag.log" | awk -v t="[$tag]" '!/^\[[0-9:.]+\] +\{/ || (c<120 && /layer_s|xdg_toplevel|fullscreen|wl_output|xdg_output|configure\(/) {print t, $0; c++; fflush()}' &
else
"$@" 2>&1 | sed "s/^/[$tag] /" &
fi
}
# The output at the app's real size, in case rc.xml's mode did not take.
[ -n "${BL_WIDTH:-}" ] && wlr-randr --output WL-1 --custom-mode "${BL_WIDTH}x${BL_HEIGHT}" 2>&1 | sed 's/^/[wlr-randr] /'
# In debug runs, ground truth on the network from inside the session: name lookup, then a
# fetch over IPv4 and over IPv6, so a browser's "no internet" can be placed.
if [ -f "$HOME/.droiddeck-desktop-debug" ]; then
(
echo "[net] getent: $(getent hosts example.com 2>&1 | head -2 | tr '\n' ' ')"
for f in 4 6; do
echo "[net] curl -$f: $(curl -$f -sS -m 8 -o /dev/null -w '%{http_code} %{remote_ip}' https://example.com 2>&1)"
done
) &
fi
# In debug runs Firefox (started from the panel or the menu, so it inherits this) writes its
# own network log: name lookups, connects, HTTP transactions, the link/offline decisions.
if [ -f "$HOME/.droiddeck-desktop-debug" ]; then
mkdir -p "$HOME/.cache/droiddeck"
export MOZ_LOG="nsHttp:3,nsSocketTransport:3,nsHostResolver:4,NetworkLinkService:5,NetworkConnectivityService:5,nsIOService:5"
export MOZ_LOG_FILE="$HOME/.cache/droiddeck/firefox-net.log"
fi
swaybg -m fill -i /usr/share/backgrounds/steamdeck.png &
# Desktop icons (pcmanfm-qt manages the desktop surface) and the panel with the app menu.
run pcmanfm-qt pcmanfm-qt --desktop --profile lxqt
run lxqt-panel lxqt-panel
/usr/lib/xdg-desktop-portal-wlr >/dev/null 2>&1 &
# The desktop was asked for with Steam in it (the front end's "Steam Desktop UI", Big Picture's
# "Switch to Desktop"): the client's desktop UI, as the menu's Steam entry opens it. A running
# client just gets the request; on a software desktop it goes back to the app as a Steam session.
[ "${BL_DESKTOP_STEAM:-0}" = 1 ] && run steam /usr/local/bin/droiddeck-steam-launch desktop
# Remote runs, for driving the desktop from a debugger: with ~/.droiddeck-remote-run present (only
# the app or root can create it), each script dropped into ~/.cache/droiddeck/run/ is run once,
# inside the session with its environment, its output tagged into the desktop log.
if [ -f "$HOME/.droiddeck-remote-run" ]; then
mkdir -p "$HOME/.cache/droiddeck/run"
(
while sleep 1; do
for f in "$HOME"/.cache/droiddeck/run/*.sh; do
[ -f "$f" ] || continue
mv -f "$f" "$f.running" || continue
( echo "[run] $(basename "$f") started"; bash "$f.running" 2>&1 | sed "s/^/[run] /"; echo "[run] $(basename "$f") exited"; rm -f "$f.running" ) &
done
done
) &
fi
+89 -142
View File
@@ -1,15 +1,24 @@
#!/bin/bash
# The desktop session: labwc nested as a client of the app's compositor, with LXQt's panel and
# file manager started from its autostart, and Xwayland for the X11 programs (the Steam client,
# most emulators). Run by droiddeck-session in place of gamescope for mode "lxqt".
# The desktop session: KDE Plasma, set up as SteamOS's desktop mode - KWin nested as a client of the
# app's compositor, Plasma's shell on it, and Xwayland for the X11 programs (the Steam client, most
# emulators). Run by droiddeck-session in place of gamescope for mode "lxqt" (the mode's name from
# the LXQt desktop this replaced; it is what the app and its preferences use).
# Staged by the app over the desktop package's copy on every launch, so a fix here reaches an
# installed desktop without re-downloading the package.
set -u
export XDG_SESSION_TYPE=wayland XDG_CURRENT_DESKTOP=LXQt XDG_SESSION_DESKTOP=lxqt
export XDG_SESSION_TYPE=wayland XDG_CURRENT_DESKTOP=KDE XDG_SESSION_DESKTOP=KDE DESKTOP_SESSION=plasma
export KDE_FULL_SESSION=true KDE_SESSION_VERSION=6 KDE_APPLICATIONS_AS_SCOPE=0
# Qt tries Wayland and falls back to X11 (Xwayland): an AppImage that bundles only Qt's xcb
# plugin - melonDS - exits at once on a plain "wayland" ("Could not find the Qt platform plugin").
export QT_QPA_PLATFORM="wayland;xcb" GDK_BACKEND=wayland,x11 SDL_VIDEODRIVER=wayland,x11
export QT_QPA_PLATFORMTHEME=lxqt
unset QT_QPA_PLATFORMTHEME
# KDE's programs log through Qt, which writes to the journal when stderr is not a terminal; there is
# no journal here, so their messages go to the desktop log with everything else.
export QT_FORCE_STDERR_LOGGING=1
# SteamOS's /etc/profile.d/kde.sh.
export MOZ_ENABLE_WAYLAND=1 MOZ_USE_XINPUT2=1
# Konsole's profile starts the login shell, which it finds here.
export SHELL=/bin/bash
# Firefox's child processes sandbox themselves with seccomp and namespaces, neither of which
# behaves under proot: the content process ends up unable to read the font files its parent can,
# reports "no fonts" and dies - the tab crash, with the chrome around it still drawing text.
@@ -21,77 +30,34 @@ export MOZ_DISABLE_SOCKET_PROCESS_SANDBOX=1 MOZ_DISABLE_UTILITY_SANDBOX=1
# ("Shared memory PlatformHandle is not safe to map") and dies on signal 11 - every page. Firefox's
# own switch skips the seals. (#280; the line went missing in the fontconfig move of #252.)
export MOZ_SHM_NO_SEALS=1
# pixman composites in software and gives programs shm buffers only, so a Vulkan program on it
# fails at its swapchain. vulkan (or gles2) composite on the GPU and give programs DMA-BUFs, but
# stock wlroots allocates through gbm on a real DRM node and the KGSL stand-in is not one ("unable
# to create allocator"): they need the app's patched wlroots (tools/wlroots), whose Vulkan
# allocator exports the buffers instead. BL_WLR_RENDERER picks; see the fallback at the end.
export WLR_RENDERER=${BL_WLR_RENDERER:-vulkan}
WLROOTS_DIR=/usr/local/lib/droiddeck-wlroots
BASE_LD_LIBRARY_PATH=${LD_LIBRARY_PATH:-}
use_renderer() {
export WLR_RENDERER=$1
if [ "$1" != pixman ] && [ -f "$WLROOTS_DIR/libwlroots-0.20.so" ]; then
export LD_LIBRARY_PATH=$WLROOTS_DIR${BASE_LD_LIBRARY_PATH:+:$BASE_LD_LIBRARY_PATH}
elif [ -n "$BASE_LD_LIBRARY_PATH" ]; then
export LD_LIBRARY_PATH=$BASE_LD_LIBRARY_PATH
else
unset LD_LIBRARY_PATH
fi
}
use_renderer "$WLR_RENDERER"
# A GPU renderer that failed to start here is not tried again on every desktop start (each try costs
# up to 20 s): the failure is kept with what it failed on - the renderer, the patched wlroots and the
# Linux driver - so an app update or a different driver retries, and so does picking a renderer
# again in the app's settings (which deletes the file).
FAILED_FILE=$HOME/.droiddeck-renderer-failed
renderer_key() {
echo "$WLR_RENDERER $(md5sum "$WLROOTS_DIR/libwlroots-0.20.so" 2>/dev/null | cut -d' ' -f1) ${BL_VK_DRIVER:-runtime}"
}
if [ "$WLR_RENDERER" != pixman ] && [ "$(cat "$FAILED_FILE" 2>/dev/null)" = "$(renderer_key)" ]; then
echo "== droiddeck-desktop: $WLR_RENDERER failed to start here before; using pixman (choose a renderer in the settings to retry)"
use_renderer pixman
fi
# The desktop's own log, beside the session's, so labwc and the programs on it can be read apart
# KWin composites in software (QPainter): its GPU path allocates through gbm on a DRM render node,
# and the KGSL stand-in is not one. Its windows get shm buffers only, so GL programs on it draw with
# Mesa's software rasterizer, Plasma's own Qt Quick draws with Qt's software renderer (plasmashell
# crashes on llvmpipe here), and a Vulkan program cannot draw at all: games and emulators from the
# menu run through droiddeck-gpu (their own gamescope on the app's compositor), and Steam goes back
# to the app as a Steam session - SteamOS's "Return to Gaming Mode". The session's own GL choice
# (zink on Turnip, for the Steam client) is put back by droiddeck-gpu.
export KWIN_COMPOSE=Q QT_QUICK_BACKEND=software LIBGL_ALWAYS_SOFTWARE=1 GALLIUM_DRIVER=llvmpipe
export DROIDDECK_GLTHREAD=${mesa_glthread:-}
unset MESA_LOADER_DRIVER_OVERRIDE LIBGL_KOPPER_DRI2 mesa_glthread
# The desktop's own log, beside the session's, so KWin and the programs on it can be read apart
# from the session that started them. The session log keeps the milestones either way.
if [ -n "${BL_DEBUG_DIR:-}" ]; then
mkdir -p "$BL_DEBUG_DIR" 2>/dev/null || true
exec >>"$BL_DEBUG_DIR/desktop.log" 2>&1
echo "== droiddeck-desktop $(date -u '+%Y-%m-%d %H:%M:%S UTC') renderer=$WLR_RENDERER"
echo "== droiddeck-desktop $(date -u '+%Y-%m-%d %H:%M:%S UTC') ${BL_WIDTH:-1280}x${BL_HEIGHT:-720}"
fi
export WLR_BACKENDS=wayland
# The cursor goes to the app's compositor as a wl_pointer cursor surface ("hardware" cursor on the
# wayland backend), which the app draws as its pointer. Drawn into the desktop's own frames instead
# (WLR_NO_HARDWARE_CURSORS=1), it cost every frame a full-screen composite: a software cursor
# rules out direct scan-out, so a full-screen game was never handed to the app as it is.
mkdir -p "$HOME/.config/labwc" "$HOME/.config/lxqt"
# Our defaults for labwc and the panel, refreshed every session. What a user changes in the
# panel's own settings lands in panel.conf and is kept; only rc.xml and autostart are ours.
# The nested output takes the app's surface size; left alone, wlroots' Wayland backend opens
# a 1280x720 window and the whole desktop is upscaled from that.
sed "s/@MODE@/${BL_WIDTH:-1280}x${BL_HEIGHT:-720}/" /etc/xdg/labwc/rc.xml > "$HOME/.config/labwc/rc.xml"
cp -f /etc/xdg/labwc/autostart "$HOME/.config/labwc/autostart"
# panel.conf is the user's once the panel has written it, except the one our first package
# shipped: it never named its panel ([General] panels=), so lxqt-panel built an empty default
# one. That file is replaced; one that names its panels is kept.
if ! grep -q '^panels=' "$HOME/.config/lxqt/panel.conf" 2>/dev/null; then
cp -f /etc/xdg/lxqt/panel.conf "$HOME/.config/lxqt/panel.conf"
fi
[ -f "$HOME/.config/lxqt/lxqt.conf" ] || cp /etc/xdg/lxqt/lxqt.conf "$HOME/.config/lxqt/lxqt.conf"
# pcmanfm-qt paints the desktop; left unconfigured it paints it black, over swaybg's wallpaper.
if [ ! -f "$HOME/.config/pcmanfm-qt/lxqt/settings.conf" ]; then
mkdir -p "$HOME/.config/pcmanfm-qt/lxqt"
printf '[Desktop]\nWallpaper=/usr/share/backgrounds/steamdeck.png\nWallpaperMode=zoom\nBgColor=#1b1030\nShowHidden=false\n' \
> "$HOME/.config/pcmanfm-qt/lxqt/settings.conf"
fi
# The runtime directory outlives a session. lxqt-panel and pcmanfm-qt are single-instance
# programs that leave a lock and a socket there; finding last session's, they decide they are
# already running and exit without a word - a desktop with a wallpaper and nothing on it.
# Only the app's own compositor socket (wayland-0) is kept.
# The runtime directory outlives a session. KDE's daemons are single-instance programs that leave a
# lock and a socket there; finding last session's, they decide they are already running and exit
# without a word. Only the app's own compositor socket (wayland-0) is kept.
find "$XDG_RUNTIME_DIR" -mindepth 1 -maxdepth 1 ! -name 'wayland-0*' ! -name 'keymap.xkb' -exec rm -rf {} + 2>/dev/null
chmod 700 "$XDG_RUNTIME_DIR" 2>/dev/null
# KWin will not start Xwayland when its socket directory is not sticky, as a shared /tmp would be,
# and Plasma's session manager cannot listen at all without the ICE directory, which only root may
# create for it.
mkdir -p /tmp/.X11-unix /tmp/.ICE-unix && chmod 1777 /tmp/.X11-unix /tmp/.ICE-unix 2>/dev/null
# Fontconfig defaults and Android language fallbacks are set up by droiddeck-session before this
# script or any desktop program starts. The generated defaults live in conf.d, leaving local.conf
# available for the user's own final overrides.
# script or any desktop program starts.
# The menu's "Steam" / "Steam Big Picture" entries and one entry per installed game: all of them
# hand off to the app (droiddeck-steam-launch), since the client cannot draw on this desktop.
export BL_DESKTOP=1
@@ -103,81 +69,62 @@ python3 /usr/local/bin/droiddeck-desktop-games 2>&1 | sed 's/^/[games] /'
# given the controller for its next start without waiting for the next desktop.
python3 /usr/local/bin/droiddeck-pad-defaults 2>&1 | sed 's/^/[pads] /'
( while sleep 30; do python3 /usr/local/bin/droiddeck-pad-defaults 2>&1 | sed 's/^/[pads] /'; done ) &
# Games and emulators from the menu run through droiddeck-gpu (their own gamescope on the app's
# compositor) while the desktop is on pixman, where they could not draw with the GPU.
# BL_DESKTOP_GPU=on/off overrides; each entry keeps "Run in a desktop window" either way.
gpu_entries() { python3 /usr/local/bin/droiddeck-desktop-gpu 2>&1 | sed 's/^/[gpu] /'; }
gpu_entries
# ~/.droiddeck-desktop-debug: labwc's own debug log (views and layer surfaces mapping) too. The GPU
# renderers are experimental and always log in full, so a desktop that does not come up says why.
DEBUG=; { [ -f "$HOME/.droiddeck-desktop-debug" ] || [ "$WLR_RENDERER" != pixman ]; } && DEBUG=-d
run_labwc() {
echo "== droiddeck-desktop: labwc ($WLR_RENDERER${LD_LIBRARY_PATH:+, wlroots from $WLROOTS_DIR}) on $WAYLAND_DISPLAY"
# A session bus: the panel's menus, the file manager and the portal all expect one.
if command -v dbus-run-session >/dev/null 2>&1; then
dbus-run-session -- labwc $DEBUG -C "$HOME/.config/labwc"
else
labwc $DEBUG -C "$HOME/.config/labwc"
fi
}
pids_named() {
local p
for p in /proc/[0-9]*; do
[ "$(cat "$p/comm" 2>/dev/null)" = "$1" ] && echo "${p#/proc/}"
done
}
# labwc answers on its own socket (the one beside the app's wayland-0) once its event loop runs; a
# labwc stuck on the GPU never does.
labwc_answers() {
local sock
for sock in "$XDG_RUNTIME_DIR"/wayland-*; do
case $sock in *.lock|*/wayland-0) continue ;; esac
[ -S "$sock" ] || continue
WAYLAND_DISPLAY=${sock##*/} timeout 3 wayland-info >/dev/null 2>&1 && return 0
done
return 1
}
if [ "$WLR_RENDERER" = pixman ]; then
run_labwc
exit $?
# Games and emulators from the menu run through droiddeck-gpu; BL_DESKTOP_GPU=on/off overrides,
# and each entry keeps "Run in a desktop window" either way.
python3 /usr/local/bin/droiddeck-desktop-gpu 2>&1 | sed 's/^/[gpu] /'
# SteamOS's desktop icons: Return to Gaming Mode and Steam, put there once - what the user moves
# or deletes stays that way.
desktop_dir=$(xdg-user-dir DESKTOP 2>/dev/null); [ -n "$desktop_dir" ] && [ "$desktop_dir" != "$HOME" ] || desktop_dir=$HOME/Desktop
if [ ! -e "$HOME/.config/droiddeck-desktop-icons" ]; then
mkdir -p "$desktop_dir" "$HOME/.config"
cp -f /usr/share/applications/droiddeck-return-gaming.desktop "$desktop_dir/Return.desktop" 2>/dev/null
cp -f /usr/share/applications/steamdeck-steam.desktop "$desktop_dir/steam.desktop" 2>/dev/null
chmod +x "$desktop_dir"/*.desktop 2>/dev/null
touch "$HOME/.config/droiddeck-desktop-icons"
fi
# A GPU renderer this device cannot start either ends the desktop at once or leaves it hanging on
# the loading screen. Either way the desktop comes up on pixman instead, and the log says why.
started=$(date +%s)
run_labwc &
labwc_job=$!
answered=
while kill -0 "$labwc_job" 2>/dev/null; do
if labwc_answers; then answered=1; break; fi
[ $(( $(date +%s) - started )) -ge 20 ] && break
sleep 1
done
if [ -n "$answered" ]; then
echo "== droiddeck-desktop: labwc on $WLR_RENDERER is up after $(( $(date +%s) - started )) s"
wait "$labwc_job"
exit $?
# A Return icon still there is kept current with the package's entry (what it runs has changed).
[ -f "$desktop_dir/Return.desktop" ] && cp -f /usr/share/applications/droiddeck-return-gaming.desktop "$desktop_dir/Return.desktop" 2>/dev/null
# Plasma's caches of the menu, the icons and the MIME types, which a package install never ran.
update-mime-database /usr/share/mime >/dev/null 2>&1 &
[ -f /usr/share/icons/hicolor/icon-theme.cache ] || gtk-update-icon-cache -q -t /usr/share/icons/hicolor 2>/dev/null &
[ -f /usr/share/glib-2.0/schemas/gschemas.compiled ] || glib-compile-schemas /usr/share/glib-2.0/schemas 2>/dev/null
# In debug runs Firefox (started from the panel or the menu, so it inherits this) writes its
# own network log: name lookups, connects, HTTP transactions, the link/offline decisions.
if [ -f "$HOME/.droiddeck-desktop-debug" ]; then
mkdir -p "$HOME/.cache/droiddeck"
export MOZ_LOG="nsHttp:3,nsSocketTransport:3,nsHostResolver:4,NetworkLinkService:5,NetworkConnectivityService:5,nsIOService:5"
export MOZ_LOG_FILE="$HOME/.cache/droiddeck/firefox-net.log"
export QT_LOGGING_RULES="kwin_*.debug=true"
fi
if kill -0 "$labwc_job" 2>/dev/null; then
echo "== droiddeck-desktop: labwc on $WLR_RENDERER did not answer in 20 s; stopping it"
kill -TERM $(pids_named labwc) 2>/dev/null
sleep 2
kill -KILL $(pids_named labwc) 2>/dev/null
for prog in lxqt-panel pcmanfm-qt swaybg Xwayland; do kill -KILL $(pids_named "$prog") 2>/dev/null; done
wait "$labwc_job" 2>/dev/null
rc=124
else
wait "$labwc_job"
rc=$?
# Remote runs, for driving the desktop from a debugger: with ~/.droiddeck-remote-run present (only
# the app or root can create it), each script dropped into ~/.cache/droiddeck/run/ is run once,
# inside the session with its environment, its output tagged into the desktop log.
if [ -f "$HOME/.droiddeck-remote-run" ]; then
mkdir -p "$HOME/.cache/droiddeck/run"
(
while sleep 1; do
for f in "$HOME"/.cache/droiddeck/run/*.sh; do
[ -f "$f" ] || continue
mv -f "$f" "$f.running" || continue
( echo "[run] $(basename "$f") started"; WAYLAND_DISPLAY=wayland-1 DISPLAY=:1 bash "$f.running" 2>&1 | sed "s/^/[run] /"; echo "[run] $(basename "$f") exited"; rm -f "$f.running" ) &
done
done
) &
fi
if [ "$rc" -ne 0 ] && [ $(( $(date +%s) - started )) -lt 40 ]; then
echo "== droiddeck-desktop: labwc on $WLR_RENDERER failed at start (exit $rc); starting on pixman instead"
renderer_key > "$FAILED_FILE"
use_renderer pixman
DEBUG=; [ -f "$HOME/.droiddeck-desktop-debug" ] && DEBUG=-d
find "$XDG_RUNTIME_DIR" -mindepth 1 -maxdepth 1 ! -name 'wayland-0*' ! -name 'keymap.xkb' -exec rm -rf {} + 2>/dev/null
gpu_entries
run_labwc
rc=$?
# Plasma as its own login starts it: startplasma-wayland sets up the session's environment and runs
# plasma_session, which starts KWin (through kwin_wayland_wrapper, ours first on PATH) as a client of
# the app's compositor with its own Xwayland, then Plasma's daemons, shell and autostart entries on
# it. The session bus is ours: Plasma, the file manager and the portal all expect one.
echo "== droiddeck-desktop: Plasma on $WAYLAND_DISPLAY"
dbus-run-session -- startplasma-wayland
rc=$?
echo "== droiddeck-desktop: Plasma ended ($rc)"
# Plasma logged out - Log Out, or Return to Gaming Mode, which logs out the same way, so open windows
# are asked to close (and to save) first. As on SteamOS, leaving the desktop goes to Gaming Mode: the
# app is asked for a Steam session, and it ends this one to start it. A desktop the app stops never
# gets here; a Plasma that failed does not count as a logout.
if [ "$rc" -eq 0 ]; then
/usr/local/bin/droiddeck-steam-launch bigpicture
sleep 30
fi
exit $rc
+2 -7
View File
@@ -6,7 +6,7 @@
# a desktop window". Run at every desktop start; copies whose original is gone, or all of them when
# the switch is off, are removed.
#
# BL_DESKTOP_GPU=auto (default: on while the desktop is composited by pixman) | on | off
# BL_DESKTOP_GPU=on (default: the desktop composites in software) | off
import os
import re
@@ -23,12 +23,7 @@ SKIP = re.compile(r"^(steam|droiddeck-game-|droiddeck-steam|steamdeck-)", re.I)
def enabled():
mode = os.environ.get("BL_DESKTOP_GPU", "auto").strip().lower()
if mode in ("on", "1", "yes", "true"):
return True
if mode in ("off", "0", "no", "false"):
return False
return os.environ.get("WLR_RENDERER", "pixman") == "pixman"
return os.environ.get("BL_DESKTOP_GPU", "on").strip().lower() not in ("off", "0", "no", "false")
def main_group(text):
+8 -3
View File
@@ -1,7 +1,7 @@
#!/bin/bash
# Runs a program from the desktop on the GPU: in a gamescope of its own that draws straight into
# the app's compositor (wayland-0), not inside labwc. The desktop is composited by pixman, and
# pixman gives its windows no DMA-BUFs - a Vulkan program there fails at its swapchain
# the app's compositor (wayland-0), not inside the desktop's KWin. KWin composites in software, and
# gives its windows no DMA-BUFs - a Vulkan program there fails at its swapchain
# (VK_ERROR_SURFACE_LOST, RPCS3's error). Here it gets the same path as a program started from the
# app's rail: full screen over the desktop until it exits, then the desktop is back.
# droiddeck-gpu <program> [args...]
@@ -20,10 +20,15 @@ elif [ "${BL_REFRESH:-0}" -gt 0 ]; then
fi
[ "${BL_HDR:-0}" = 1 ] && args+=(--hdr-enabled)
echo "== droiddeck-gpu $(date -u +%H:%M:%S): $* (gamescope ${width}x${height} on wayland-0)"
# gamescope is a client of the app's compositor, beside labwc; the program inside it reaches it
# gamescope is a client of the app's compositor, beside the desktop's KWin; the program inside it reaches it
# through gamescope's own Xwayland, as in a Steam session.
export WAYLAND_DISPLAY=wayland-0
export GDK_BACKEND=x11 QT_QPA_PLATFORM=xcb SDL_VIDEODRIVER=x11
# GL on the GPU again (zink on Turnip, as the session sets it): the desktop itself draws GL in software.
# Qt Quick back on its GPU renderer and KWin's software compositing not passed on, too.
unset LIBGL_ALWAYS_SOFTWARE QT_QUICK_BACKEND KWIN_COMPOSE
export MESA_LOADER_DRIVER_OVERRIDE=zink GALLIUM_DRIVER=zink LIBGL_KOPPER_DRI2=true
[ -n "${DROIDDECK_GLTHREAD:-}" ] && export mesa_glthread=$DROIDDECK_GLTHREAD
# AppImages cannot mount under proot; the menu entries already say so, a hand-typed one may not.
export APPIMAGE_EXTRACT_AND_RUN=1
gamescope "${args[@]}" -- "$@"
+11
View File
@@ -0,0 +1,11 @@
#!/bin/bash
# KWin for the desktop. Plasma's session (plasma_session) starts KWin through kwin_wayland_wrapper as
# found on PATH; this one, first on it, has KWin draw into the app's compositor (wayland-0) and serve
# its own clients on wayland-1 - by default it takes wayland-0 and finds the app's lock on it - with
# its nested output at the app's surface size (left alone, a 1024x768 window the desktop is scaled
# from), and without the lock screen, which the app's own suspend stands in for. Anything else (a KWin
# started outside DroidDeck's desktop) gets the real wrapper as it is.
if [ "${BL_DESKTOP:-}" = 1 ]; then
set -- --wayland-display wayland-0 --socket wayland-1 --width "${BL_WIDTH:-1280}" --height "${BL_HEIGHT:-720}" --no-lockscreen "$@"
fi
exec /usr/bin/kwin_wayland_wrapper "$@"
-55
View File
@@ -1,55 +0,0 @@
[General]
__userfile__=true
iconTheme=Papirus-Dark
panels=panel1
panels=panel1
[panel1]
alignment=-1
animation-duration=0
background-color=@Variant(\0\0\0\x43\x1\xff\xff\x1c\x1c\x1c\x1c\x1c\x1c\0\0)
background-image=
font-color=@Variant(\0\0\0\x43\x1\xff\xff\xff\xff\xff\xff\xff\xff\0\0)
hidable=false
iconSize=28
lineCount=1
lockPanel=false
opacity=90
panelSize=40
plugins=mainmenu, quicklaunch, taskbar, spacer, tray, worldclock, showdesktop
position=Bottom
reserve-space=true
show-delay=0
width=100
width-percent=true
[mainmenu]
type=mainmenu
icon=/usr/share/icons/Papirus-Dark/32x32/apps/steam.svg
showText=false
[quicklaunch]
type=quicklaunch
apps\1\desktop=/usr/share/applications/steamdeck-steam.desktop
apps\2\desktop=/usr/share/applications/steamdeck-bigpicture.desktop
apps\3\desktop=/usr/share/applications/pcmanfm-qt.desktop
apps\4\desktop=/usr/share/applications/qterminal.desktop
apps\size=4
[taskbar]
type=taskbar
buttonStyle=IconAndText
groupingEnabled=false
showGroupOnHover=true
[spacer]
type=spacer
[tray]
type=tray
[worldclock]
type=worldclock
[showdesktop]
type=showdesktop
-31
View File
@@ -1,31 +0,0 @@
<?xml version="1.0"?>
<!-- labwc for a handheld: a plain theme, large enough to hit with a finger, and the keybinds a
desktop expects. Refreshed from here every session. -->
<labwc_config>
<core><gap>0</gap><reuseOutputMode>yes</reuseOutputMode></core>
<theme>
<name>Clearlooks</name>
<cornerRadius>6</cornerRadius>
<font place="ActiveWindow"><name>DejaVu Sans</name><size>11</size></font>
</theme>
<output name="WL-1" mode="@MODE@"/>
<placement><policy>center</policy></placement>
<windowSwitcher><osd show="yes" preview="yes"/></windowSwitcher>
<keyboard>
<keybind key="A-Tab"><action name="NextWindow"/></keybind>
<keybind key="A-F4"><action name="Close"/></keybind>
<keybind key="W-Return"><action name="Execute"><command>qterminal</command></action></keybind>
<keybind key="W-e"><action name="Execute"><command>pcmanfm-qt</command></action></keybind>
<keybind key="W-d"><action name="ToggleMaximize"/></keybind>
</keyboard>
<mouse><doubleClickTime>500</doubleClickTime></mouse>
<!-- Programs opened on the desktop at a size that suits it. melonDS remembers a 1x window for the
front end's full-screen toggle (droiddeck-pad-defaults), too small for a desktop: here it
opens at 800x600, centred (AutoPlace alone kept the top-left corner). Only the desktop reads this file, so the front end is unaffected. -->
<windowRules>
<windowRule title="melonDS*">
<action name="ResizeTo" width="800" height="600"/>
<action name="AutoPlace" policy="center"/>
</windowRule>
</windowRules>
</labwc_config>
@@ -4,7 +4,7 @@
# droiddeck-session desktop the file manager
# droiddeck-session run <path> a Linux program (AppImage, script or ELF)
# droiddeck-session steam [steam-url] the native Steam client
# droiddeck-session lxqt the LXQt/labwc desktop (DroidDeck's desktop package)
# droiddeck-session lxqt the KDE Plasma desktop (DroidDeck's desktop package)
# BL_WIDTH / BL_HEIGHT size the output, BL_FPS limits it, BL_LOG collects everything said here.
set -u
export HOME=${HOME:-/root}
@@ -173,7 +173,7 @@ if [ -z "${BL_INSIDE:-}" ]; then
wayland-info >/dev/null 2>&1 && break
sleep 0.1
done
# The desktop (DroidDeck's hosted package) is its own nested compositor, labwc, drawing straight
# The desktop (DroidDeck's hosted package) is its own nested compositor, KWin, drawing straight
# into the app's: no gamescope in between.
if [ "$mode" = lxqt ]; then
step "starting the desktop"
@@ -4,15 +4,10 @@
# droiddeck-steam-launch desktop [appid|steam-url] Steam's desktop UI, optionally a game
# droiddeck-steam-launch bigpicture [appid|steam-url] Big Picture
#
# On a desktop that draws with the GPU (labwc on vulkan or gles2 - the default since the GPU
# desktop) the client runs right there: a window on the desktop, through the desktop's Xwayland,
# with the same set-up a Steam session gives it (droiddeck-session steam, minus gamescope), and
# its games open in windows of their own. A client already running there gets the request instead
# of a second one being started.
#
# On a software desktop (pixman: the GPU renderers failed on this device) there is no dma-buf, so a
# game - or the client's own Vulkan window - would die at its first frame. There the request goes
# to the app, which ends the desktop and starts a Steam session under gamescope in its place.
# The desktop (KDE Plasma) composites in software and has no dma-buf, so the client's own Vulkan
# window - and any game it starts - would die at its first frame there. The request goes to the app
# instead, which ends the desktop and starts a Steam session under gamescope in its place, as
# SteamOS's desktop hands Steam back to Gaming Mode.
set -u
ui=${1:-desktop}
target=${2:-}
@@ -25,29 +20,7 @@ case $target in
*) url=steam://rungameid/$target ;;
esac
steam_root=${XDG_DATA_HOME:-${HOME:-/root}/.local/share}/Steam
client=$steam_root/steamrtarm64/steam
if [ "${BL_DESKTOP:-}" = 1 ] && [ -n "${WLR_RENDERER:-}" ] && [ "$WLR_RENDERER" != pixman ]; then
log=${BL_DEBUG_DIR:-$HOME/.cache/droiddeck}/steam-desktop.log
mkdir -p "$(dirname "$log")" 2>/dev/null
if pgrep -f 'steamrtarm64/steam( |$)' >/dev/null 2>&1 && [ -x "$client" ]; then
# One client at a time: the running one takes the request (a second start hands its command
# line over and exits). No game asked for = switch it to the UI that was clicked.
[ -n "$url" ] || { [ "$ui" = bigpicture ] && url=steam://open/bigpicture || url=steam://open/main; }
echo "droiddeck-steam-launch: the client is running on the desktop; handing it $url" | tee -a "$log"
exec "$client" "$url"
fi
echo "droiddeck-steam-launch: starting the Steam client on the desktop ($ui${url:+, $url}); log: $log"
# BL_INSIDE: the session script's Steam start-up without gamescope in front of it. The desktop UI
# unless Big Picture was asked for; never Deck mode (its Quick Access Menu needs gamescope).
export BL_INSIDE=1 BL_STEAMDECK=0
if [ "$ui" = desktop ]; then export BL_STEAM_UI=desktop; else unset BL_STEAM_UI; fi
setsid /usr/local/bin/droiddeck-session steam ${url:+"$url"} >>"$log" 2>&1 < /dev/null &
exit 0
fi
# The software desktop, or outside the desktop: ask the app for a Steam session.
# Ask the app for a Steam session.
dir=${BL_LAUNCH_DIR:-}
if [ -z "$dir" ] || [ ! -d "$dir" ]; then
echo "droiddeck-steam-launch: not inside a DroidDeck session (BL_LAUNCH_DIR unset)" >&2
+10 -6
View File
@@ -768,17 +768,17 @@ ONE_PATH(rmdir, REMOVED, IN_DELETE, next_rmdir(path))
ONE_PATH(unlink, REMOVED, IN_DELETE, next_unlink(path))
ONE_PATH(remove, REMOVED, IN_DELETE, next_remove(path))
#define TWO_PATHS(name, gone, event) \
#define TWO_PATHS(name, gone, event, call) \
int name(const char *from, const char *to) { \
NEXT(name); \
struct side a, b; \
int track_a = gone && watching(from) && split(from, &a), track_b = watching(to) && split(to, &b); \
if (!track_a && !track_b) return next_##name(from, to); \
if (!track_a && !track_b) return call(from, to); \
pthread_mutex_lock(&oplock); \
begin(); \
if (track_a) before(&a); \
if (track_b) before(&b); \
int r = next_##name(from, to); \
int r = call(from, to); \
int saved = errno; \
struct expect x[2]; \
int nx = 0; \
@@ -795,9 +795,13 @@ ONE_PATH(remove, REMOVED, IN_DELETE, next_remove(path))
return r; \
}
TWO_PATHS(rename, 1, IN_MOVED_TO)
TWO_PATHS(link, 0, IN_CREATE)
TWO_PATHS(symlink, 0, IN_CREATE)
/* A refused hard link to a lock file is taken as a symlink (links.c). */
int bl_link_lock(const char *oldpath, const char *newpath, int result) __attribute__((visibility("hidden")));
static int link_or_lock(const char *from, const char *to) { return bl_link_lock(from, to, next_link(from, to)); }
TWO_PATHS(rename, 1, IN_MOVED_TO, next_rename)
TWO_PATHS(link, 0, IN_CREATE, link_or_lock)
TWO_PATHS(symlink, 0, IN_CREATE, next_symlink)
#else
+56
View File
@@ -0,0 +1,56 @@
/*
* Lock files taken by hard link, which Android denies apps.
*
* libICE and libXau lock an authority file the classic way: create "<file>-c", then link() it to
* "<file>-l" - the link either appears or fails because the other holder's is there. Android's
* SELinux policy refuses hard links in an app's data, so the link fails for everyone, the lock is
* never taken, and Plasma's session manager gives up at "Could not lock ICEAuthority file". With
* no session manager there is no Plasma desktop.
*
* Only that convention is answered here: when the real link is refused and the new name ends in
* "-l", a symlink stands in. Creating a symlink fails on an existing name just as a link does, so
* the lock excludes as before, and the holder removes both names when it is done. Every other
* link keeps the real answer: a program that links a file into place and then deletes the
* original would be left with a dangling symlink.
*/
#define _GNU_SOURCE
#include <dlfcn.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
static int refused(int error) { return error == EPERM || error == EACCES; }
static int lock_name(const char *path) {
size_t n = path ? strlen(path) : 0;
return n > 2 && strcmp(path + n - 2, "-l") == 0;
}
/* The answer to link(oldpath, newpath), given the real call's: a refused lock link becomes a symlink. */
__attribute__((visibility("hidden"))) int bl_link_lock(const char *oldpath, const char *newpath, int result) {
/* libc's own symlink: dircache.c's wrapper may be holding its lock around this call. */
static int (*real_symlink)(const char *, const char *);
if (result == 0 || !refused(errno) || !lock_name(newpath)) return result;
if (real_symlink == NULL) real_symlink = dlsym(RTLD_NEXT, "symlink");
return real_symlink(oldpath, newpath);
}
/* 64-bit builds wrap link() in dircache.c, which hands its result to bl_link_lock. */
#if __SIZEOF_POINTER__ != 8
int link(const char *oldpath, const char *newpath) {
static int (*real_link)(const char *, const char *);
if (real_link == NULL) real_link = dlsym(RTLD_NEXT, "link");
return bl_link_lock(oldpath, newpath, real_link(oldpath, newpath));
}
#endif
int linkat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath, int flags) {
static int (*real_linkat)(int, const char *, int, const char *, int);
if (real_linkat == NULL) real_linkat = dlsym(RTLD_NEXT, "linkat");
int result = real_linkat(olddirfd, oldpath, newdirfd, newpath, flags);
/* A relative old name would resolve against the new name's directory as a symlink's target. */
if (result != 0 && refused(errno) && lock_name(newpath) && oldpath[0] == '/' && flags == 0)
return symlinkat(oldpath, newdirfd, newpath);
return result;
}