# HG changeset patch # User IBBoard # Date 1519420885 0 # Node ID 8052b4f3d142aab152fc286c7c2716bcdad65284 # Parent 3adc69ceb24961de48d8d74dcec1370ba64b7652 Add a little script for symlinking icons to other themes Mainly used for fixing file associations (e.g. mapping text/html icon to application/x-extension-html) diff -r 3adc69ceb249 -r 8052b4f3d142 link-icon --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/link-icon Fri Feb 23 21:21:25 2018 +0000 @@ -0,0 +1,37 @@ +#! /bin/bash + +if [[ $# -ne 4 ]]; then + echo "Usage: ${0##*/} source-SOURCE theme old-path new-path" >&2 + echo " e.g. ${0##*/} /usr/share/icons/Tango mimetypes/gnome-mime-text-css mimetypes/text-css" >&2 + exit 1 +elif [[ ! -d "$1" ]]; then + echo "Source SOURCE did not exist" >&2 + exit 1 +elif [[ "${1:0:1}" != "/" ]]; then + echo "Source must be absolute. For relative paths use link-icon-relative" + exit 1 +elif [[ ! -d ~/.icons/"$2" ]]; then + echo "Destination theme does not exist" + exit 1 +fi + +SOURCE=$1 +THEME=$2 +ICON_OLD=$3 +ICON_NEW=$4 +for dir in 16 22 24 32 48 64 128 256 512; do + NEW_PREFIX=~/.icons/"$THEME"/${dir}x${dir} + OLD_PREFIX="$SOURCE"/${dir}x${dir} + if [[ -d "${NEW_PREFIX}"/"${ICON_NEW%/*}" ]] && [[ -f "${OLD_PREFIX}"/"${ICON_OLD}".png ]]; then + ln -s "${OLD_PREFIX}"/"${ICON_OLD}".png "${NEW_PREFIX}"/"${ICON_NEW}".png + fi +done + +NEW_PREFIX=~/.icons/"$THEME"/scalable +OLD_PREFIX="$SOURCE"/scalable +if [[ -d "${NEW_PREFIX}"/"${ICON_NEW%/*}" ]] && [[ -f "${OLD_PREFIX}"/"${ICON_OLD}".svg ]]; then + ln -s "${OLD_PREFIX}"/"${ICON_OLD}".svg "${NEW_PREFIX}"/"${ICON_NEW}".svg +fi + +gtk-update-icon-cache-2.0 ~/.icons/"$THEME" +gtk-update-icon-cache-3.0 ~/.icons/"$THEME"