mirror of
https://github.com/pithings/unkernel.git
synced 2026-12-05 01:19:58 +08:00
guest: dark GTK, libadwaita and Chromium in the Wayland session, SDL windows that map on wland (libdecor preferred from the start), and a pointer on Xwayland's root window
This commit is contained in:
@@ -31,7 +31,9 @@
|
||||
# bin/wland: Wayland apps in the page, through
|
||||
# the relay the Debian image carries),
|
||||
# etc/profile.d/{kw-path.sh,kw-term.sh,kw-gl.sh,kw-wayland.sh},
|
||||
# etc/chromium.d/kw-wayland, the X.Org
|
||||
# etc/chromium.d/kw-wayland,
|
||||
# usr/local/bin/Xwayland (the distro's, with a
|
||||
# pointer on its root window), the X.Org
|
||||
# fbdev/evdev config, usr/share/licenses/unkernel,
|
||||
# usr/lib/kw-base (the base's id), and an empty
|
||||
# /data mount point. Its scripts run the base's
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
# Copyright (C) 2026 Pooya Parsa <pooya@pi0.io>
|
||||
# /etc/chromium.d/kw-wayland (the kw layer): Debian's chromium wrapper
|
||||
# sources this. In a Wayland session (in the page every shell has one:
|
||||
# kw-wayland.sh) Chromium uses Wayland rather than look for an X display;
|
||||
# kw-wayland.sh) Chromium uses Wayland rather than look for an X display,
|
||||
# and is dark like the page's desktop (its own UI, and prefers-color-scheme
|
||||
# for the pages it shows);
|
||||
# and started with neither a Wayland nor an X display (not from a shell,
|
||||
# or a machine booted without kw.wayland=1) where the machine can show
|
||||
# Wayland windows (/dev/kwshm), it gets wland's session: wland starts the
|
||||
@@ -14,7 +16,7 @@ if [ -z "${WAYLAND_DISPLAY:-}" ] && [ -z "${DISPLAY:-}" ] && [ -c /dev/kwshm ] &
|
||||
_kw_env=$(/usr/lib/kw/bin/wland 2>/dev/null) && eval "$_kw_env"
|
||||
unset _kw_env
|
||||
fi
|
||||
[ -z "${WAYLAND_DISPLAY:-}" ] || CHROMIUM_FLAGS="$CHROMIUM_FLAGS --ozone-platform=wayland"
|
||||
[ -z "${WAYLAND_DISPLAY:-}" ] || CHROMIUM_FLAGS="$CHROMIUM_FLAGS --ozone-platform=wayland --force-dark-mode"
|
||||
# Guest GL's render node is there but not Mesa's EGL, which Debian's chromium
|
||||
# does not pull in: its GPU process cannot start and it renders in software.
|
||||
if [ -c /dev/dri/renderD128 ] && ! ls /usr/lib/*-linux-gnu/libEGL.so.1 >/dev/null 2>&1; then
|
||||
|
||||
8
guest/base/rootfs/etc/gtk-3.0/settings.ini
Normal file
8
guest/base/rootfs/etc/gtk-3.0/settings.ini
Normal file
@@ -0,0 +1,8 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# Copyright (C) 2026 Pooya Parsa <pooya@pi0.io>
|
||||
# /etc/gtk-3.0/settings.ini (the kw layer): GTK 3 apps use their dark
|
||||
# variant, as the page's desktop is dark. A user's own
|
||||
# ~/.config/gtk-3.0/settings.ini comes after this and wins.
|
||||
|
||||
[Settings]
|
||||
gtk-application-prefer-dark-theme=1
|
||||
8
guest/base/rootfs/etc/gtk-4.0/settings.ini
Normal file
8
guest/base/rootfs/etc/gtk-4.0/settings.ini
Normal file
@@ -0,0 +1,8 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# Copyright (C) 2026 Pooya Parsa <pooya@pi0.io>
|
||||
# /etc/gtk-4.0/settings.ini (the kw layer): GTK 4 apps use their dark
|
||||
# variant, as the page's desktop is dark. A user's own
|
||||
# ~/.config/gtk-4.0/settings.ini comes after this and wins.
|
||||
|
||||
[Settings]
|
||||
gtk-application-prefer-dark-theme=1
|
||||
@@ -13,7 +13,10 @@
|
||||
# X or ask are told to use Wayland: XDG_SESSION_TYPE (Chromium's and
|
||||
# Electron's automatic choice, Qt, session-aware apps), GTK, Qt, SDL,
|
||||
# Firefox, Electron. Each only where unset; the X fallbacks stay for apps
|
||||
# without a Wayland backend. Debian's chromium wrapper takes its flag from
|
||||
# without a Wayland backend. The page's desktop is dark, so apps are asked
|
||||
# for their dark variant: GTK by /etc/gtk-3.0 and gtk-4.0/settings.ini,
|
||||
# libadwaita (which ignores that setting and would ask a settings portal,
|
||||
# and none runs) by ADW_DEBUG_COLOR_SCHEME, Chromium by its flag. Debian's chromium wrapper takes its flag from
|
||||
# /etc/chromium.d/kw-wayland instead (it clears CHROMIUM_FLAGS).
|
||||
# Shell builtins only: every shell start reads this. [ -O / ] is root
|
||||
# ($UID is bash's only).
|
||||
@@ -42,6 +45,14 @@ if [ -n "${WAYLAND_DISPLAY:-}" ]; then
|
||||
export GDK_BACKEND="${GDK_BACKEND:-wayland,x11}"
|
||||
export QT_QPA_PLATFORM="${QT_QPA_PLATFORM:-wayland;xcb}"
|
||||
export SDL_VIDEODRIVER="${SDL_VIDEODRIVER:-wayland,x11}"
|
||||
# SDL 2.32 hangs before its window's first buffer when the compositor answers
|
||||
# the decoration protocol with "client-side" (wland draws no title bars): it
|
||||
# moves the window to libdecor in the middle of its wait for the first
|
||||
# configure. Preferring libdecor from the start avoids that move; with the
|
||||
# plugin (libdecor-0-plugin-1-cairo) the window gets a title bar, without it
|
||||
# none, and it maps either way.
|
||||
export SDL_VIDEO_WAYLAND_PREFER_LIBDECOR="${SDL_VIDEO_WAYLAND_PREFER_LIBDECOR:-1}"
|
||||
export MOZ_ENABLE_WAYLAND="${MOZ_ENABLE_WAYLAND:-1}"
|
||||
export ELECTRON_OZONE_PLATFORM_HINT="${ELECTRON_OZONE_PLATFORM_HINT:-auto}"
|
||||
export ADW_DEBUG_COLOR_SCHEME="${ADW_DEBUG_COLOR_SCHEME:-prefer-dark}"
|
||||
fi
|
||||
|
||||
@@ -191,7 +191,7 @@ export XDG_RUNTIME_DIR="$dir" WAYLAND_DISPLAY="$disp"
|
||||
# The toolkit hints (XDG_SESSION_TYPE=wayland, GTK, Qt, SDL, Firefox, Electron).
|
||||
[ -r /etc/profile.d/kw-wayland.sh ] && . /etc/profile.d/kw-wayland.sh
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "export XDG_RUNTIME_DIR='$XDG_RUNTIME_DIR' WAYLAND_DISPLAY='$WAYLAND_DISPLAY' XDG_SESSION_TYPE='$XDG_SESSION_TYPE' GDK_BACKEND='$GDK_BACKEND' QT_QPA_PLATFORM='$QT_QPA_PLATFORM' SDL_VIDEODRIVER='$SDL_VIDEODRIVER' MOZ_ENABLE_WAYLAND='$MOZ_ENABLE_WAYLAND' ELECTRON_OZONE_PLATFORM_HINT='$ELECTRON_OZONE_PLATFORM_HINT'"
|
||||
echo "export XDG_RUNTIME_DIR='$XDG_RUNTIME_DIR' WAYLAND_DISPLAY='$WAYLAND_DISPLAY' XDG_SESSION_TYPE='$XDG_SESSION_TYPE' GDK_BACKEND='$GDK_BACKEND' QT_QPA_PLATFORM='$QT_QPA_PLATFORM' SDL_VIDEODRIVER='$SDL_VIDEODRIVER' SDL_VIDEO_WAYLAND_PREFER_LIBDECOR='$SDL_VIDEO_WAYLAND_PREFER_LIBDECOR' MOZ_ENABLE_WAYLAND='$MOZ_ENABLE_WAYLAND' ELECTRON_OZONE_PLATFORM_HINT='$ELECTRON_OZONE_PLATFORM_HINT' ADW_DEBUG_COLOR_SCHEME='$ADW_DEBUG_COLOR_SCHEME'"
|
||||
exit 0
|
||||
fi
|
||||
export LANG="${LANG:-C.UTF-8}"
|
||||
|
||||
32
guest/base/rootfs/usr/local/bin/Xwayland
Executable file
32
guest/base/rootfs/usr/local/bin/Xwayland
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/run/kw-lower/bin/busybox sh
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# Copyright (C) 2026 Pooya Parsa <pooya@pi0.io>
|
||||
|
||||
# /usr/local/bin/Xwayland (the kw layer): runs the distro's Xwayland
|
||||
# (/usr/bin/Xwayland) and gives its root window a pointer. Xwayland's root
|
||||
# window has no cursor, which every X window that sets none of its own
|
||||
# inherits (the Athena widgets' apps: xeyes, XPaint, twm's desktop), so the
|
||||
# compositor hides the pointer over them (in the page: no pointer at all).
|
||||
# When Xwayland is given a display (:N), this sets the root window's cursor
|
||||
# to left_ptr (xsetroot, from x11-xserver-utils; nothing without it) once
|
||||
# the display's socket is there. A server that resets when its last client
|
||||
# leaves (no -noreset) forgets it if xsetroot was that client. Found first
|
||||
# on PATH (before /usr/bin; sudo's secure_path too), so whatever starts
|
||||
# Xwayland by name gets it: a shell, a launcher app, xwayland-satellite.
|
||||
|
||||
real=/usr/bin/Xwayland
|
||||
[ -x $real ] || { echo "Xwayland: not installed (Debian: sudo apt-get install xwayland)" >&2; exit 127; }
|
||||
d=
|
||||
for a; do case $a in :[0-9]*) d=${a#:}; break ;; esac; done
|
||||
if [ -n "$d" ] && [ -x /usr/bin/xsetroot ] && [ ! -e "/tmp/.X11-unix/X$d" ]; then
|
||||
(
|
||||
i=0
|
||||
while [ ! -S "/tmp/.X11-unix/X$d" ]; do
|
||||
i=$((i + 1))
|
||||
[ $i -gt 300 ] && exit 0
|
||||
sleep 0.1
|
||||
done
|
||||
DISPLAY=:$d /usr/bin/xsetroot -cursor_name left_ptr 2>/dev/null
|
||||
) </dev/null >/dev/null 2>&1 &
|
||||
fi
|
||||
exec $real "$@"
|
||||
Reference in New Issue
Block a user