View Single Post
Old 01-13-2014, 10:14 AM   #2
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
Works with KUAL. The reason was '&' with launching script in 'menu.json'

Beneath I showed how easy can add new dedicated gestures. Another gestures are intended for 'Graphic Notes', based on native 'Xtestlab126'. To start it, use pinch + up gesture.

Code:
#!/bin/sh
######################
# Gestures v1.1
######################

# we have 10 gestures + 10 dedicated for app
#
# first four
# pinch + up
# pinch + down
# pinch + left
# pinch + right
#
# second four
# stretch + up
# stretch + down
# stretch + left
# stretch + right
#
# long tap
# pinch + down + up    - emergency assistance :)


usleep 1100000	# -  how long wait for end of gesture

if [ $(pidof xtestlab126 | wc -w) == "1" ]; then	changemode=10	# set 'changemode' for particular app
else							changemode=0
fi

#if [ $(pidof app | wc -w) == "1" ]; then	changemode=20	# set 'changemode' for particular app
#else						changemode=0
#fi

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

run=`/usr/bin/awk -v ch=$changemode '
BEGIN {pinch=0; stretch=0; third=0}
{
	if ($1==7) pinch=1 					# -  7 can occur many times
	if ($1==3 && third==1) print 999+ch 
	if ($1==4 && pinch==1) third=1
	if ($1==8) stretch=1				# -  8 can occur many times
}
END{
	if (pinch==1){
		if ($1==3 && third==0) print 1+ch ;
		if ($1==5) print 3+ch ;
		if ($1==6) print 4+ch ;
	}
	if (stretch==1){
		if ($1==3) print 5+ch ;
		if ($1==4) print 6+ch ;
		if ($1==5) print 7+ch ;
		if ($1==6) print 8+ch ;
	}
	if ($1==4 && third==1) print 2+ch
	if ($1==9) print 9+ch
}' /tmp/gesture`

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

ext=/mnt/us/extensions

case "$run" in

	# -  pinch + up
	1)
	$ext/gestures/bin/graphicnotes start & 
	$ext/gestures/bin/graphickill & ;;
#	/mnt/us/bin/dict;;

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

	# -  stretch + up
	5)
	v=`/usr/bin/lipc-get-prop -i com.lab126.audio Volume`
	/usr/bin/lipc-set-prop -i com.lab126.audio Volume $(($v + 1)) ;;
	
	# -  stretch + down
	6)
	v=`/usr/bin/lipc-get-prop -i com.lab126.audio Volume`
	/usr/bin/lipc-set-prop -i com.lab126.audio Volume $(($v - 1)) ;;

	# -  stretch + left
	7)
	/mnt/us/koreader/koreader.sh /mnt/us/documents & ;;
	
	# -  stretch + right
	8)
	$ext/midori/runit.sh &;;

	# -  long tap
	9)
	;;

	# -  pinch + down + up
	999)
	restart framework &;;

	# -  xt pinch + up
	11)
	$ext/gestures/bin/graphicnotes info & ;;	

	# -  xt pinch + down
	12)
	$ext/gestures/bin/graphicnotes show & ;;	

	# -  xt pinch + left
	13)
	$ext/gestures/bin/graphicnotes next 1 & ;;	

	# -  xt pinch + right
	14)
	$ext/gestures/bin/graphicnotes prev 1 & ;;

	# -  xt stretch + up
	15)
	$ext/gestures/bin/graphicnotes next 100 & ;;

	# -  xt stretch + down
	16)
	$ext/gestures/bin/graphicnotes background & ;;	# work only in portrait background

	# -  xt stretch + left
	17)
	$ext/gestures/bin/graphicnotes next 5 & ;;

	# -  xt stretch + right
	18)
	$ext/gestures/bin/graphicnotes prev 5 & ;;

	# -  xt long tap
	19)
	$ext/gestures/bin/graphicnotes tap &
	 ;;

	# -  xt long tap
	1009)
	$ext/gestures/bin/graphicnotes review &
	 ;;

esac

/bin/rm /tmp/gesture.lock
echo "" > /tmp/gesture
You can also run 'Gestures' and 'Graphic Notes' without install in autostart.

When the 'Midori' was launched and then closed, 'Gestures' will be stopped because of 'killall tail' in 'runit.sh' - midori file. Simplest way is replace 'killall tail' on 'killall parselog'. It's example.

todo
1 nicer way to refresh
2 completly delete note
3 bypassing 4k pipe buffer, to use the location of the touch in real-time
Attached Thumbnails
Click image for larger version

Name:	1.gif
Views:	255
Size:	11.0 KB
ID:	117908   Click image for larger version

Name:	2.gif
Views:	296
Size:	7.7 KB
ID:	117909   Click image for larger version

Name:	3.gif
Views:	283
Size:	9.0 KB
ID:	117961  
Attached Files
File Type: zip gestures_v1.1_graphicnote_v1.0.zip (72.5 KB, 181 views)

Last edited by peterhey; 01-14-2014 at 02:33 PM. Reason: little update
peterhey is offline   Reply With Quote