← Back to team overview

torios-dev team mailing list archive

Icon themes

 

Hi,
I am working on a way to generate icon themes in a usable list for myself
I have a script that I am testing.

I also posted this to the Puppy forums in case someone is interested in
help there.

You run the script with no arguments and it defaults to
theme=hicolor
size=32
but you can run it with ANY theme name and size
./iconFinder Numix 48
or whatever you like :)

it outputs a file ${HOME}/icon_include
which contains the icons in jwmrc syntax
<IconPath>${THEME_DIR}/${THEME_TO_USE}/$i</IconPath>

you get a few errors when running, because it looks in a few directories
that don't have icons... but don't fear this is expected  we are looking
to find the icons :)

Any ideas for this would be much appreciated

The hope for this is to eventually implement this as a way to get icon
themes and easily change the icon theme

-- 
Regards

-Israel
ToriOS Team

#!/bin/bash
shopt -s globstar
subdir=""
THEME_TO_USE="$1"
SIZE_TO_USE="$2"
if [ -z "$1" ]
then
  THEME_TO_USE="hicolor"
fi
if [ -z "$2" ]
then
  SIZE_TO_USE="32"
fi
DirectoryMatchesSize() {
 # read Type and size data from subdir
  if [ "${Type}" == "Fixed" ]
  then
    Size="$iconsize"
  elif [ "${Type}" == "Scaled" ]
  then
   echo ""
  #  MinSize <= iconsize <= MaxSize
  fi
  #if Type is Threshold
   # return Size - Threshold <= iconsize <= Size + Threshold
}
HOME_THEME_DIR="${HOME}/.icons"
THEME_DIR_XDG=(${XDG_DATA_DIRS//:// })
THEME_DIR_XDG=($(echo ${THEME_DIR_XDG[*]} |sed 's|$| |' |sed 's|/ |/icons |g' | sed 's://:/:'))

BASE_THEME_DIR="/usr/share/pixmaps"
for i in "${THEME_DIR_XDG[@]}"
do ## loop through XDG dirs
  THEME_DIR="$i"
  for THEME_FILE in "${THEME_DIR}"/${THEME_TO_USE}/**/*.theme
  do ## theme file loops
  NAME=""
  INHERITS=""
  DIRS=""
  MIN=""
  MAX=""
  SIZE=""
  TYPE=""
  THRESH=""
  while read LINE || [ "$LINE" ]
  do ## read loop
    case $LINE in
      Name=*) 
        NAME="${LINE#*=}"''
        ;;

      Inherits=*)
        INHERITS="${LINE#*=}"''
        ;;

      Directories=*)
        DIRS="${LINE#*=}"''
        ;;

      MinSize=*)
        MIN="${LINE#*=}"''
        ;;

      MaxSize=*)
        MAX="${LINE#*=}"''
        ;;

      Size=*)
        SIZE="${LINE#*=}"''
        ;;

      Type=*)
        TYPE="${LINE#*=}"''
        ;;

      Threshold=*)
        THRESH="${LINE#*=}"''
        ;;

      *) ;;

    esac
  if [ "${SIZE}" == "${SIZE_TO_USE}" ]
  then

## ALWAYS ADD pixmaps :)
    echo "<IconPath>${BASE_THEME_DIR}</IconPath>" >${HOME}/icon_include

## create some cool include file
    ICON_PATH=($(echo "${DIRS//,/ }" | sort -u))
    for i in "${ICON_PATH[@]}"
    do
      if [ "${i//$SIZE/}" != "${i}" ]
      then
        echo "<IconPath>${THEME_DIR}/${THEME_TO_USE}/$i</IconPath>" >> ${HOME}/icon_include
      fi
    done
  fi
  done < "$THEME_FILE"
  ## read loop

  done ## theme file loops
done ## loop through XDG dirs