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 Sat 25 Oct 2014, 23:43
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 Posts_count  
Author Message
rhadon


Joined: 27 Mar 2008
Posts: 1293
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: 2596
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: 1293
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: 3972
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_website 
rhadon


Joined: 27 Mar 2008
Posts: 1293
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: 2230
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: 3972
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_website 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


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