Software that fixes a glaring problem with my Linux experience
Smilex Jun 21, 2018
Hey! I'm curious if anyone else has this problem, and would benefit from this solution. I've switched DEs and terminals trying to get away from it. Most recently I switched from XFCE to DWM, but I moved back because it turns out DWM doesn't suffice for me anymore, and so I was reminded about this issue again. The solution I made was a real eureka moment for me, and I'm happier about it than I should be.
This is a cross post from https://itjac.me/blog.html#blog006

I've been using Linux for over a decade now, and I find myself always with several terminals open, each with something running in them that I cycle through.
A problem with desktop environments that have a window bar and support alt+tab, is that each terminal has the same icon, and so I have to cycle through all of them, until I get to the correct one.
I've tried solving this by using some terminal software that supports custom background colors, but XFCE changes the window screenshot, in the Alt+Tab window, to grayscale. Also this doesn't help with the XFCE panel.
I had the idea that these should all have distinct icons, with different silhouettes, so that they are easy and quick to recognise. But I figured this would be a good feature for a desktop environment, and that meant a lot of work.
That was until I came across a tool made by Paul Evans ( http://www.leonerd.org.uk ), called xseticon ( http://www.leonerd.org.uk/code/xseticon/ ). The X protocol allows you to change the icon of other X windows, and that is what xseticon does. So all I had to do, was write a program that spawns a new terminal, then looks up the X window that was created for it. This was done by checking the PID of the window, which I got from the _NET_WM_PID atom, with the PID I got from the fork() call. Once I had the window ID, I found the PNG icon I wanted to use for this window, and then I called execv to xseticon, with the window ID and the PNG path. The way I select PNGs, is simply with a global array in the code, and then I create a file in $HOME/.icongiver that stores the previous iterator value. This way it simply iterates through the array, in modulus of the array size.
One weird issue that I never figured out, is that when the program was launched from the XFCE Application Finder, it wouldn't give the terminal an icon. I solved this by creating a script, with a /bin/bash bang that only calls my program. I then copied this script into /usr/local/bin.

I made these icons for myself to use. I'm not trained at this stuff, but it is an enjoyable activity. Mostly I just used the circle select tool in The Gimp, and the bucket tool to fill in color.

This is how it looks on the XFCE panel. The top most icon is what the default is. It's for a terminal that's been running since before I started this project.

And here it is in the Alt+Tab window,

This does not solve the problem entirely, but it does help. And for 2 hours of programming, I expect the effort to have been worth it.
It is only one file of C code, with system dependent variables being #define'd at the top.

Now I want to write about licensing. Of course this program is so simple that any license I put on it is merely symbolic; but I decided to go with GPLv3. And I'm worried where the community is going with MIT licenses, and the like. Worried, but not certain, that it is a very bad thing to do, which only propels the giants and furthers consolidation.
It is weird to think that the GPL wasn't a big part of why the FOSS community exists today. And most tech companies who have adopted open source, have done so because they have had to. This implies that open source has beaten proprietary, in at least some fields. What does it then mean to MIT license your software? To my mind, it means that corporations can freely kick and scream about change, and delay it as much as possible, but then do not have to pay anything when they lose. Because the software was MIT licensed, when the corporation makes the decision that they've lost, they just jump over at no cost and fight again.
I also recognise that the MIT license, and licenses similar to it, can benefit small business because the GPL gets in the way. But if my worry is founded on something, then I don't think the solution is to move to a MIT license. The solution might instead be to have multiple licenses, for different team sizes. However I also see that it isn't that simple, because a large corporation can create a smaller team that gets the MIT licensed version of a FOSS project, but then gives that back to the large corporation.
I realize that I'm hardly adding much to the conversion, but I like to use writing to learn what I think. And I do not have the answer, but I'm also not content with what is currently happening, and so I'd like to link to an article I read that touches on the subject - https://jacobinmag.com/2018/06/github-microsoft-open-source-code-technology

The source code and the icon PNGs can be downloaded here - https://itjac.me/releases/icongiver.tar.bz2
nox Jun 21, 2018
This is a neat solution to your problem!

Personally I've taken to assigning certain terminals to certain named workspaces. To me that's a cleaner way of resolving, in my eyes, the same issue.
prachi53 Mar 26, 2019
Great Post, Many thanks for sharing such nice and helpful info.
Xpander Mar 26, 2019
I used workspaces also, but recently i made a script to try a bit different approach since i always don't need maximized terminals.

it looks like this:
[

and script which is binded to my roccat keyboard easyshift+T:

mate-terminal --title=T1 --hide-menubar &
mate-terminal --title=T2 --hide-menubar &
mate-terminal --title=T3 --hide-menubar &
mate-terminal --title=T4 --hide-menubar
sleep 1
wmctrl -r "T1" -e 0,3,20,1277,695
wmctrl -r "T2" -e 0,1282,20,1277,695
wmctrl -r "T3" -e 0,3,771,1277,695
wmctrl -r "T4" -e 0,1282,771,1277,695


wmctrl is a wonderful thing :)
wvstolzing Mar 26, 2019
Looks great. I've got a few scripts that launch special purpose urxvt windows with predefined attributes and icon file, but it's all entered by hand. Though I've eventually settled on tmux title strings for telling apart terminal windows.

Quoting: Xpanderwmctrl is a wonderful thing :)

Does anyone know whether something equivalent is in the works for pure Wayland? (wmctrl does work on XWayland IIRC).
slaapliedje Mar 26, 2019
Use Tilix and set the title of the terminal so it's the program you're using :)

You just go into Preferences -> Appearance -> Default Session name, and you can customize it however you want.
Shmerl Mar 26, 2019
For Wayland such thing would be very compositor specific.
Smilex Jul 14, 2019
Quoting: chancho_zombiei get segmentation fault, does it work with konsole?? should I define the full path to my home directory?

Sorry for the late reply, I never noticed the activity in this thread!
Anyway, the script is written to require knowledge of programming from the user. You'll have to look at the code and alter it to what works for you
While you're here, please consider supporting GamingOnLinux on:

Reward Tiers: Patreon. Plain Donations: PayPal.

This ensures all of our main content remains totally free for everyone! Patreon supporters can also remove all adverts and sponsors! Supporting us helps bring good, fresh content. Without your continued support, we simply could not continue!

You can find even more ways to support us on this dedicated page any time. If you already are, thank you!
Login / Register


Or login with...
Sign in with Steam Sign in with Google
Social logins require cookies to stay logged in.

Buy Games
Buy games with our affiliate / partner links: