Operating System - HP-UX
1820260 Members
2795 Online
109622 Solutions
New Discussion юеВ

Send output to an Xwindow Virtual Desktop

 
SOLVED
Go to solution
TwoProc
Honored Contributor

Send output to an Xwindow Virtual Desktop

I'm using an Envision Terminal with CDE with four virtual desktops (default). I've renamed each desktop to a different server name.

Assuming that I've telnet'd over to a different server than the one that's running MWM for me;

I'd like to run an x-command and have it appear in a named window.

For instance, to run xterm normally, I can use xclock -display myxterm:0.

Easy enough, but what if I want the clock to appear on a different virtual desktop?

Suppose there are four virtual desktops, labeled "ONE","TWO","THREE" and "FOUR". I want to send the xclock display to the "TWO" virtual desktop.

Right away, I figured I could use: "xclock -display myxterm:1"

But this doesn't work. Can anyone tell me how to do this? I hate having to switch to the proper desktop that I want the display to appear on before running my command (actually I want to run gpm, but I'd just as soon test the idea with something small like xclock).

Thanks for the help,

John
We are the people our parents warned us about --Jimmy Buffett
10 REPLIES 10
Michael Steele_2
Honored Contributor

Re: Send output to an Xwindow Virtual Desktop

That should work.

export DISPLAY=xxx.xxx.xxx.xxx:0.0

xclock

From terminal to receive display maybe xhost +, allow access to all.
Support Fatherhood - Stop Family Law
TwoProc
Honored Contributor

Re: Send output to an Xwindow Virtual Desktop

If you read above, I already knew how to send it to the default virtual desktop (that is the current virtual desktop).

How do I send it to the second virtual desktop - when I'm not on it from the command line?

I know that I can click on the window bar and do a "send to desktop", but I want to execute a command and send it to a virtual desktop all from the command line. I want to do this so I can script a bunch of things that I want started automatically, and have them appear correctly in their named window(s).

That is, I know that :0.0 (the current desktop) works, I want to use another desktop - one I'm not one.

Thanks for the help and the response anyways.

We are the people our parents warned us about --Jimmy Buffett
Alex Glennie
Honored Contributor
Solution

Re: Send output to an Xwindow Virtual Desktop

The functionality is not in built within CDE, what you need is a small program to switch to the appropriate desktop prior to starting each X application.

I have something along these lines send me an email : see my forum profile. or try compiling the following but I think it requires libs from the CDE dev kit to be installed .... ps what O/S ?

/* include files */
#include
#include
#include


/* functions */
void main(int, char**);
void ws_change(Widget widget, Atom aWorkspace, XtPointer client_data);

/* global variables */
static XmString xms;
static Widget toplevel;
static Widget *wWs;
static Atom *paWsSet = NULL;
static unsigned long numWorkspaces;
static Atom *paWs;

static Display *display;
static Window root;
static int screen;
static Widget top, form, top1;
static XtAppContext app_context;
static Arg args[10];
static int n, i, status, pNumWorkspaces;
static Atom *ppaWorkspaces, foundWsAtom = NULL;
static DtWsmWorkspaceInfo *ppWsInfo;
static DtWsmCBContext wsmcontext;
static char *desiredWs;

/* main - main logic for program */
void main (int argc, char **argv)
{

/* initialize toolkit */
n = 0;
XtSetArg (args[n], XmNallowShellResize, True); n++;
XtSetArg (args[n], XtNmappedWhenManaged, False); n++;
toplevel = XtAppInitialize (&app_context,{}&p@x8@a`{ "Dtswitch", NULL, 0,
&argc, argv, NULL, args, n);
display = XtDisplay(toplevel);
screen = DefaultScreen(display);
root = RootWindow(display, screen);
XSynchronize(display, screen);

if ( argc != 2 )
{
printf("must provide name of a workspace to switch to\n");
printf("we'll just monitor workspace changes now\n");
desiredWs = NULL;
}
else
{
desiredWs = argv[1];
}

status = DtWsmGetWorkspaceList(display, root, &ppaWorkspaces,
&pNumWorkspaces);
if (status != Success )
{
printf("problem obtaining workspace list, exiting with status %d\n",
status);
exit(status);
}
/*
printf("Number of workspaces returned is %d\n", pNumWorkspaces);
*/
for (i=0;i {
status = DtWsmGetWorkspaceInfo(display, root, ppaWorkspaces[i],
&ppWsInfo);
if (status != Success )
{
printf("problem getting workspace info %d\n", status);
}
else
{
printf("Workspace %d , title is %s, name is %s\n",i,
ppWsIn{}&p@x8@a`{{fo->pchTitle,
XGetAtomName(display,ppWsInfo->workspace));
if ((desiredWs != NULL) &&
(0 == strcmp(desiredWs, ppWsInfo->pchTitle)))
{
foundWsAtom = ppWsInfo->workspace;
}
}
}

wsmcontext = DtWsmAddCurrentWorkspaceCallback(toplevel, ws_change, NULL);
/*
printf("wsmcontext is %d\n", wsmcontext);
*/
XtRealizeWidget (toplevel);

if (foundWsAtom != None)
{
printf("Atom is %x, name is %s\n",
foundWsAtom,XGetAtomName(display, foundWsAtom));
XFlush(display);
status = DtWsmSetCurrentWorkspace(toplevel, foundWsAtom);
XFlush(display);
printf("status is %d\n",status);
/*
if ( status != Success )
{
printf("workspace %s does not exist\n", desiredWs);
}
*/
}
else
printf("Never found a match - workspace doesn't exist\n");
/*
XtAppMainLoop (app_context);
*/
}

void ws_change(Widget widget, Atom aWorkspace, XtPointer client_data)
{
printf("In the change workspace callback\n");
}


TwoProc
Honored Contributor

Re: Send output to an Xwindow Virtual Desktop

The O/S is 11i. Thanks for the code, I'll give it a try.
We are the people our parents warned us about --Jimmy Buffett
TwoProc
Honored Contributor

Re: Send output to an Xwindow Virtual Desktop

Works !

Big 10,

Thanks
We are the people our parents warned us about --Jimmy Buffett
Wodisch
Honored Contributor

Re: Send output to an Xwindow Virtual Desktop

Hi John,

if you want to run your programs the way you've shown in yor question, then you'll have to run "Xnest" in your CDE session, one *nested* X-server in each workspace. THEN each of those does have its own dispay number...

FWIW,
Wodisch
TwoProc
Honored Contributor

Re: Send output to an Xwindow Virtual Desktop

OK, I'm willing to try - what's Xnest and where do I get it? I've looked on my server and I don't see it.

Thanks.
We are the people our parents warned us about --Jimmy Buffett
Alex Glennie
Honored Contributor

Re: Send output to an Xwindow Virtual Desktop

John,

Send me an email (see my forum profile for the address) I can provide you with the binary .... fyi Xnest is a nested Xserver (not HP s/w) basically acts like Reflections X on unix.

Alternatively you can search say via google I'm sure you'll find it ...

I'm not 100% convinced it's exactly what you are after but then again the switch program wasn't ideal I suspect either.

TwoProc
Honored Contributor

Re: Send output to an Xwindow Virtual Desktop

Great, I searched google and found it thanks for the input.

John
We are the people our parents warned us about --Jimmy Buffett
TwoProc
Honored Contributor

Re: Send output to an Xwindow Virtual Desktop

See above
We are the people our parents warned us about --Jimmy Buffett