Is it possible to let tkabber set the urgency flag?

Hallo,

some applications set the urgency flag when the contents have changed. My window manager (ion3) then changes the color of the title bar. This is very useful for an instant messanger running in the background. But tkabber obviously doesn't support this feature.

There's a very small application demonstrating how urgency flag is set at
http://modeemi.fi/~tuomov/ion/misc/urgent.c .

Is it possible to add this to tkabber?

Greetings!
Benno

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I've tried a little bit. I

I've tried a little bit. I know how to set it in principal. But I don't know how to get the WindowID of the chat window. I think I have to use something like [winfo id $window] in ifacetk/iface.tcl. But I haven't found the right value for $window.

Probably you should use

Probably you should use something like

[winfo toplevel [chat::winid $chatid]]

if you know chat ID $chatid.

Thanks! I've tried it. But

Thanks! I've tried it. But the returned value and the X window identifier differ. When opening a plain wish and typing

winfo id .

in it, the returned value differs from the X window ID too. E.g. winfo returns 0xc00003 while the window ID is 0xc00004. Thus I think
winfo id window

doesn't return the correct X window ID in general.
Getting the right value should be very easy I think. But without any knowledge of tcl/tk I don't know how.

You may also try to use wm

You may also try to use

wm frame .

instead of

winfo id .

In ifacetk/iface.tcl wm

In ifacetk/iface.tcl

wm frame $cw

returns the same value as

winfo id $cw

.

The command

xwininfo -tree

gives the following output:

xwininfo: Please select the window about which you
          would like information by clicking the
          mouse in that window.

xwininfo: Window id: 0x1800086 "Chatte mit ameise"

  Root window id: 0x4c (the root window) (has no name)
  Parent window id: 0x800018 (has no name)
     1 child:
     0x1800102 (has no name): ()  1398x497+0+0  +1+20
        6 children:
        0x18000e1 (has no name): ()  1370x405+8+31  +9+51
        0x1800105 (has no name): ()  1382x405+8+31  +9+51
           1 child:
           0x18000e2 (has no name): ()  12x405+1370+0  +1379+51
        0x180010a (has no name): ()  1382x45+8+444  +9+464
        0x18000e0 (has no name): ()  1382x45+8+444  +9+464
           1 child:
           0x1800106 (has no name): ()  12x45+1370+0  +1379+464
        0x18000de (has no name): ()  1382x458+8+31  +9+51
           3 children:
           0x180010c (has no name): ()  1382x45+0+413  +9+464
              1 child:
              0x1800110 (has no name): ()  1382x45+0+0  +9+464
           0x180010d (has no name): ()  1382x8+0+405  +9+456
              2 children:
              0x1800113 (has no name): ()  8x8+1368+0  +1377+456
              0x1800114 (has no name): ()  1382x2+0+3  +9+459
           0x180010e (has no name): ()  1382x405+0+0  +9+51
              1 child:
              0x180010f (has no name): ()  1382x405+0+0  +9+51
        0x1800022 (has no name): ()  1382x23+8+8  +9+28
           4 children:
           0x180010b (has no name): ()  6x19+280+2  +289+30
           0x1800109 (has no name): ()  188x23+92+0  +101+28
           0x18000df (has no name): ()  72x19+20+2  +29+30
              1 child:
              0x1800112 (has no name): ()  72x19+0+0  +29+30
           0x18000e3 (has no name): ()  20x20+0+1  +9+29
              1 child:
              0x1800111 (has no name): ()  20x20+0+0  +9+29

In this case 0x1800086 is the value I need. But with the winfo and wm commands above I got the value 0x1800102. Perhaps the command must not be placed in ifacetk/iface.tcl.

Is there an easy way to list all of tkabber's windows with their IDs?

OK, I've found an ugly

OK, I've found an ugly solution. I must add a few lines only and it will work.

Thanks!
Benno

EDIT:
I've added these three lines after line 939 in ifacetk/iface.tcl (tkabber-0.9.8):

catch {exec xwininfo -tree -id [winfo id $cw] | grep Parent -} windowid
regexp {0x[0-9a-f]+} $windowid winid
exec urgent $winid 
 

The flag is set by an external program because I don't know how to set it with tcl/tk:

/*
 * A simple example of setting the XUrgencyHint
 *     Compile with:
 * 
 *     gcc -L/usr/X11R6/lib -lX11 urgent.c -o urgent
 * 
 */

#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>

static int set_urgency(Display *dpy, Window id, int set)
{
        XWMHints *hints=XGetWMHints(dpy, id);

        if(hints==NULL)
                return 0;

        if(set)
                hints->flags|=XUrgencyHint;
        else
                hints->flags&=~XUrgencyHint;

        return (XSetWMHints(dpy, id, hints)!=0);
}

int main(int argc, char *argv[])
{
        Display *dpy;
        const char *ids;
        Window id;

        id=strtol(argv[1], NULL, 16);
        dpy=XOpenDisplay(NULL);

        if(dpy==NULL){
                fprintf(stderr, "Unable to open display.");
                return EXIT_FAILURE;
        }

        /* Set the flag */
        set_urgency(dpy, id, 1);

        XFlush(dpy);

        XCloseDisplay(dpy);

        return EXIT_SUCCESS;
        exit;
}

It's not perfect but it seems to work.

Syndicate content