01-10-2014, 04:34 PM | #1 |
Member
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 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. Last edited by peterhey; 01-13-2014 at 12:33 PM. |
01-13-2014, 10:14 AM | #2 |
Member
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 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 Last edited by peterhey; 01-14-2014 at 02:33 PM. Reason: little update |
Advert | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Troubleshooting Kindle PW screen gestures not working | venem | Amazon Kindle | 3 | 06-19-2013 07:08 AM |
Paperwhite Gestures | Akirainblack | Kindle Developer's Corner | 4 | 11-02-2012 07:57 AM |
Paperwhite Perodicals Navigation; Gestures | weatherman | Amazon Kindle | 2 | 10-17-2012 02:55 PM |
Customizing/Adding touch gestures | ali.sattari | Kindle Developer's Corner | 2 | 04-25-2012 04:33 PM |
How to enable multitasking gestures in iOS 4.3 | rcuadro | Apple Devices | 7 | 03-18-2011 12:42 AM |