about summary refs log tree commit diff
path: root/pkgs/development/libraries/gtk/gtk3-setup-hook.sh
blob: 5a0eea0fc28557c33c528d3219d9f033d29fb25d (plain) (blame)
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
# shellcheck shell=bash

fixupOutputHooks+=(_gtk3CleanComments)

# Clean comments that link to generator of the file
_gtk3CleanComments() {
    local f="${prefix:?}/lib/gtk-3.0/3.0.0/immodules.cache"
    if [ -f "$f" ]; then
        sed 's|Created by .*bin/gtk-query-|Created by bin/gtk-query-|' -i "$f"
    fi
}

# Packages often run gtk-update-icon-cache to include their icons in themes’ icon cache.
# However, since each package is installed to its own prefix, the files will only collide.
dropIconThemeCache() {
    if [[ -z "${dontDropIconThemeCache:-}" ]]; then
        local icondir="${out:?}/share/icons"
        if [[ -d "${icondir}" ]]; then
            # App icons are supposed to go to hicolor theme, since it is a fallback theme as per [icon-theme-spec], but some might still choose to install stylized icons to other themes.
            find "${icondir}" -name 'icon-theme.cache' -print0 \
              | while IFS= read -r -d '' file; do
                echo "Removing ${file}"
                rm -f "${file}"
            done
        fi
    fi
}

preFixupPhases="$preFixupPhases dropIconThemeCache"