Solved

Linux/X11 Keyboard interceptor

Posted on 2004-04-11
8
293 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
why should double free() crash? 7 30
yum update fails 11 372
what does daemon command do in linux 3 69
incorrect file reading in bash 7 49
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now