summaryrefslogtreecommitdiffstats
path: root/debian/patches/debian/01_debianize_xrdb.patch
blob: 1dced2cb46169881c71e3061777f08c1d67a57d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
From: Laurent Bigonville <bigon@debian.org>
Date: Thu, 12 Mar 2020 18:05:51 +0100
Subject: Debianize the 00-xrdb script

In Debian, /etc/X11/Xresources is a directory, processing of ~/.Xresources
is controlled by /etc/X11/Xsession.options, and xrdb is not a mandatory
dependency.

Forwarded: not-needed, Debian-specific
---
 plugins/xsettings/00-xrdb | 36 +++++++++++++++++++++++++++++++-----
 1 file changed, 31 insertions(+), 5 deletions(-)

diff --git a/plugins/xsettings/00-xrdb b/plugins/xsettings/00-xrdb
index a047e8b..7fc8492 100755
--- a/plugins/xsettings/00-xrdb
+++ b/plugins/xsettings/00-xrdb
@@ -1,9 +1,35 @@
 #!/bin/sh
 
-userresources=$HOME/.Xresources
-sysresources=/etc/X11/Xresources
+# This script mimic what /etc/X11/Xsession.d/30x11-common_xresources is doing
+# but for Xwayland
 
-# merge in defaults
-[ -r "$sysresources" ] && xrdb -nocpp -merge "$sysresources"
-[ -r "$userresources" ] && xrdb -merge "$userresources"
+USRRESOURCES=$HOME/.Xresources
+SYSRESOURCES=/etc/X11/Xresources
+OPTIONFILE=/etc/X11/Xsession.options
 
+# read OPTIONFILE
+OPTIONS=$(cat "$OPTIONFILE") || true
+
+has_option() {
+  if [ "${OPTIONS#*
+$1}" != "$OPTIONS" ]; then
+    return 0
+  else
+    return 1
+  fi
+}
+
+if [ -d "$SYSRESOURCES" ] && which xrdb >/dev/null 2>&1; then
+  RESOURCEFILES=$(run-parts --list $SYSRESOURCES)
+  if [ -n "$RESOURCEFILES" ]; then
+    for RESOURCEFILE in $RESOURCEFILES; do
+      xrdb -merge $RESOURCEFILE
+    done
+  fi
+fi
+
+if has_option allow-user-resources && [ -f "$USRRESOURCES" ]; then
+  if which xrdb >/dev/null 2>&1; then
+    xrdb -merge $USRRESOURCES
+  fi
+fi