View Single Post
Old 01-10-2014, 04:34 PM   #1
peterhey
Member
peterhey can grip it by the huskpeterhey can grip it by the huskpeterhey can grip it by the huskpeterhey can grip it by the huskpeterhey can grip it by the huskpeterhey can grip it by the huskpeterhey can grip it by the huskpeterhey can grip it by the huskpeterhey can grip it by the huskpeterhey can grip it by the huskpeterhey can grip it by the husk
 
Posts: 21
Karma: 141126
Join Date: Dec 2013
Device: touch
Launch applications by gestures + graphic notes

The touch device supports gestures. We can use it also to launch applications.

Define your applications in case section.
Code:
# gesture file

#!/bin/sh

# we have 9 gestures
#
# first four
# pinch + up
# pinch + down
# pinch + left
# pinch + right
#
# second four
# stretch + up
# stretch + down
# stretch + left
# stretch + right
#
# pinch + down + up    - emergency assistance :)

usleep 1500000	# -  how long wait for end of gesture

run=`/usr/bin/awk '
BEGIN {a=0; b=0; c=0} {
if ($1==7) a=1 					# -  7 can occur many times
if ($1==3 && c==1) print "9" 
if ($1==4 && a==1) c=1
if ($1==8) b=1 					# -  8 can occur many times
}
END{
if ($1==3 && a==1 && c==0) print "1"
if ($1==4 && c==1) print "2"
if ($1==5 && a==1) print "3"
if ($1==6 && a==1) print "4"
if ($1==3 && b==1) print "5"
if ($1==4 && b==1) print "6" 
if ($1==5 && b==1) print "7"
if ($1==6 && b==1) print "8"
}' /tmp/gesture`

# 3 - up; 4 - down; 5 - left; 6 - right; 7 - pinch; 8 - stretch

if [ "$run" != "" ]; then
	aplay ./ding1.wav		# beep from chess
fi	

case "$run" in

	# -  pinch + up
	1)
	/mnt/us/bin/dict &;;

	# -  pinch + down
	2)
	if [ $(pidof leafpad) ]; then killall leafpad	# -  when it's running, kill it
	else /mnt/us/extensions/leafpad/bin/leafpad.sh &
	fi;;
	
	# -  pinch + left
	3)
	/mnt/us/extensions/kterm/bin/kterm.sh 1 &;;
	
	# -  pinch + right
	4)
	/mnt/us/extensions/kterm/bin/kterm.sh &;;

	# -  stretch + up
	5)
	/mnt/us/bin/v+ &;;
	
	# -  stretch + down
	6)
	/mnt/us/bin/v- &;;

	# -  stretch + left
	7)
	if [ $(pidof koreader.sh) ]; then killall koreader-base		# - It captures and disables gestures in 'messages' file. Need switch to system events, or so.
	else /mnt/us/koreader/koreader.sh /mnt/us/documents &
	fi;;
	
	# -  stretch + right
	8)
	/mnt/us/extensions/midori/runit.sh &;;

	# -  pinch + down + up
	9)
	restart framework &;;
esac

/bin/rm /tmp/gesture.lock
echo "" > /tmp/gesture
It works with Launcher http://yifan.lu/p/kindlelauncher/
I don't know why it isn't working with KUAL. Some hints?

In this way we can open another application without closing app which we currently use. Or launch any script when the lack of access to menu. Many possibilities.

But it's far from perfect. One issue, framework hangs up when book and kterm are opened simultanously. Free to develop.

It starts automaticly after reboot when is on. Off state disable it.

Tested at K5 touch only. Autostart could bring some issue. So, if you have doubts, wait for feedback from other users.
Attached Files
File Type: zip gestures_v1.0.zip (12.5 KB, 203 views)

Last edited by peterhey; 01-13-2014 at 12:33 PM.
peterhey is offline   Reply With Quote