summary refs log tree commit diff
path: root/pkgs/data/icons/hicolor-icon-theme
diff options
context:
space:
mode:
authorJosé Romildo Malaquias <malaquias@gmail.com>2020-04-17 13:39:03 -0300
committerJosé Romildo Malaquias <malaquias@gmail.com>2020-04-19 21:29:32 -0300
commitbbeb6ac387ad5aa933310a7572d8de4462bc356a (patch)
treeb5771b03966d5875b7847191474d6752c03657c7 /pkgs/data/icons/hicolor-icon-theme
parent76f2f29de6932eb661559355383c3d9dfe736eb5 (diff)
downloadnixpkgs-bbeb6ac387ad5aa933310a7572d8de4462bc356a.tar
nixpkgs-bbeb6ac387ad5aa933310a7572d8de4462bc356a.tar.gz
nixpkgs-bbeb6ac387ad5aa933310a7572d8de4462bc356a.tar.bz2
nixpkgs-bbeb6ac387ad5aa933310a7572d8de4462bc356a.tar.lz
nixpkgs-bbeb6ac387ad5aa933310a7572d8de4462bc356a.tar.xz
nixpkgs-bbeb6ac387ad5aa933310a7572d8de4462bc356a.tar.zst
nixpkgs-bbeb6ac387ad5aa933310a7572d8de4462bc356a.zip
hicolor-icon-theme: add hook to symlink inherited icon themes
Diffstat (limited to 'pkgs/data/icons/hicolor-icon-theme')
-rw-r--r--pkgs/data/icons/hicolor-icon-theme/setup-hook.sh41
1 files changed, 41 insertions, 0 deletions
diff --git a/pkgs/data/icons/hicolor-icon-theme/setup-hook.sh b/pkgs/data/icons/hicolor-icon-theme/setup-hook.sh
index f07bab4b269..9a6b5f405ca 100644
--- a/pkgs/data/icons/hicolor-icon-theme/setup-hook.sh
+++ b/pkgs/data/icons/hicolor-icon-theme/setup-hook.sh
@@ -11,3 +11,44 @@ hicolorIconThemeHook() {
 
 # I think this is meant to be a runtime dep
 addEnvHooks "${hostOffset:?}" hicolorIconThemeHook
+
+
+# Make symbolic links of parent icon themes that are inherited in the
+# icon themes installed by the package.
+symlinkParentIconThemes() {
+    if [ -e $out/share/icons ]; then
+        echo Symlinking parent icon themes...
+        local theme
+        local theme_name
+        local inheritance
+        local parent
+        local parent_theme
+        local dir
+        local parent_path
+        for theme in $out/share/icons/*/index.theme; do
+            theme_name="${theme%/*}"
+            theme_name="${theme_name##*/}"
+            echo "  theme: $theme_name"
+            inheritance=$(sed -rne 's,^Inherits=(.*)$,\1,p' $theme)
+            IFS=',' read -ra parent_themes <<< "$inheritance"
+            for parent_theme in "${parent_themes[@]}"; do
+                parent_path=""
+                if [ -e "$out/share/icons/$parent_theme" ]; then
+                    parent_path="$(realpath $out/share/icons/$parent_theme)"
+                else
+                    IFS=':' read -ra dirs <<< $XDG_ICON_DIRS
+                    for parent_dir in  "${dirs[@]}"; do
+                        if [ -e "$parent_dir/icons/$parent_theme/index.theme" ]; then
+                            parent_path=$(realpath "$parent_dir/icons/$parent_theme")
+                            ln -s "$parent_path" "$out/share/icons/"
+                            break
+                        fi
+                    done
+                fi
+                echo "    parent: $parent_theme	-> $parent_path"
+            done
+        done
+    fi
+}
+
+preFixupHooks+=(symlinkParentIconThemes)