-   Linux - General (
-   -   Script to run "CTRL+ALT+BACKSPACE" (

sadarax 04-29-2007 08:03 AM

Script to run "CTRL+ALT+BACKSPACE"
What command exactly is run when you press the keys "CTRL+ALT+BACKSPACE"? I have some times where I need to have a script restart my X-session. As a user I can press CTRL+ALT+BACKSPACE any time I want and restart my graphic session, but I do know how to do this from a script. Can anyone tell me how?

General Failure 04-29-2007 08:08 AM

killall X|kdm|gdm|xdm ?

rob.rice 04-29-2007 04:08 PM

it is built into X itself
I'm not sure but a killall X then maybe you would need to run KDM , GDM or XDM
then what ever started started X or it may respwan on it's owen
try a " killall X "from an xterm and what happens

jlliagre 04-29-2007 05:05 PM

Here is a small C program that does the real Control-Alt-Backspace thing:

#include <stdlib.h>
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/extensions/XTest.h>
#include <X11/keysym.h>

int main(int argc, char **argv)
  Display *display;
  int foo;

  if((display=XOpenDisplay(NULL)) == NULL)
      fprintf(stderr, "%s: can't open %s\n", argv[0], XDisplayName(NULL));

  if(XTestQueryExtension(display, &foo, &foo, &foo, &foo) == False)
      fprintf(stderr,"XTEST extension missing\n");

  XTestFakeKeyEvent(display, XKeysymToKeycode(display, XK_Control_L), True, CurrentTime);
  XTestFakeKeyEvent(display, XKeysymToKeycode(display, XK_Alt_L), True, CurrentTime);
  XTestFakeKeyEvent(display, XKeysymToKeycode(display, XK_BackSpace), True, CurrentTime);
  return 0;

Exercise it with caution !

All times are GMT -5. The time now is 06:23 AM.