LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Script to run "CTRL+ALT+BACKSPACE" (http://www.linuxquestions.org/questions/linux-general-1/script-to-run-ctrl-alt-backspace-549896/)

sadarax 04-29-2007 07: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 07:08 AM

killall X|kdm|gdm|xdm ?

rob.rice 04-29-2007 03: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 04:05 PM

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

#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));
      exit(1);
  }

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

  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);
  XCloseDisplay(display);
  return 0;
}

Exercise it with caution !


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