control hotkeys in gtk from a bash script?

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

control hotkeys in gtk from a bash script?

#1 Post by zigbert »

I found this script that return keystroke value. It works great when running it in a terminal..... But......

Is it possible to start it from gtkdialog code in a way that the keystrokes responds from an active gui window? When I try, the key-script gets its own pid, and it seems to me that my keystrokes is out of reach of gtkdialog.


Thanks
Sigmund

Code: Select all

#!/bin/bash

while IFS='^B' read -sn1 a; do # ^B is Control B
	k=`perl -e "printf('%d',ord('$a'));"`
	if (( k == 27 )) ; then
		while IFS='' read -sn1 -t1 c; do
			l=`perl -e "printf('%d',ord('$c'));"`
			k="$k $l"
			grep "^$k 0 " $0 > /dev/null
			if (( $? == 0 )) ; then
				break
			fi
		done
	fi
#	echo $k
	gxmessage $k
	grep "^$k 0 " $0
done
# never gets here
exit

27 79 70 0 end
27 79 72 0 home
27 79 81 0 f2
27 79 82 0 f3
27 79 83 0 f4
27 91 49 53 126 0 f5
27 91 49 55 126 0 f6
27 91 49 56 126 0 f7
27 91 49 57 126 0 f8
27 91 50 48 126 0 f9
27 91 50 49 126 0 f10
27 91 50 52 126 0 f12
27 91 50 126 0 insert
27 91 51 126 0 delete
27 91 49 126 0 home
27 91 52 126 0 end
27 91 53 126 0 pageUp
27 91 54 126 0 pageDown
27 91 65 0 up
27 91 66 0 down
27 91 67 0 right
27 91 68 0 left
27 91 49 59 53 67 0 ctl-right
27 91 49 59 53 68 0 ctl-left
27 91 49 59 53 65 0 ctl-up
27 91 49 59 53 66 0 ctl-down
27 91 69 0 keypad-five
9 0 tab
33 0 bang
35 0 pound
36 0 dollarSign
37 0 percent
38 0 ampersand
40 0 openParen

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#2 Post by Karl Godt »

I could think of somethink like

<entry>
<variable>Entry</variable>
<input>cat /tmp/TEMPFILE</input>
</entry>
<action>
./FILE</action>
--------------------------------------
FILE
#!/bin/bash

CODE to get KEY

echo $k > /tmp/TEMPFILE
--------------------------------------
<action>cat /tmp/TEMPFILE</action>
<action>refresh:Entry</action>


I started to dislike the rubbering of the parent window and added
a " & "
<action>./FILE &</action>
and a
<hbox>
<button><input file stock=\"gtk-refresh\"></input><label>REFRESH
Files</label>
<action type=\"clear\">Entry</action>
<action>Refresh:Entry</action>
<action type=\"clear\">Entry3</action>
<action>Refresh:Entry3</action>
</button>

so the user must hit it to show the changed entry ....

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#3 Post by technosaurus »

there are a lot of keyloggers (most lighter than perl) ... then you could clear the log file and use tail -n [# of bytes]
but some languages have different number of bytes and the Esc key and others are doubles
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#4 Post by zigbert »

technosaurus wrote:then you could clear the log file and use tail -n [# of bytes]
Great answer, it could work. Do you know where to find a keylogger without perl that won't add new dependencies to Puppy. At least not something big.


Thank you
Sigmund

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#5 Post by seaside »

zigbert wrote:
technosaurus wrote:then you could clear the log file and use tail -n [# of bytes]
Great answer, it could work. Do you know where to find a keylogger without perl that won't add new dependencies to Puppy. At least not something big.


Thank you
Sigmund
zigbert,

I'm not sure about dependencies, but Logkeys apparently runs on Ubuntu Lucid and the latest can be found here-
http://code.google.com/p/logkeys/

It requires compiling and I've never tried it, but it seems better than some of the other keyloggers.

Regards,
s

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#6 Post by jpeps »

Why is using Perl an issue? It's already in base:

Code: Select all

#!/usr/bin/perl
$key="@ARGV";
print ord($key);

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#7 Post by seaside »

jpeps wrote:Why is using Perl an issue? It's already in base:

Code: Select all

#!/usr/bin/perl
$key="@ARGV";
print ord($key);
jpeps,

I agree and I've just posted a 300k keylogger (logkeys-0.1.0.pet) here-
http://murga-linux.com/puppy/viewtopic. ... 764#487764
which would be a bit of overkill.....

Regards,
s
(Logkeys does work rather well, however...)

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#8 Post by technosaurus »

I sometimes forget that perl in base is slightly stripped while the rest of the modules are in the devx ... I nearly always have the devx merged with my main sfs & it made for a confounding bug hunt in a script
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

Post Reply