Skip to content

May 21, 2009

How to change xfce4 themes to use Gnome icons

by Joe Kuan

ubuntulogoChanging the Icon-Theme in xfce4 from Rodent (default) to Gnome sets the xfce4 window manager to use the Gnome icons set. This only means the icons in the Desktop, xfce4 menus are using the Gnome icons set. However, the theme itself doesn’t use the Gnome icons set, that means all the GTK applications (Firefox and many others) are still using icons from the Rodent set. I personally prefer the Gnome icons because of the look and the choice of many icons.

Simply changing from Rodent to GNOME does not solve the matter because Gnome icons set uses the new XDG index scheme and the set doesn’t include the old iconrc-png or iconrc file.

gnome icons set

Another reason is that all the xfce4 themes are still using the old GTK stock icons list defined in Rodent icons theme.

theme iconrc file

In Rodent/iconrc file, the stock relationship is defined as:

pixmap_path "/usr/share/icons/Rodent/scalable/stock"
style "icon-style" {
stock["gtk-about"]                  =  {{ "stock_about.svg" }}
stock["gtk-add"]                    =  {{ "stock_add.svg" }}

As you can see the definition is arranged in name and value pairs. As in Gnome icon sets, not all the svg files have the same matching name. Some files may have different prefix or simply not exist. The following shell script (quick hack) creates a /usr/share/icons/gnome/hack_stock directory containing all the svg files found in Gnome icons set. It parses the Rodent’s iconrc file and then looks for the same svg file in hack_stock directory. If the file doesn’t exist, then it will try different prefixes. It will leave the entry with empty filename if all fail.

# Create a directory for putting all the stock icons .svg files in one place
mkdir /usr/share/icons/gnome/hack_stock
cd /usr/share/icons/gnome/hack_stock

# Create symbolic files pointing to all Gnome stock image files
find /usr/share/icons/gnome -name '*'.svg -exec ln -s {} \;  2> /dev/null

# Read the Rodent iconrc file and get filename.svg to see whether it exists
# in gnome icons set. If so, append the line. If no, echo it as a warning
while read line
do
  if [ -z "$line" ]
  then
    echo "$line" >> ../iconrc
    continue
  fi
  echo "$line" | grep "^stock" > /dev/null
  if [ $? -eq 0 ]
  then
     svgfile=`echo "'$line'" | awk -F= '{ print $2; }' | tr -d "[{{\"'}} ]"`
     if [ -f "$svgfile" ]
     then
        echo "$line" >> ../iconrc

     # Try without the stock prefix
     elif [ -f "${svgfile#stock_}" ]
     then
       echo "$line" | sed "s/{{.*}}/{{ \"${svgfile#stock_}\" }}/" >> ../iconrc

     else
        # Try with gtk prefix and all the underscore become -
        gtksvg=`echo ${svgfile/stock/gtk} | tr '_' '-'`
        if [ -f "$gtksvg" ]
        then
          echo "$line" | sed "s/{{.*}}/{{ \"${gtksvg}\" }}/" >> ../iconrc

        # Last option, leave the empty name
        else
          echo "$line" | sed 's/{{.*}}/{{ "" }}/' >> ../iconrc
        fi
     fi
  else
     echo "$line" >> ../iconrc
  fi
done < /usr/share/icons/Rodent/iconrc

Note that the generated iconrc file may still contain some missing links. I have tried to go through the laborious task of finding svg files with similar look. However, some are left empty because of no suitable candidates.

stock["gtk-about"]                  =  {{ "stock_about.svg" }}
stock["gtk-add"]                    =  {{ "add.svg" }}
stock["gtk-apply"]                  =  {{ "" }}
stock["gtk-bold"]                   =  {{ "gtk-bold.svg" }}
stock["gtk-cancel"]                 =  {{ "gtk-cancel.svg" }}

Before using the new iconrc file, you still need to update couple things.

  1. Change the first line of the pixmap path in the generated iconrc file from
  2. pixmap_path "/usr/share/icons/Rodent/scalable/stock"
    

    to

    pixmap_path "/usr/share/icons/gnome/hack_stock"
    
  3. Change the last line of the icon source path for the theme file in /usr/share/themes/<theme name>/gtk-2.0/gtkrc from
  4. include "/usr/share/icons/Rodent/iconrc-png"
    

    to

    include "/usr/share/icons/gnome/iconrc"
    

Here is the finalised Gnome iconrc file. 

pixmap_path "/usr/share/icons/gnome/hack_stock"

style "icon-style" {

stock["gtk-about"]                  =  {{ "stock_about.svg" }}
stock["gtk-add"]                    =  {{ "add.svg" }}
stock["gtk-apply"]                  =  {{ "emblem-default.svg" }}
stock["gtk-bold"]                   =  {{ "gtk-bold.svg" }}
stock["gtk-cancel"]                 =  {{ "gtk-cancel.svg" }}
stock["gtk-cdrom"]                  =  {{ "gtk-cdrom.svg" }}
stock["gtk-clear"]                  =  {{ "gtk-clear.svg" }}
stock["gtk-close"]                  =  {{ "stock_close.svg" }}
stock["gtk-color-picker"]           =  {{ "" }}
stock["gtk-convert"]                =  {{ "" }}
stock["gtk-connect"]                =  {{ "connect_creating.svg" }}
stock["gtk-copy"]                   =  {{ "stock_copy.svg" }}
stock["gtk-cut"]                    =  {{ "stock_cut.svg" }}
stock["gtk-delete"]                 =  {{ "stock_delete.svg" }}
stock["gtk-dialog-error"]           =  {{ "gtk-dialog-error.svg" }}
stock["gtk-dialog-info"]            =  {{ "gtk-dialog-info.svg" }}
stock["gtk-dialog-question"]        =  {{ "gtk-dialog-question.svg" }}
stock["gtk-dialog-warning"]         =  {{ "gtk-dialog-warning.svg" }}
stock["gtk-directory"]              =  {{ "stock_open.svg" }}
stock["gtk-disconnect"]             =  {{ "connect_no.svg" }}
stock["gtk-dnd"]                    =  {{ "" }}
stock["gtk-dnd-multiple"]           =  {{ "" }}
stock["gtk-stock-edit"]             =  {{ "kedit.svg" }}
stock["gtk-execute"]                =  {{ "gtk-execute.svg" }}
stock["gtk-file"]                   =  {{ "gtk-new.svg" }}
stock["gtk-find"]                   =  {{ "find.svg" }}
stock["gtk-find-and-replace"]       =  {{ "gtk-find-and-replace.svg" }}
stock["gtk-floppy"]                 =  {{ "gtk-floppy.svg" }}
stock["gtk-goto-bottom"]            =  {{ "gtk-goto-bottom.svg" }}
stock["gtk-goto-first"]             =  {{ "gtk-goto-first-ltr.svg" }}
stock["gtk-goto-last"]              =  {{ "gtk-goto-last-ltr.svg" }}
stock["gtk-goto-top"]               =  {{ "gtk-goto-top.svg" }}
stock["gtk-go-back"]                =  {{ "gtk-go-back-ltr.svg" }}
stock["gtk-go-down"]                =  {{ "go-down.svg" }}
stock["gtk-go-forward"]             =  {{ "gtk-go-forward-ltr.svg" }}
stock["gtk-go-up"]                  =  {{ "go-up.svg" }}
stock["gtk-harddisk"]               =  {{ "gtk-harddisk.svg" }}
stock["gtk-help"]                   =  {{ "stock_help.svg" }}
stock["gtk-home"]                   =  {{ "stock_home.svg" }}
stock["gtk-indent"]                 =  {{ "gtk-indent-ltr.svg" }}
stock["gtk-index"]                  =  {{ "gtk-sort-ascending.svg" }}
stock["gtk-italic"]                 =  {{ "gtk-italic.svg" }}
stock["gtk-jump-to"]                =  {{ "gtk-jump-to-ltr.svg" }}
stock["gtk-justify-center"]         =  {{ "gtk-justify-center.svg" }}
stock["gtk-justify-fill"]           =  {{ "gtk-justify-fill.svg" }}
stock["gtk-justify-left"]           =  {{ "gtk-justify-left.svg" }}
stock["gtk-justify-right"]          =  {{ "gtk-justify-right.svg" }}
stock["gtk-media-forward"]          =  {{ "stock_media-fwd.svg" }}
stock["gtk-media-next"]             =  {{ "stock_media-next.svg" }}
stock["gtk-media-pause"]            =  {{ "stock_media-pause.svg" }}
stock["gtk-media-play"]             =  {{ "stock_media-play.svg" }}
stock["gtk-media-previous"]         =  {{ "stock_media-prev.svg" }}
stock["gtk-media-record"]           =  {{ "stock_media-rec.svg" }}
stock["gtk-media-rewind"]           =  {{ "stock_media-rew.svg" }}
stock["gtk-media-stop"]             =  {{ "stock_media-stop.svg" }}
stock["gtk-missing-image"]          =  {{ "gtk-missing-image.svg" }}
stock["gtk-network"]                =  {{ "gtk-network.svg" }}
stock["gtk-new"]                    =  {{ "gtk-new.svg" }}
stock["gtk-no"]                     =  {{ "gtk-cancel.svg" }}
# use builtin
# stock["gtk-ok"]                     =  {{ "" }}
stock["gtk-open"]                   =  {{ "stock_open.svg" }}
stock["gtk-paste"]                  =  {{ "stock_paste.svg" }}
stock["gtk-preferences"]            =  {{ "gtk-preferences.svg" }}
stock["gtk-print"]                  =  {{ "stock_print.svg" }}
stock["gtk-print-preview"]          =  {{ "stock_print-preview.svg" }}
stock["gtk-properties"]             =  {{ "stock_properties.svg" }}
stock["gtk-quit"]                   =  {{ "gtk-quit.svg" }}
stock["gtk-redo"]                   =  {{ "stock_redo.svg" }}
stock["gtk-refresh"]                =  {{ "stock_refresh.svg" }}
stock["gtk-remove"]                 =  {{ "remove.svg" }}
stock["gtk-revert-to-saved"]        =  {{ "gtk-revert-to-saved-ltr.svg" }}
stock["gtk-save"]                   =  {{ "stock_save.svg" }}
stock["gtk-save-as"]                =  {{ "stock_save-as.svg" }}
stock["gtk-select-color"]           =  {{ "" }}
stock["gtk-select-font"]            =  {{ "font.svg" }}
stock["gtk-sort-ascending"]         =  {{ "gtk-sort-ascending.svg" }}
stock["gtk-sort-descending"]        =  {{ "gtk-sort-descending.svg" }}
stock["gtk-spell-check"]            =  {{ "gtk-spell-check.svg" }}
stock["gtk-stop"]                   =  {{ "stock_stop.svg" }}
stock["gtk-strikethrough"]          =  {{ "gtk-strikethrough.svg" }}
stock["gtk-undelete"]               =  {{ "gtk-undo-ltr.svg" }}
stock["gtk-underline"]              =  {{ "gtk-underline.svg" }}
stock["gtk-undo"]                   =  {{ "stock_undo.svg" }}
stock["gtk-unindent"]               =  {{ "gtk-unindent-ltr.svg" }}
stock["gtk-yes"]                    =  {{ "" }}
stock["gtk-zoom-100"]               =  {{ "gtk-zoom-100.svg" }}
stock["gtk-zoom-fit"]               =  {{ "zoom-fit-best.svg" }}
stock["gtk-zoom-in"]                =  {{ "stock_zoom-in.svg" }}
stock["gtk-zoom-out"]               =  {{ "stock_zoom-out.svg" }}
stock["gnome-stock-about"]          =  {{ "stock_about.svg" }}
stock["gnome-stock-attach"]         =  {{ "stock_attach.svg" }}
stock["gnome-stock-volume"]         =  {{ "stock_volume.svg" }}
stock["gnome-stock-mic"]            =  {{ "stock_mic.svg" }}
stock["gnome-stock-line-in"]        =  {{ "" }}
stock["gnome-stock-book-blue"]      =  {{ "" }}
stock["gnome-stock-book-green"]     =  {{ "" }}
stock["gnome-stock-book-red"]       =  {{ "" }}
stock["gnome-stock-book-yellow"]    =  {{ "" }}
stock["stock_fullscreen"]           =  {{ "stock_fullscreen.svg" }}
stock["stock_new_tab"]              =  {{ "" }}
stock["epiphany-bookmarks"]         =  {{ "" }}
stock["epiphany-bookmark-page"]     =  {{ "" }}
stock["stock_add-bookmark"]         =  {{ "" }}
stock["epiphany-new-tab"]           =  {{ "" }}
stock["stock-mailto"]               =  {{ "mail-send.svg" }}
stock["stock_mail-send"]            =  {{ "stock_mail-send.svg" }}
stock["stock_view-html-source"]     =  {{ "html.svg" }}
stock["stock-download"]             =  {{ "emblem-downloads.svg" }}
stock["epiphany-download"]          =  {{ "emblem-downloads.svg" }}
stock["epiphany-mailto"]            =  {{ "mail-send.svg" }}
stock["stock-history"]              =  {{ "" }}
stock["epiphany-history"]           =  {{ "" }}
stock["gtk-stock-dialog-warning"]   =  {{ "gtk-dialog-warning.svg" }}
stock["rox-show-hidden"]            =  {{ "" }}
stock["rox-show-details"]           =  {{ "" }}
stock["rox-select"]                 =  {{ "" }}
stock["gtk-stock-ok"]               =  {{ "" }}
stock["gtk-stock-revert"]           =  {{ "stock_undo.svg" }}
stock["gtk-stock-stop"]             =  {{ "stock_stop.svg" }}
stock["terminal-edit"]              =  {{ "gtk-preferences.svg" }}
stock["session-stock-edit"]         =  {{ "gtk-preferences.svg" }}
stock["gtk-stock-import"]           =  {{ "" }}
stock["gtk-stock-export"]           =  {{ "" }}
stock["gtk-stock-insert-image"]     =  {{ "insert-image.svg" }}
stock["gtk-stock-insert-object"]    =  {{ "insert-object.svg" }}
stock["gtk-stock-insert-table"]     =  {{ "" }}
stock["gtk-stock-reset"]            =  {{ "" }}
stock["gtk-media-play"]             =  {{ "stock_media-play.svg" }}
}
class "GtkWidget" style "icon-style"

style "panel-icons"
{
stock ["panel-screenshot"]          =  {{ "camera-photo.svg" }}
stock ["panel-run"]                 =  {{ "gtk-execute.svg" }}
stock ["panel-logout"]              =  {{ "gnome-logout.svg" }}
stock ["panel-amusements"]          =  {{ "applications-games.svg" }}
stock ["panel-accessories"]         =  {{ "access.svg" }}
stock ["panel-multimedia"]          =  {{ "multimedia.svg" }}
stock ["panel-internet"]            =  {{"stock_internet.svg" }}
}
class "GtkWidget" style "panel-icons"

style "media-icons"
{
stock ["cdplayer-stop"]             =  {{ "media-playback-stop.svg" }}
stock ["cdplayer-play"]             =  {{ "media-playback-start.svg" }}
stock ["cdplayer-pause"]            =  {{ "media-playback-pause.svg" }}
stock ["cdplayer-prev"]             =  {{ "media-skip-backward.svg" }}
stock ["cdplayer-next"]             =  {{ "media-skip-forward.svg" }}
stock ["cdplayer-eject"]            =  {{"media-eject.svg" }}
stock ["cdplayer-backward"]         =  {{ "media-seek-backward.svg" }}
stock ["cdplayer-record"]           =  {{"media-record.svg" }}
stock ["volume-mute"]               =  {{ "audio-volume-muted.svg" }}
stock ["volume-zero"]               =  {{ "audio-volume-muted.svg" }}
stock ["volume-min"]                =  {{ "audio-volume-low.svg" }}
stock ["volume-med"]                =  {{ "audio-volume-medium.svg" }}
stock ["volume-max"]                =  {{ "audio-volume-high.svg" }}
}
class "GtkWidget" style "media-icons"

It seems that the Gnome icons doesn’t have ‘gtk-ok’ icon. So I have commented it out to use the Gtk built-in one instead. There are far more selections in Gnome icons for specific stock icons. If you find any icon defined in the iconrc file with inconsistent look & feel, then drop me a comment and I will update the blog.

At the time of writing, following versions were used:
Xfce-4.4.2, Ubuntu 8.04 LTS, gnome-icon-theme 2.22.0-1ubuntu2, xfce4-icon-theme 4.4.2-1

Hope this may help some of you using xfce4.

I work for iTrinegy and here are my other technical blogs

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Note: HTML is allowed. Your email address will never be published.

Subscribe to comments

Follow

Get every new post delivered to your Inbox.

Join 33 other followers

%d bloggers like this: