Skip to content

Commit

Permalink
Prefer color-scheme from org.freedesktop.portal.Desktop
Browse files Browse the repository at this point in the history
In some distros GNOME 42 or later versions are not available, thus
querying color-scheme will return an error.
  • Loading branch information
easyteacher authored and TheTumultuousUnicornOfDarkness committed Sep 17, 2023
1 parent 97290a3 commit 221b680
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions linuxdeploy-plugin-gtk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,14 @@ mkdir -p "$HOOKSDIR"
cat > "$HOOKFILE" <<\EOF
#! /usr/bin/env bash
case "$(gsettings get org.gnome.desktop.interface color-scheme 2> /dev/null)" in
"'prefer-dark'") GTK_THEME_VARIANT="dark";;
"'prefer-light'") GTK_THEME_VARIANT="light";;
*) GTK_THEME_VARIANT="light";;
COLOR_SCHEME="$(dbus-send --session --dest=org.freedesktop.portal.Desktop --type=method_call --print-reply --reply-timeout=1000 /org/freedesktop/portal/desktop org.freedesktop.portal.Settings.Read 'string:org.freedesktop.appearance' 'string:color-scheme' 2>/dev/null | tail -n1 | cut -b35- | cut -d' ' -f2)"
if [ -z "$COLOR_SCHEME" ]; then
COLOR_SCHEME="$(gsettings get org.gnome.desktop.interface color-scheme 2> /dev/null)"
fi
case "$COLOR_SCHEME" in
"1"|"'prefer-dark'") GTK_THEME_VARIANT="dark";;
"2"|"'prefer-light'") GTK_THEME_VARIANT="light";;
*) GTK_THEME_VARIANT="light";;
esac
APPIMAGE_GTK_THEME="${APPIMAGE_GTK_THEME:-"Adwaita:$GTK_THEME_VARIANT"}" # Allow user to override theme (discouraged)
Expand Down

0 comments on commit 221b680

Please sign in to comment.