Page 1 of 1

Assign (or change) window icons in Openbox

Posted: Mon 28 Oct 2013, 16:04
by cimarron
This is easy in JWM, but I couldn't find a way in Openbox to assign window icons to applications that didn't have them built in (the little icons that appear on the titlebar and in the taskbar). And I was seeing a lot of default Openbox icons. If anyone has a better way to do this, please share.

The best I could come up with is a little script that is run as the application launches, and it assigns an icon using xseticon. To find the window ID, I use xdotool and assume the newly launched application is the focused window. The application is launched with a command like this:

Code: Select all

firefox "$@" & icon-me firefox.png 25
The png is the image I want to assign as the icon, and the number at the end is a delay in seconds to make sure the application fully launches before this "icon-me" script is run (save in, say, /usr/local/bin and give permissions to execute):

Code: Select all

#!/bin/bash

sleep $2
ID=$(xdotool getactivewindow)
xseticon -id $ID /usr/share/pixmaps/$1
The delay can be varied by application (usually 2-5 seconds is enough, but big applications like Firefox can take longer). The icons are placed in /usr/share/pixmaps.

Here's xdotool provided by technosaurus (just unpack and place in /usr/bin), and a deb package of xseticon, which I think will install in all Debian and Ubuntu compatible pups:

Posted: Sun 03 Nov 2013, 21:27
by RSH
Hi.

I'm creating automatically symbolic links of all icons from /usr/share/pixmaps and also from /usr/local/lib/X11/pixmaps to /usr/share/icons/hicolor/48x48/apps and after this doing a refresh of gtk icon cache:

Code: Select all

gtk-update-icon-cache -f /usr/share/icons/hicolor/
When writing a bash script it's usually needed to give the icons name only (without path and extension), to have application icon shown in an openbox window.

Code: Select all

<window title=\"$m_01\" icon-name=\"lazy_remaster\" resizable=\"false\">

Posted: Mon 04 Nov 2013, 09:20
by simargl5
You need to stop using Puppy-only place for installing icons /usr/local/lib/X11/pixmaps, that's simply wrong, maybe it was ok when puppy was first made and it had some window manager that looked like win 95, but now it's wrong. Too bad Puppy developers don't know what is proper place to put icons, and because of that Gtk2 and Gtk3 applications had to use those ugly fallback icons.

Posted: Mon 04 Nov 2013, 12:46
by Flash
Where should they be, and why?

Posted: Mon 04 Nov 2013, 14:21
by cimarron
Just to clarify, I'm not trying to assign icons to applications I wrote, but applications I installed (such as Firefox and SpaceFM) that didn't seem to have window icons, at least not ones that worked for me with Openbox. I tried putting icons in the locations suggested (like /usr/share/pixmaps and /usr/share/icons/hicolor...), with very limited success. I mostly kept seeing the default Openbox window icon.

There were also a few icons I wanted to change (like Geany, SMPlayer). In JWM, icons can be assigned in a config file according to window name or class, but Openbox doesn't seem to have this capability.

So this howto offers a simple way to assign a (new) icon automatically as the application launches. Not perfect, but the best solution I've found so far.


EDIT: I figured out how to manually install a new icon theme, and that fixed several of the missing window icons. But a few were still missing, and I wanted to change a few others that didn't use the icon theme I installed. This method works pretty well for that.