Find the answer to your Linux question:
Results 1 to 3 of 3
When I fire up a terminal window, I always get the default red X xterm icon. The issue is that I often have xterms/rxvts that run for a long periods ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux User
    Join Date
    Dec 2011
    Location
    Turtle Island West
    Posts
    362

    Set custom taskbar icons for xterm/rxvt


    When I fire up a terminal window, I always get the default red X xterm icon. The issue is that I often have xterms/rxvts that run for a long periods of time with some special purpose program running in them. Midnight Commander for example. Mplayer doing internet radio. Tailing /var/log/something. etc. etc..

    I got tired of looking at the red X all the time, so I looked into how to change the icon. A lot of people probably know the printf/echo command to change the xterm title bar:

    printf ( "\033]0;%s\007\n", title );

    but how do you set the icon?

    There's a program called xseticon that does it. There's also another program called the same thing that doesn't. I have no idea what it's supposed to do, but it has a ton of bizarre dependencies and is just awful.

    Anyway, after looking at the one that does work, I realized even it is more complicated than it needs to be. To be honest, it uses (demands) PNG files for the icons. XPM is XWindows native format, and it can load them easily into Pixmaps, so I hacked myself a super-duper-simple C program that sets custom icons for your xterm/rxvt/whatever.

    What it uses:

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <glibconfig.h>
    #include <glib/glib.h>
    #include <X11/Xlib.h>
    #include <X11/xpm.h>

    gcc -Wall -L/usr/X11R6/lib -L/usr/lib -lX11 -lXpm -lglib-2.0 xsetxpm.o -o xsetxpm

    That's it.

    Even glib could be dropped.

    Again, this is demonstration code. It works, but it does very little error checking, and calls out to be fancied up. If you feed it garbage, it either shows usage() and quits, or fails silently. Sometimes it's amazing how much research and work it takes to make something simple.

    There's basically 8 lines of real code to make this happen.

    I included a few icons in xpm format just so it works right off the bat. Some even have transparency that works.

    The tar file is 3592 *bytes*, Makefile, icons, everything.
    Attached Files Attached Files

  2. #2
    Just Joined!
    Join Date
    Oct 2013
    Posts
    1
    Hello,

    Thanks for a great tool that I couldn't find before.

    I managed to successfully compile it and run it after minor issues I described below.

    The way to run it that I used was (when you know the window's title):

    Code:
    xsetxpm -id `xwininfo -int -name "window title" | grep 'xwininfo:' | cut -d ' ' -f 4` path_to_xpm.xpm
    The program works fine. However, unfortunately the icons of some applications that I tested don't change.
    These are more complex/newer applications like Firefox, Gimp, Pidgin, gmplayerm Audacious.
    The following appliction succefully respond to the icon change:
    aumix,xfig,zenmap,xclock,xeyes,xterm,rxvt,Xpdf,vim ,mutt,xboard,xine.

    I believe this is related to the libraries that they use. Maybe glib2?

    Is there any chance you could improve the application in order to support more applications?
    I would be very greatful!

    The following minor changes had to be done when I compile it with glib2-2.32.4:

    After compiler mssage:
    xsetxpm.c:44:5: warning: 'g_basename' is deprecated (declared at /usr/include/glib-2.0/glib/gfileuti
    make: *** [xsetxpm.o] Error 1

    I changes the "g_basename" to "g_path_get_basename".

    Also:
    in gmacros.h I had to comment out:

    #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
    #error "Only <glib.h> can be included directly."
    #endif

    I believe that this has been amended in the newer version of glib2.

    Kind Regards

    Linkus

  3. #3
    Linux User
    Join Date
    Dec 2011
    Location
    Turtle Island West
    Posts
    362
    The program works fine. However, unfortunately the icons of some applications that I tested don't change.
    These are more complex/newer applications like Firefox, Gimp, Pidgin, gmplayerm Audacious.
    I think that's because they set their own icons. xsetxpm will change the icon, then it gets set right back to what the app wants so fast you can't see it. You'd likely have to hack the app itself, or make xsetxpm a daemon that constantly sets the icon faster than the app can do it.
    After compiler mssage:
    xsetxpm.c:44:5: warning: 'g_basename' is deprecated (declared at /usr/include/glib-2.0/glib/gfileuti
    make: *** [xsetxpm.o] Error 1


    I changes the "g_basename" to "g_path_get_basename".
    I must have done some tweaking right after I posted here. I did that too.
    Also:
    in gmacros.h I had to comment out:

    #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
    #error "Only <glib.h> can be included directly."
    #endif
    Yeah. Funny glib issues. I'm surprised the compile bailed over a warning. I've never seen that gmacros thing before. I use glib-2.16.6. A bit old. They keep changing things too fast. Maybe take out the #include <glibconfig.h>? I always thought that was odd, but everything needed it. I guess they changed it, again.

    Anyway, happy hacking.

    Peace and Cheer.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •