Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Fri 29 Aug 2014, 16:28
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
How to detect a single key without using a terminal?
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [7 Posts]  
Author Message
rhadon


Joined: 27 Mar 2008
Posts: 1291
Location: Germany

PostPosted: Sat 14 Sep 2013, 04:23    Post subject:  How to detect a single key without using a terminal?  

Hi everybody,

I want to detect a single key by a script and found two possible solutions (e.g. with key = "z"):

Code:
char=''   
read -n1 char > /dev/null
if [ "$char" = "z" ] ; then
...
fi


or

Code:
stty raw -echo
char=`dd bs=1 count=1 2>/dev/null`
if [ "$char" = "z" ] ; then
...
fi
stty -raw echo


The big problem, it only works if I run the script from a terminal, which I don't want. It should run in the background.

So, is it a problem of maybe I/O redirection or am I barking up the wrong tree?

hopefully,
Rolf

_________________
Ich verwende "frugal", und das ist gut so. Wink
Raspberry Pi without Puppy? No, thanks.
Back to top
View user's profile Send private message 
greengeek

Joined: 20 Jul 2010
Posts: 2501
Location: New Zealand

PostPosted: Sat 14 Sep 2013, 05:28    Post subject:  

SFR initially used xbindkeys for a similar purpose, then changed that to using a special script (which he called "detect_key") in this topic here:
http://murga-linux.com/puppy/viewtopic.php?t=87418
Back to top
View user's profile Send private message 
rhadon


Joined: 27 Mar 2008
Posts: 1291
Location: Germany

PostPosted: Sat 14 Sep 2013, 05:46    Post subject:  

I'll take a look.

Thanks greengeek,

Rolf

_________________
Ich verwende "frugal", und das ist gut so. Wink
Raspberry Pi without Puppy? No, thanks.
Back to top
View user's profile Send private message 
Karl Godt


Joined: 20 Jun 2010
Posts: 3964
Location: Kiel,Germany

PostPosted: Sat 14 Sep 2013, 06:07    Post subject:  

Ahh, radon finally wants to make mouse trap trojans with keylogging ability Razz
Back to top
View user's profile Send private message Visit poster's website 
rhadon


Joined: 27 Mar 2008
Posts: 1291
Location: Germany

PostPosted: Sat 14 Sep 2013, 06:36    Post subject:  

Quote:
Ahh, radon finally wants to make mouse trap trojans with keylogging ability

Not exactly Karl, but near the mark Laughing

Rolf[/quote]

_________________
Ich verwende "frugal", und das ist gut so. Wink
Raspberry Pi without Puppy? No, thanks.
Back to top
View user's profile Send private message 
jamesbond

Joined: 26 Feb 2007
Posts: 2125
Location: The Blue Marble

PostPosted: Sat 14 Sep 2013, 06:57    Post subject:  

Look at here http://jamesbond3142.no-ip.org/wiki/main/files/bootmenu.gz and check the "event handling" section. You need evtest for this to work.

cheers!

_________________
Fatdog64, Slacko and Puppeee user. Puppy user since 2.13.
Contributed Fatdog64 packages thread
Back to top
View user's profile Send private message 
Karl Godt


Joined: 20 Jun 2010
Posts: 3964
Location: Kiel,Germany

PostPosted: Sat 14 Sep 2013, 13:14    Post subject:  

Ha ! Finally found acpid v1 while searching for evtest .. remembered it from acpid v2 :

http://sourceforge.net/projects/acpid2/files/
http://sourceforge.net/projects/acpid2/files/evtest20081214.tar.bz2/download

Works pretty good !
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [7 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0501s ][ Queries: 12 (0.0047s) ][ GZIP on ]