nixos/wyoming/{faster-whisper,piper}: drop download directory (#376447)
[NixPkgs.git] / pkgs / by-name / hi / hicolor-icon-theme / setup-hook.sh
blobdf7cac08b058f9e0304c96708d9c74ba4319e9f2
1 # shellcheck shell=bash
3 # Populate XDG_ICON_DIRS
4 hicolorIconThemeHook() {
6 # where to find icon themes
7 if [ -d "$1/share/icons" ]; then
8 addToSearchPath XDG_ICON_DIRS "$1/share"
9 fi
12 # I think this is meant to be a runtime dep
13 addEnvHooks "${targetOffset:?}" hicolorIconThemeHook
15 # Make symbolic links of parent icon themes that are inherited in the
16 # icon themes installed by the package.
17 symlinkParentIconThemes() {
18 if [ -e $out/share/icons ]; then
19 echo Symlinking parent icon themes...
20 local theme
21 local theme_name
22 local inheritance
23 local parent
24 local parent_theme
25 local dir
26 local parent_path
27 for theme in $out/share/icons/*/index.theme; do
28 theme_name="${theme%/*}"
29 theme_name="${theme_name##*/}"
30 echo " theme: $theme_name"
31 inheritance=$(sed -rne 's,^Inherits=(.*)$,\1,p' "$theme")
32 IFS=',' read -ra parent_themes <<< "$inheritance"
33 for parent_theme in "${parent_themes[@]}"; do
34 parent_path=""
35 if [ -e "$out/share/icons/$parent_theme" ]; then
36 parent_path="$(realpath "$out/share/icons/$parent_theme")"
37 else
38 IFS=':' read -ra dirs <<< $XDG_ICON_DIRS
39 for parent_dir in "${dirs[@]}"; do
40 if [ -e "$parent_dir/icons/$parent_theme/index.theme" ]; then
41 parent_path="$(realpath "$parent_dir/icons/$parent_theme")"
42 ln -s "$parent_path" "$out/share/icons/"
43 break
45 done
47 echo " parent: $parent_theme -> $parent_path"
48 done
49 done
53 preFixupHooks+=(symlinkParentIconThemes)