Monitor keypresses without focus?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Monitor keypresses without focus?
# 1  
Old 02-06-2017
Monitor keypresses without focus?

Hi all,
I'm new to Linux, been at it a couple weeks. I have written a script that basically acts as a watchdog to ping a server on a set interval, make sure chromium-browser is running, and a couple other things (it displays data via web browser). I'd like to make it stop the script when I hit Esc. I have figured out how to do that except for when chrome is in the foreground. Is there any way I can get around this with scripting? Any help appreciated!

Oh, using Fedora 25, Xwayland disabled(using Xorg), if that matters (my understanding of the various components in windowing is still murky)
# 2  
Old 02-06-2017
A shell script has little to no control of where it receives input from unless you're going to try opening up raw keyboard devices yourself. And then you'll end up having to translate the raw keycodes.
# 3  
Old 02-06-2017
Also, probably should have stated the script itself starts chromium-browser

---------- Post updated at 02:57 PM ---------- Previous update was at 02:56 PM ----------

Quote:
Originally Posted by Corona688
A shell script has little to no control of where it receives input from unless you're going to try opening up raw keyboard devices yourself. And then you'll end up having to translate the raw keycodes.
I was afraid of that. I was hoping there was some way thru X that I could redirect input or something similar. I need absolutely no interaction on the chromium-browser window itself, it's view-only.
# 4  
Old 02-06-2017
To add to Corona688's reply...

I don't know the particulars for Fedora but Ubuntu's events sit in /dev/input/ as event6 in my case.

It will produce a BINARY _string_ that you will have to decode to get the required character(s).

This is a simple command that will monitor, (using MY /dev/input/event6 ):-
Code:
sudo cat /dev/input/event6

Note the "sudo" because you might need elevated access to read the device.

EDIT:
You could try xinput list keyboard it might just work...

Last edited by wisecracker; 02-06-2017 at 05:46 PM.. Reason: See above...
# 5  
Old 02-07-2017
Thanks, I'll see where I can get with that. Hopefully I will get to poke around and try it today.
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Infrastructure Monitoring

Searching for Saas Monitor service which monitor my servers which are sitting in different providers

Sorry if this is the wrong forum Searching for Saas Monitor service which monitor my servers which are sitting in different providers . This monitor tool will take as less CPU as possible , and will send info about the server to main Dashboard. The info I need is CPU / RAM / my servers status (... (1 Reply)
Discussion started by: umen
1 Replies

2. What is on Your Mind?

Learning System Administration: What to focus on?

In the fall I am taking courses in System Admin and Networking Admin, along with Cisco classes. Sometime next year I hope to get Red Hat and CCNA certifications, then try to get some experience and a job. I am wondering what I can focus on in the meantime (and in my spare time) that will... (1 Reply)
Discussion started by: ScottLew
1 Replies

3. UNIX for Dummies Questions & Answers

Display command stealing focus

Please Help a Newbie, I'm using the display command to post a picture of several configurations for a machine operator to choose from. The Issue I have is when I display the image the displayed image steals focus from my bash window. The operator then has to re-select the window to answer the... (1 Reply)
Discussion started by: BitBoy
1 Replies

4. UNIX for Dummies Questions & Answers

Starting a program without it stealing focus

Hi all I have a java program I'm starting in Mac os from the terminal using the command java -Djava.library.path=/Users/me/Desktop/Cfiles/DynamicCTGLayout/build/Release -jar However, when I do this, my current program I'm using becomes "deselected" and the java program's GUI becomes... (2 Replies)
Discussion started by: WhiteTiger
2 Replies

5. Programming

Focus on already running process by giving ID or name?

Is this possible to be done with C++ ? I am working on Qt Creator by I didn't find any working setFocus function or something. Can you help me a bit? Thank you. The program actually checks if there is a process of this program already running and if there is it exits. I want to make it focus on... (2 Replies)
Discussion started by: hakermania
2 Replies

6. Shell Programming and Scripting

how to send a key to a windows without focus

Hi, i found xte and xdotool for sending some keys to windowed applications but they need to have the focus on it. Can someone say me if i can do the same but wihtout focusing the window i want to type something ? edit: xreplay (0 Replies)
Discussion started by: linked
0 Replies

7. UNIX for Dummies Questions & Answers

Gnome focus

Hello all, Is there a way to make sawfish window manager focus on a gui when you click it but not make it raise to the top? I know that motif and CDE (soalris) allow you to focus with out raising the windows. THANKS (2 Replies)
Discussion started by: larry
2 Replies
Login or Register to Ask a Question