Hello

I like to have one terminal per computer I'm connected to and
distinguish those by the icon in the window managers task bar. However,
setting those icons is a real mess in most modern window managers. KDE
offers a way which requires root access and placing properly named icons
in /ush/share/icons, Gnome and Xfce don't have any possibility to
manually specify an icon for some application at all.

Therefor, I hacked up some lines of codes which allow to manually
specify an icon for rxvt-unicode. It uses for this the _NET_WM_ICON
window properties described at
http://standards.freedesktop.org/wm-spec/wm-spec-1.3.html#id2507733 
which seems to be supported by all modern WM.

This is just a proof of concept with a hardwired file name, the idea
should be to make the file name customizable via command line. Also,
this patch leaves the size of the imported icon unchanged and assumes,
that the window manager scales to something reasonable. Probably one
should at least check, if the size of the image given by the user
exceeds some sane maximum.

Find the patch attached. It assumes that there's a file
/usr/share/icons/zoidberg.png on your disk which is probably wrong...

Would something like this acceptable for inclusion in rxvt-unicode?

Yours,
Frank

-- 
Have you ever considered how much text can fit in eighty columns?  Given that a
signature typically contains up to four lines of text, this space allows you to
attach a tremendous amount of valuable information to your messages.  Seize the
opportunity and don't waste your signature on bullshit that nobody cares about.
? iconproperty.patch
? patch.patch
Index: init.C
===================================================================
RCS file: /schmorpforge/rxvt-unicode/src/init.C,v
retrieving revision 1.253
diff -u -r1.253 init.C
--- init.C	15 Jul 2008 16:41:22 -0000	1.253
+++ init.C	14 Oct 2008 13:08:36 -0000
@@ -1137,6 +1137,37 @@
 
   XmbSetWMProperties (dpy, top, NULL, NULL, (char **)argv, argc,
                       &szHint, &wmHint, &classHint);
+#  ifdef HAVE_AFTERIMAGE 
+  ASImage *im = file2ASImage("/usr/share/icons/zoidberg.png", 0xFFFFFFFF, SCREEN_GAMMA, 0, NULL);
+  if (im){
+    int w=im->width;
+    int h=im->height;
+    int length=4*w*h+2*sizeof(int);
+    int* buffer = (int*)malloc(length);
+    int screen = DefaultScreen(dpy);
+    int depth = DefaultDepth( dpy, screen );
+    ASVisual* asv = create_asvisual( dpy, screen, depth, NULL );
+    ASImage* result = scale_asimage (asv, im,
+                                     w,h,ASA_ARGB32,
+                                     100, ASIMAGE_QUALITY_DEFAULT);
+    if (buffer && result){
+      buffer[0]=w;
+      buffer[1]=h;
+      memcpy(buffer+2,result->alt.argb32,4*w*h);
+      Atom net_wm_icon = XInternAtom(dpy, "_NET_WM_ICON", False);
+      Atom cardinal = XInternAtom(dpy, "CARDINAL", False);
+      XChangeProperty(dpy, top, net_wm_icon, cardinal, 32,
+                      PropModeReplace, (const unsigned char*) buffer, 2+w*h);
+    }
+    else{
+      if (!buffer) rxvt_warn ("Memory allocation for icon hint failed!\n");
+      if (!result) rxvt_warn ("Image transformation to ARGB of image for icon hint failed!\n");
+    }
+  }
+  else{
+    rxvt_warn ("Loading of image for icon hint failed!\n");
+  }
+#endif
 
 #if ENABLE_FRILLS
   if (mwmhints.flags)
_______________________________________________
rxvt-unicode mailing list
[email protected]
http://lists.schmorp.de/cgi-bin/mailman/listinfo/rxvt-unicode

Reply via email to