summaryrefslogtreecommitdiffstats
path: root/scripts/gtk3/gtk3-fix.sh
blob: 143ea706e5c3e2450b61f5a93d8a143e1ffb4a4b (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
#!/bin/bash
# credit:
# http://tacticalvim.wordpress.com/2013/01/05/using-the-adwaita-gtk3-theme-with-xfce-and-lightdm/
#
# to be run as root, not user related
#
# gtk-fallback.css notes:
# - https://bugs.archlinux.org/task/34002
# - https://git.gnome.org/browse/gnome-themes-standard/commit/?id=1aed68dbda8b93b39d2586df132cc14ca337c4d9

GR_FILE="/usr/share/themes/Adwaita/gtk-3.0/gtk.gresource"
GR_BASEDIR="$(dirname "${GR_FILE}")"
GR_BASEROOT="/org/gnome/adwaita/"
GR_FILES="${GR_BASEDIR}/files"

mkdir "${GR_FILES}"
pushd "${GR_FILES}" >/dev/null || exit

for RSRC in $(gresource list $GR_FILE); do
	RSRC_FILE="$(echo "${RSRC#$GR_BASEROOT}")"
	mkdir -p "$(dirname "$RSRC_FILE")" ||:
	gresource extract "$GR_FILE" "$RSRC" > "$RSRC_FILE"
done

find "${GR_BASEDIR}" -maxdepth 1 -name '*.css' -print0 | xargs -0 -I '{}' \
  sed -i.bck \
    -e "s|^\(@import\s\+url\s*(\s*\"\)resource://${GR_BASEROOT}\(.*\)|\1file:///${GR_FILES}/\2|" \
  '{}'

popd >/dev/null