Solved

Linux/X11 Keyboard interceptor

Posted on 2004-04-11
8
300 Views
Last Modified: 2010-04-21
Hi,

for some twisted reason, i need to write a program that locks any input from keyboard/mouse for other than my application.
I already tried, with limited success, with SDL WM_GrabInput, but that does not grab key combinations like CTRL+ALT+BACKSPACE or CTRL+ALT+F2.

What i need is advice, and possibly C (im programming in FPC for this) code to accomplish a total lockout from the keyboard, in order to prevent X shutdown, or console switching.
I dont expect answers or comments like "use XDM" or "disable the TTYs and run in X runlevel", since that's not what im looking for (actually might be the worst case scenario if there's no other solution to my problem".

Thanks.
0
Comment
Question by:KiCk
  • 3
  • 2
8 Comments
 
LVL 9

Expert Comment

by:Alf666
ID: 10804493
Get the source of the "xev" utility.

It's a small X11 utility that allows you to grab any X11 events (including key presses/releases).
It's a very old X11 stuff which is a perfect example of what you are trying to achieve. It uses native X11 calls.
0
 
LVL 9

Expert Comment

by:Alf666
ID: 10804500
0
 
LVL 2

Expert Comment

by:astrand
ID: 10893157
To prevent the Xserver from ending / switching to VTs on CTRL+ALT+BACKSPACE / CTRL+ALT+F2, you need to change you XF86Config. Activate options DontZoom and DontZap.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:KiCk
ID: 10907005
DontZap does not prevent console switching.
DontZoom prevents the user from switching screen resolution, which i actually need :)

As for xev, that captures the events from within the window, not from all windows.
0
 
LVL 2

Accepted Solution

by:
astrand earned 500 total points
ID: 10907454
> DontZap does not prevent console switching.0

Ah, sorry. DontVTSwitch is what you want in this case.

As for listen to all events, try the program ftp://ftp.lysator.liu.se/pub/misc/evcnt-1.0.tar.gz.
0
 
LVL 9

Expert Comment

by:Alf666
ID: 10908301
I know the xev does not get all events, but it's a good example of what can be done.
Based on that, you can do whatever you want.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
GUI development for Ubuntu 8 220
Expect & sshpass package for Solaris 10 x86 15 991
Problem to line 1 62
Linux: disable vim auto-comment 7 156
Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question