LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-29-2007, 07:03 AM   #1
sadarax
Member
 
Registered: Sep 2005
Distribution: Ubuntu
Posts: 252

Rep: Reputation: 30
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?
 
Old 04-29-2007, 07:08 AM   #2
General Failure
Member
 
Registered: Jan 2007
Location: Germany
Distribution: Slackware 13.37
Posts: 387

Rep: Reputation: 37
killall X|kdm|gdm|xdm ?
 
Old 04-29-2007, 03:08 PM   #3
rob.rice
Senior Member
 
Registered: Apr 2004
Distribution: slack what ever
Posts: 1,076

Rep: Reputation: 205Reputation: 205Reputation: 205
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
 
Old 04-29-2007, 04:05 PM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
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 !
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"GRUB _" when booting, nothing but "ctrl+alt+del" functions rabidpencil Linux - Newbie 15 08-08-2006 10:20 AM
"Alt GR" produces Keycode for "CTRL" as well Bigpet Linux - Software 5 04-09-2006 04:31 AM
dark screen when pressing Ctrl + Alt + Backspace or Ctrl + Alt F1-F6 in Gnome or KDE trinoo Slackware 5 01-28-2005 08:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration