Run CommandReader "/path/to/x-touch .5 2 3 1 @" "touch"
our first alpha code craft of a dwell... that works quite well... in chromium overridden... but that's ok... lol
- - - - - - -
#!/bin/sh
x_touch ()
# usage: [ dwell=0 [ touch3=0 [ touch2=0
# [ show=0|1|2|3|4|5 [xchar=@] ]
# ] ] ]
# dwell: timeout in seconds,
# disable with: 0 | [0].0
# touch3: touched fingers count for click 3,
# disable with: 0, sugested: 2
# touch2: touched fingers count for click 2,
# disable with: 0, sugested: 3
# show: output population, disable with: 0
# 0 ) quiet
# @ stdout:
# 1 ) xmobar: gold, orangered, transparent
# 2 ) events: TIMING, LOCKED, UNLOCKED
# 3 ) extra: + KILLED
# @ stderr:
# 4 ) show: + EVENT lines
# >=5 ) debug: + event descriptions
# xchar: string to use in xmobar mode
{ xinput test-xi2 --root | {
local dwell=yes d=${1:-0} \
t3=${2:-0} t2=${3:-0} s=${4:-1} x=${5:-X} ;
[ $d = 0 -o $d = .0 -o $d = 0.0 ] &&
{ d=0 ; dwell=no ; }
[ $d = 0 -a $t3 -eq 0 -a $t2 -eq 0 ] && {
echo 'Nothing to do... :(' >&2 ;
return 1 ;
} ;
local last_event=none color= ;
event () { [ $s -gt 0 -a "$*" != "$last_event" ] && {
if [ $s -eq 1 ] ; then
local color=
case $1 in
T* ) color=darkred ;;
L* )
case $2 in
2 ) color=gold ;;
3 ) if [ "$3" = dwell ] ;
then color=limegreen ;
else color=green ;
fi ;
esac ;
;;
U* ) color=#222222 ;;
esac;
echo "
else echo $* ;
fi ;
last_event="$*";
} ; } ;
show () { [ $s -gt 3 ] && echo "$@" >&2 ; } ;
local line=
while read line ; do
case "$line" in
*TouchScreen*slave*pointer* )
show $line ;
break ;
esac ;
done ;
to_after_empty ()
{
local line ;
while read line ; do
[ -z "$line" ] && break ; done ;
} ;
to_after_empty ;
click () { /usr/bin/xdotool click ${1:-3} ; } ;
local dwelling=yes \
LOCK=/tmp/x-touch-dwell.ing"$DISPLAY" \
lock= touched=0 ;
thouched ()
{
touched=$(( $touched + 1 )) ;
[ $touched -eq 1 -a $dwell = yes ] && {
dwelling=yes ;
{
sleep $d ;
touch $LOCK ;
event LOCKED 3 dwell ;
} &
pid=$! ;
event TIMIMG $d @ $pid
} ;
} ;
local dwelling=no ;
undwell () # click?
{
[ $dwelling = yes ] && { # dwelling?
dwelling=no ;
if [ -e $LOCK ] ; then # locked?
rm $LOCK ;
[ "$1" = yes ] && # click?
click ;
else
kill $pid ;
[ $s -gt 2 ] && event KILLED $pid ;
fi ;
} ;
} ;
unlock () # click?
{
touched=0 ;
[ $dwell = yes ] && undwell $1 ;
event UNLOCKED;
} ;
# delete any previous lock
[ -e $LOCK ] && rm $LOCK ;
# for xmonad: first event
if [ $s -eq 1 ] ; then
# sleep 1s ;
event UNLOCKED ;
else last_event=UNLOCKED ;
fi;
local line= showing=yes touching=0 ;
while read line ; do
case "$line" in EVENT* )
showing=no
case "$line" in
# *22* ) show $line ;; # RawTouchBegin
*18* ) # TouchBegin
show $line $touching touching ;
touching=$(( $touching + 1 )) ;
thouched ;
case $touched in
$t3 ) undwell ; event LOCKED 3 ;;
$t2 ) undwell ; event LOCKED 2 ;;
* ) [ $touched -gt $t3 -o $touched -gt $t2 ] &&
event UNLOCKED ;;
esac ;
showing=yes ;
;;
# *24* ) show $line ;; # RawTouchEnd
*20* ) # TouchEnd
show $line $touching touching ;
touching=$(( $touching - 1 )) ;
if [ $touching -eq 0 ] ; then
case $touched in
1 ) unlock yes ;
continue ;
;;
$t3 ) click ;;
$t2 ) click 2 ;;
esac ;
unlock ;
fi ;
showing=yes ;
;;
*19* ) # TouchUpdate
show $line $touching touching ;
unlock ;
;;
*Touch* )
show $line ;
showing=yes ;
esac ;
;;
* ) [ $showing = yes -a $s -gt 4 ] &&
show ::\\t"$line" ;
esac ;
done ;
} ; } ;
x_touch "$@" ;