TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [TCLUG:6088] Banal xterm question
Here is a program that will do it. But you will have to know the
window id of the xterm. You can find that out by running xwininfo.
I am not sure there are any control sequences that will do it. But
you can take a look at the source code README file which has
references to control sequences that change the behaviour of the xterm.
You can compile the program with :
gcc -o myiconify myiconify.c -lX11
And run it like so :
myiconify -i 0x400005
to iconify it or
myiconify -o 0x400005
to reverse the process. But you will have to find out the window
id of the xterm window, some other way. You can use xwininfo and
do a grep for the title and the cut the window id part of it.
Enjoy !
--
sandipan
/*-- Cut here and save as myiconify.c or anyother name you prefer --*/
#include<X11/Xlib.h>
#include<stdlib.h>
#include<stdio.h>
void print_help()
{
fprintf(stderr, "usage: myiconify <-o|i> windowid\n");
fprintf(stderr, " where -i: iconifies the window\n");
fprintf(stderr, " -o: un-iconifies the window\n");
fprintf(stderr, " windowid is the id of the window in hex as returned
by\n");
fprintf(stderr, " say xwininfo. It is not the title of the
window\n");
exit(EXIT_FAILURE);
}
main(int argc, char** argv)
{
Display* dpy;
Window win;
Screen scr;
int iconify = 0;
if( argc != 3 ) {
print_help();
}
if( strcmp(argv[1], "-i") == 0 ) {
iconify = 1;
} else if ( strcmp(argv[1], "-o") == 0 ) {
iconify = 0;
} else {
print_help();
}
if( sscanf( argv[2], "%x", &win ) != 1 ) {
print_help();
}
dpy = XOpenDisplay("");
if( !dpy ) {
fprintf( stderr, "Cannot open display\n" );
exit(1);
}
if( iconify ) {
XIconifyWindow( dpy, win, DefaultScreen(dpy) );
} else
{
XMapWindow( dpy, win );
}
XCloseDisplay(dpy);
}
bob@math.umn.edu wrote:
>
> I would like to iconify an xterm window from a bash script running
> in that same xterm. And for fun, maybe reverse the process as well.
>
> Is this trivial or terrible, and how can it be done?
>
> Adios,
> Chris
> --
> C.S. Cornuelle
> School of Mathematics/MCIM
> 206 Church St. SE
> University of Minnesota
> Minneapolis, MN 55455
> (612) 626-8930, 624-9069
> bob@math.umn.edu
> --
> Ferventer Vestite