LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Send keys to an X app & diconnect an X session (https://www.linuxquestions.org/questions/linux-software-2/send-keys-to-an-x-app-and-diconnect-an-x-session-393281/)

Spoonman 12-15-2005 02:57 PM

Send keys to an X app & diconnect an X session
 
I have an application that I generally leave running on my machine, and would like it to shutdown gracefully if possible when the machine shuts down. If I'm not there, and the UPS shuts the machine down, it doesn't shutdown gracefully unless I hit Ctrl-Z. Is there a way I can script sending Ctrl-Z (or any keystroke for future reference) to an X-based application? Sorta like Send Keyboard Keys for Windows at vsisoftware dot com (I can't post URLs yet).

Second, is there a way to disconnect from an X session, so I can reconnect from another machine? Similar to Terminal Services for Windows? I've looked at using VNC, but it's far too slow.

Thanks,
-Spoonie

titopoquito 12-16-2005 04:17 AM

Quote:

Originally Posted by Spoonman
Is there a way I can script sending Ctrl-Z (or any keystroke for future reference) to an X-based application? Sorta like Send Keyboard Keys for Windows at vsisoftware dot com (I can't post URLs yet).

You can for example use wmctrl to send applications running on X a close signal. (If you read in the manpage check the -c switch). The website: http://sweb.cz/tripie/utils/wmctrl/
Otherwise If I understand your intention right you could look at the kill command and it's options. This doesn't not any keystroke but can shut down an application gracefully or force it to end.

Spoonman 12-18-2005 09:14 AM

The app is vmware, and I have a virtual machine running on my primary server all the time. What I want to do is send it the ctrl-z before the app closes (and wait an appropriate amount of time) so it puts the server in hibernation rather than just letting it be "switched off". wmctrl won't do the job by itself 'cause it just kills the app. However, at the bottom of that page is an app called "gnee" that might do the job. It can't grab focus, it appears, so I'd use wmctrl to do that first, then send the keystroke. I'm still in the process of rebuilding my server, at which point I'll post a reply so the right answer's here for others (I've been searching for this for some time).

-S


All times are GMT -5. The time now is 08:18 AM.