Assign (or change) window icons in Openbox

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
User avatar
cimarron
Posts: 292
Joined: Fri 31 May 2013, 01:57

Assign (or change) window icons in Openbox

#1 Post 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:
Attachments
xseticon.tar.gz
(7.17 KiB) Downloaded 295 times
xdotool.tar.gz
(30.27 KiB) Downloaded 280 times

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#2 Post 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\">
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

simargl5

#3 Post 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.

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#4 Post by Flash »

Where should they be, and why?

User avatar
cimarron
Posts: 292
Joined: Fri 31 May 2013, 01:57

#5 Post 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.

Post Reply