Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Mon 14 Oct 2019, 20:12
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Utilities
screen, touchscreen and touchpad rotation for tablet
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [9 Posts]  
Author Message
stemsee

Joined: 27 Jun 2013
Posts: 2483
Location: In The Way

PostPosted: Thu 01 Aug 2019, 11:19    Post subject:  screen, touchscreen and touchpad rotation for tablet  

So my tablet has a keyboard with touchpad that attaches only on one side horizontally.

My tablet also boots display orientation is upright, and this script is arranged with that in mind.

The touchpad transformations have comments to label the real transformation. So if your tablet's orientation is horizontal then swap the touchpad transformations from the functions according to your needs.

Sometimes I want the screen and touchscreen to rotate but not the touchpad.

This script does that, and by swapping the transformation matrices allows all possibilities.

Save as ytsr.

depends on xinput and yad being installed

Code:
#!/bin/sh
# yad tray screen rotation "ytsr" by stemsee
# copyright (c) 2019 Marcos M Contant
[[ "`whoami`" != "root" ]] && exec sudo -E -S ${0} "$\"" #Normal
running=`ps -e | grep ytsr | wc -l`
[[ "$running" -gt 2 ]] && exit #check if running, one instance only
export OUTPUT_CHARSET=UTF-8
mkfifo /tmp/RPIPE
exec 3<> /tmp/RPIPE
export connected=`xrandr | grep connected | cut -f1 -d' ' | head -1`
export TRANSFORM='Coordinate Transformation Matrix'
# get event number from xinput
export pad=13 #my hardware specific
export touch=14 #my hardware specific
function left (){
   xrandr --output $connected --rotate left
    xinput set-prop $touch "Evdev Axis Inversion" 1, 0
    xinput set-prop $touch "Evdev Axes Swap" 1
    xinput set-prop $pad "$TRANSFORM" -1 0 1 0 -1 1 0 0 1 #normal
   echo "icon:/usr/share/pixmaps/left.png" >/tmp/RPIPE
   echo "left" >/etc/rotate
}; export -f left
function right (){
   xrandr --output $connected --rotate right
    xinput set-prop $touch "Evdev Axis Inversion" 0, 1
    xinput set-prop $touch "Evdev Axes Swap" 1
   xinput set-prop $pad "$TRANSFORM" 1 0 0 0 1 0 0 0 1 #inverted
   echo "icon:/usr/share/pixmaps/right.png" >/tmp/RPIPE
   echo "right" >/etc/rotate
}; export -f right
function inverted (){
   xrandr --output $connected --rotate inverted
    xinput set-prop $touch "Evdev Axis Inversion" 1, 1
    xinput set-prop $touch "Evdev Axes Swap" 0
    xinput set-prop $pad  "$TRANSFORM" 0 1 0 -1 0 1 0 0 1 #left
   echo "icon:/usr/share/pixmaps/inverted.png" >/tmp/RPIPE
   echo "inverted" >/etc/rotate

}; export -f inverted
function normal (){
   xrandr --output $connected --rotate normal
    xinput set-prop $touch "Evdev Axis Inversion" 0, 0
    xinput set-prop $touch "Evdev Axes Swap" 0
   xinput set-prop $pad "$TRANSFORM" 0 -1 1 1 0 0 0 0 1 # right
   echo "icon:/usr/share/pixmaps/normal.png" >/tmp/RPIPE
   echo "normal" >/etc/rotate
}; export -f normal
function restate (){
   export state=`cat /etc/rotate`
   [[ -z "$state" ]] && state=normal
   bash -c $state
   echo "icon:/usr/share/pixmaps/$state.png" >/tmp/RPIPE
}; export -f restate
bash -c restate
yad --notification --listen --text="Rotate Screen" --tray-icon="/usr/share/pixmaps/$state.png" --command="bash -c normal" --menu="Rotate Left!bash -c left!/usr/share/pixmaps/left.png|Rotate right!bash -c right!/usr/share/pixmaps/right.png|Rotate Inverted!bash -c inverted!/usr/share/pixmaps/inverted.png|" <&3
Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 2483
Location: In The Way

PostPosted: Sun 04 Aug 2019, 09:06    Post subject:  

I have added the ability to rotate the touchpad independently. I will add the same for the display and the touchscreen, while retaining also integrated functions.
Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 2483
Location: In The Way

PostPosted: Tue 06 Aug 2019, 05:11    Post subject:  

Improving all the time!

The script now auto-detects the touchpad and touchscreen devices.

There is a swap function in case the devices are labelled incorrectly.

The menu has individual rotation options for display, touchpad and touchscreen/digitizer.

/etc/rotate stores last set values for persistence at next boot.
Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 2483
Location: In The Way

PostPosted: Tue 06 Aug 2019, 11:15    Post subject:  

Latest script with new features
Code:
#!/bin/sh
# yad tray screen rotation "ytsr" b stemsee
# copyright (c) 2019 Marcos M Contant
[[ "`whoami`" != "root" ]] && exec sudo -E -S ${0} "$\"" #Normal
running=`ps -e | grep rotate | wc -l`
[[ "$running" -gt 2 ]] && exit #check if running, one instance only
export OUTPUT_CHARSET=UTF-8
[[ ! -p /tmp/RPIPE ]] && mkfifo /tmp/RPIPE
exec 3<> /tmp/RPIPE
export connected=`xrandr | grep connected | cut -f1 -d' ' | head -1`
export TRANSFORM='Coordinate Transformation Matrix'
# get event number from xinput
export touch=`xinput | grep -i touch |  cut -f2 -d'=' | awk '{print $1}' | head -1`
export pad=`xinput | grep -i touch |  cut -f2 -d'=' | awk '{print $1}' | tail -1`

function swapdevfn (){
   export pad=`xinput | grep -i touch |  cut -f2 -d'=' | awk '{print $1}' | head -1`
   export touch=`xinput | grep -i touch |  cut -f2 -d'=' | awk '{print $1}' | tail -1`
}; export swapdevfn
function pormal (){
   xinput set-prop $pad "$TRANSFORM" 1 0 0 0 1 0 0 0 1
   echo "normal" >/etc/rotatep
}; export -f pormal
function pight (){
    xinput set-prop $pad "$TRANSFORM" 0 1 0 -1 0 1 0 0 1
   echo "pight" >/etc/rotatep
}; export -f pight
function perted (){
    xinput set-prop $pad "$TRANSFORM" -1 0 1 0 -1 1 0 0 1
    echo "perted" >/etc/rotatep
}; export -f perted
function peft (){
   xinput set-prop $pad "$TRANSFORM" 0 -1 1 1 0 0 0 0 1
   echo "peft" >/etc/rotatep
}; export -f peft
function chorm (){
    xinput set-prop $touch "Evdev Axis Inversion" 0, 0
    xinput set-prop $touch "Evdev Axes Swap" 0
    echo "normal" >/etc/rotatet
}; export -f chorm
function chight (){
    xinput set-prop $touch "Evdev Axis Inversion" 0, 1
    xinput set-prop $touch "Evdev Axes Swap" 1
    echo "chight" >/etc/rotatet
}; export -f chight
function chited (){
    xinput set-prop $touch "Evdev Axis Inversion" 1, 1
    xinput set-prop $touch "Evdev Axes Swap" 0
    echo "chited" >/etc/rotatet
}; export -f chited
function cheft (){
    xinput set-prop $touch "Evdev Axis Inversion" 1, 0
    xinput set-prop $touch "Evdev Axes Swap" 1
    echo "cheft" >/etc/rotatet
}; export -f cheft
function dimal (){
   xrandr --output $connected --rotate normal
   echo "dimal" >/etc/rotated
}; export -f dimal
function dight (){
   xrandr --output $connected --rotate right
   echo "dight" >/etc/rotated
}; export -f dight
function diserted (){
   xrandr --output $connected --rotate inverted
   echo "diserted" >/etc/rotated
}; export -f diserted
function deft (){
   xrandr --output $connected --rotate left
   echo "deft" >/etc/rotated
}; export -f deft
function left (){
   xrandr --output $connected --rotate left
    xinput set-prop $touch "Evdev Axis Inversion" 1, 0
    xinput set-prop $touch "Evdev Axes Swap" 1
   xinput set-prop $pad "$TRANSFORM" 0 -1 1 1 0 0 0 0 1
   echo "icon:/usr/share/pixmaps/left.png" >/tmp/RPIPE
   echo "left" >/etc/rotate
}; export -f left
function right (){
   xrandr --output $connected --rotate right
    xinput set-prop $touch "Evdev Axis Inversion" 0, 1
    xinput set-prop $touch "Evdev Axes Swap" 1
    xinput set-prop $pad "$TRANSFORM" 0 1 0 -1 0 1 0 0 1
   echo "icon:/usr/share/pixmaps/right.png" >/tmp/RPIPE
   echo "right" >/etc/rotate
}; export -f right
function inverted (){
   xrandr --output $connected --rotate inverted
    xinput set-prop $touch "Evdev Axis Inversion" 1, 1
    xinput set-prop $touch "Evdev Axes Swap" 0
    xinput set-prop $pad "$TRANSFORM" -1 0 1 0 -1 1 0 0 1
   echo "icon:/usr/share/pixmaps/inverted.png" >/tmp/RPIPE
   echo "inverted" >/etc/rotate
}; export -f inverted
function normal (){
   xrandr --output $connected --rotate normal
    xinput set-prop $touch "Evdev Axis Inversion" 0, 0
    xinput set-prop $touch "Evdev Axes Swap" 0
    xinput set-prop $pad "$TRANSFORM" 1 0 0 0 1 0 0 0 1
   echo "icon:/usr/share/pixmaps/normal.png" >/tmp/RPIPE
   echo "normal" >/etc/rotate
}; export -f normal
function restate (){
   state=`cat /etc/rotate`
   [[ -z "$state" ]] && state=normal
   bash -c $state   
   echo "icon:/usr/share/pixmaps/$state.png" >/tmp/RPIPE
}; export -f restate
bash -c restate
for i in /etc/rotate /etc/rotatet /etc/rotated /etc/rotatep
do
   bash -c `cat "$i"`
done
yad --notification --listen \
--text="Rotate Screen" \
--tray-icon="/usr/share/pixmaps/normal.png" \
--command="bash -c normal" \
--menu="Rotate Left!bash -c left!/usr/share/pixmaps/left.png\
|Rotate right!bash -c right!/usr/share/pixmaps/right.png\
|Rotate Inverted!bash -c inverted!/usr/share/pixmaps/inverted.png\
|Rotate pad Left!bash -c peft!/usr/share/pixmaps/left.png\
|Rotate pad right!bash -c pight!/usr/share/pixmaps/right.png\
|Rotate pad Inverted!bash -c perted!/usr/share/pixmaps/inverted.png\
|Rotate pad normal!bash -c pormal!/usr/share/pixmaps/normal.png\
|Rotate touch Left!bash -c cheft!/usr/share/pixmaps/left.png\
|Rotate touch right!bash -c chight!/usr/share/pixmaps/right.png\
|Rotate touch Inverted!bash -c chited!/usr/share/pixmaps/inverted.png\
|Rotate touch normal!bash -c chorm!/usr/share/pixmaps/normal.png\
|Rotate display Left!bash -c deft!/usr/share/pixmaps/left.png\
|Rotate display right!bash -c dight!/usr/share/pixmaps/right.png\
|Rotate display Inverted!bash -c diserted!/usr/share/pixmaps/inverted.png\
|Rotate display normal!bash -c dimal!/usr/share/pixmaps/normal.png\
|Swap touch pad/screen event!bash -c swapdevfn!gtk-refresh" <&3
Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 2483
Location: In The Way

PostPosted: Sat 10 Aug 2019, 04:04    Post subject:  

colour coded menu
rotaemnu.png
 Description   
 Filesize   41.3 KB
 Viewed   126 Time(s)

rotaemnu.png

Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 2483
Location: In The Way

PostPosted: Wed 04 Sep 2019, 23:33    Post subject:  

Well I know this is simplistic. What it should be doing is parsing udevadm info to identify the touchscreen and touchpad. But I noticed that one could also use the events in /sys/class/input/(mouse[0-2] etc with xinput. or simply let the user enter the event numbers after looking at xinput output. Or a udev rule, which requires the same in depth parsing of udevadm info/db.

Oh well.
Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 2483
Location: In The Way

PostPosted: Sat 07 Sep 2019, 22:59    Post subject:  

Compromise....user must identify from the xinput info.

event numbers are stored in /etc/rotate_events
last rotation is stored in /etc/rotate

still a few icon display bugs to sort out

Code:
#!/bin/sh
# yad tray screen rotation "ytsr" b stemsee
# copyright (c) 2019 Marcos M Contant
# version 2.0
[[ "$1" == reset ]] && rm -f /etc/rotate_events
[[ "`whoami`" != "root" ]] && exec sudo -E -S ${0} "$\"" #Normal
running=`ps -e | grep rotate | wc -l`
[[ "$running" -gt 2 ]] && exit #check if running, one instance only
export OUTPUT_CHARSET=UTF-8
export keg="yad xinput udevadm"
# check dependencies....use xmessage in case no yad
for i in $keg
do
not=`busybox which $i`
[[ -z "$not" ]] && echo "$i" >> /tmp/missdeps
done
missing=`cat /tmp/missdeps`
[[ ! -z "$missing" ]] && xmessage -center "Without these missing dependencies
$missing

- YTSR may not be fully functional

YTSR copyright (c) 2018 Marcos Contant
GPL 3.0 license applies.
Version 2.0" -fore black -back green -timeout 4

[[ -f /tmp/missdeps ]] && rm -f /tmp/missdeps && exit

[[ ! -p /tmp/RPIPE ]] && mkfifo /tmp/RPIPE
exec 3<> /tmp/RPIPE
trap 'rm -f /tmp/RPIPE' EXIT
# get event number from xinput
if [ -f /etc/rotate_events ]; then
   events=`cat /etc/rotate_events`
else
   events=$(xinput | yad --tabnum=1 --plug=$$ --text-info --geometry=800x400 &
   yad --tabnum=2 --plug=$$ --form --field="Touchscreen/digitizer event 1 id=:NUM" --field="Touchscreen/digitizer event 2 id=:NUM" --field="touchpad event 1 id=:NUM" --field="touchpad event 2 id=:NUM" &
   yad --key=$$ --paned --tab="Xinput device info" --tab"Select device event number" --width=800 --height=500 --splitter=300 --orient=verti &)
   echo "$events" >/etc/rotate_events
fi

export connected=`xrandr | grep connected | cut -f1 -d' ' | head -1`
export TRANSFORM='Coordinate Transformation Matrix'
[ ! -z "$events" ] && export touch=`echo "$events" | cut -f1 -d'|'`
[ ! -z "$events" ] && export _touch=`echo "$events" | cut -f2-d'|'`
[ ! -z "$events" ] && export pad=`echo "$events" | cut -f3-d'|'`
[ ! -z "$events" ] && export _pad=`echo "$events" | cut -f4-d'|'`
[ -f /etc/rotate ] && export state=`cat /etc/rotate`
[ ! -z "$state" ] && export CMD="bash -c '$state'"
[ ! -z "$state" ] && export ICON="/usr/share/pixmaps/$state.png"

function pormal (){
   xinput set-prop "$pad" "$TRANSFORM" 1 0 0 0 1 0 0 0 1
   echo "pormal" >/etc/rotatep
}; export -f pormal

function pight (){
    xinput set-prop "$pad" "$TRANSFORM" 0 1 0 -1 0 1 0 0 1
   echo "pight" >/etc/rotatep
}; export -f pight

function perted (){
    xinput set-prop "$pad" "$TRANSFORM" -1 0 1 0 -1 1 0 0 1
    echo "perted" >/etc/rotatep
}; export -f perted

function peft (){
   xinput set-prop "$pad" "$TRANSFORM" 0 -1 1 1 0 0 0 0 1
   echo "peft" >/etc/rotatep
}; export -f peft

function chorm (){
    xinput set-prop $touch "Evdev Axis Inversion" 0, 0
    xinput set-prop $touch "Evdev Axes Swap" 0
    echo "normal" >/etc/rotatet
}; export -f chorm

function chight (){
    xinput set-prop $touch "Evdev Axis Inversion" 0, 1
    xinput set-prop $touch "Evdev Axes Swap" 1
    echo "chight" >/etc/rotatet
}; export -f chight

function chited (){
    xinput set-prop $touch "Evdev Axis Inversion" 1, 1
    xinput set-prop $touch "Evdev Axes Swap" 0
    echo "chited" >/etc/rotatet
}; export -f chited

function cheft (){
    xinput set-prop $touch "Evdev Axis Inversion" 1, 0
    xinput set-prop $touch "Evdev Axes Swap" 1
    echo "cheft" >/etc/rotatet
}; export -f cheft

function dimal (){
   xrandr --output $connected --rotate normal
   echo "dimal" >/etc/rotated
}; export -f dimal

function dight (){
   xrandr --output $connected --rotate right
   echo "dight" >/etc/rotated
}; export -f dight

function diserted (){
   xrandr --output $connected --rotate inverted
   echo "diserted" >/etc/rotated
}; export -f diserted

function deft (){
   xrandr --output $connected --rotate left
   echo "deft" >/etc/rotated
}; export -f deft

function left (){
   xrandr --output $connected --rotate left
    xinput set-prop $touch "Evdev Axis Inversion" 1, 0
    xinput set-prop $touch "Evdev Axes Swap" 1
   xinput set-prop $pad "$TRANSFORM" 0 -1 1 1 0 0 0 0 1
   echo "icon:/usr/share/pixmaps/left.png" >/tmp/RPIPE
   echo "left" >/etc/rotate
}; export -f left

function right (){
   xrandr --output $connected --rotate right
    xinput set-prop $touch "Evdev Axis Inversion" 0, 1
    xinput set-prop $touch "Evdev Axes Swap" 1
    xinput set-prop $pad "$TRANSFORM" 0 1 0 -1 0 1 0 0 1
   echo "icon:/usr/share/pixmaps/right.png" >/tmp/RPIPE
   echo "right" >/etc/rotate
}; export -f right

function inverted (){
   xrandr --output $connected --rotate inverted
    xinput set-prop $touch "Evdev Axis Inversion" 1, 1
    xinput set-prop $touch "Evdev Axes Swap" 0
    xinput set-prop $pad "$TRANSFORM" -1 0 1 0 -1 1 0 0 1
   echo "icon:/usr/share/pixmaps/inverted.png" >/tmp/RPIPE
   echo "inverted" >/etc/rotate
}; export -f inverted

function normal (){
   xrandr --output $connected --rotate normal
    xinput set-prop $touch "Evdev Axis Inversion" 0, 0
    xinput set-prop $touch "Evdev Axes Swap" 0
    xinput set-prop $pad "$TRANSFORM" 1 0 0 0 1 0 0 0 1
   echo "icon:/usr/share/pixmaps/normal.png" >/tmp/RPIPE
   echo "normal" >/etc/rotate
}; export -f normal

function rotate_reset (){
   rm -f /etc/rotate
   rm -f /etc/rotate_events
   rm -f /etc/rotat*
}; export -f rotate_reset
sleep 2 && echo "icon:/usr/share/pixmaps/${state}.png" >/tmp/RPIPE &
bash -c `cat /etc/rotate` &
yad --notification --listen \
--text="Rotate Screen" \
--tray-icon="/usr/share/pixmaps/${state}.png" \
--command="$CMD" \
--menu="Rotate Left!bash -c left!/usr/share/pixmaps/leftr.png\
|Rotate right!bash -c right!/usr/share/pixmaps/rightr.png\
|Rotate Inverted!bash -c inverted!/usr/share/pixmaps/invertedr.png\
|Rotate pad Left!bash -c peft!/usr/share/pixmaps/lefty.png\
|Rotate pad right!bash -c pight!/usr/share/pixmaps/righty.png\
|Rotate pad Inverted!bash -c perted!/usr/share/pixmaps/invertedy.png\
|Rotate pad normal!bash -c pormal!/usr/share/pixmaps/normaly.png\
|Rotate touch Left!bash -c cheft!/usr/share/pixmaps/leftb.png\
|Rotate touch right!bash -c chight!/usr/share/pixmaps/rightb.png\
|Rotate touch Inverted!bash -c chited!/usr/share/pixmaps/invertedb.png\
|Rotate touch normal!bash -c chorm!/usr/share/pixmaps/normalb.png\
|Rotate display Left!bash -c deft!/usr/share/pixmaps/left.png\
|Rotate display right!bash -c dight!/usr/share/pixmaps/right.png\
|Rotate display Inverted!bash -c diserted!/usr/share/pixmaps/inverted.png\
|Rotate display normal!bash -c dimal!/usr/share/pixmaps/normal.png\
|Reset!bash -c rotate_reset!gtk-refresh" <&3
2019-09-08-081019_860x534_scrot.png
Description 
png

 Download 
Filename  2019-09-08-081019_860x534_scrot.png 
Filesize  45.07 KB 
Downloaded  19 Time(s) 
2019-09-08-081053_865x591_scrot.png
Description 
png

 Download 
Filename  2019-09-08-081053_865x591_scrot.png 
Filesize  125.64 KB 
Downloaded  26 Time(s) 
2019-09-08-081101_865x591_scrot.png
Description 
png

 Download 
Filename  2019-09-08-081101_865x591_scrot.png 
Filesize  134.71 KB 
Downloaded  32 Time(s) 
Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 2483
Location: In The Way

PostPosted: Tue 24 Sep 2019, 14:37    Post subject:  

I notice that my 2-in-1 has two events one for touchscreen and one for pen, On BionicDog the pen is actually the touchscreen and on fatdog the opposite. Either way I am successfully rotating each device.
Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 2483
Location: In The Way

PostPosted: Tue 24 Sep 2019, 15:15    Post subject:  

I'm using this
EDIT: this
Code:
#!/bin/sh
# yad tray screen rotation "ytsr" by stemsee
# copyright (c) 2019 Marcos M Contant
# version 2.0
[[ "$1" == reset ]] && rm -f /etc/rotate_events
[[ "`whoami`" != "root" ]] && exec sudo -E -S ${0} "$\"" #Normal
running=`ps -e | grep rotate | wc -l`
[[ "$running" -gt 2 ]] && exit #check if running, one instance only
export OUTPUT_CHARSET=UTF-8#!/bin/sh
# yad tray screen rotation "ytsr" by stemsee
# copyright (c) 2019 Marcos M Contant
# version 2.0
[[ "$1" == reset ]] && rm -f /etc/rotate_events
[[ "`whoami`" != "root" ]] && exec sudo -E -S ${0} "$\"" #Normal
running=`ps -e | grep rotate | wc -l`
[[ "$running" -gt 2 ]] && exit #check if running, one instance only
export OUTPUT_CHARSET=UTF-8
if [ -z $(busybox which gxmessage) ]; then
   MESSAGE=xmessage
else
   MESSAGE=gxmessage
fi

export keg="yad xinput udevadm"
# check dependencies....use xmessage in case no yad
for i in $keg
do
   not=`busybox which $i`
   [[ -z "$not" ]] && echo "$i" >> /tmp/missdeps
done
missing=`cat /tmp/missdeps`
[[ ! -z "$missing" ]] && $MESSAGE -center "Without these missing dependencies
$missing

- YTSR may not be fully functional

YTSR copyright (c) 2018 Marcos Contant
GPL 3.0 license applies.
Version 2.0" -fore black -back green -timeout 4
[[ -f /tmp/missdeps ]] && rm -f /tmp/missdeps && exit
export connected=`xrandr | grep connected | cut -f1 -d' ' | head -1`
export TRANSFORM='Coordinate Transformation Matrix'
[[ ! -p /tmp/RPIPE ]] && mkfifo /tmp/RPIPE
exec 3<> /tmp/RPIPE
[[ ! -p /tmp/check ]] && mkfifo /tmp/check
exec 7<> /tmp/check
# get event number from xinput
function checkfn (){
   echo -e '\f' >/tmp/check
   udevadm info -e | grep input | grep -e "event${touch}" -e "event${pad}" >/tmp/check
}; export -f checkfn

function xinputfn (){
   echo -e '\f' >/tmp/check
   xinput | grep -v Virtual >/tmp/check
}; export -f xinputfn

function listeventsfn (){
   echo -e '\f' >/tmp/check
   cat /etc/rotate_events >/tmp/check
}; export -f listeventsfn

function evntsfn (){
   events=/etc/rotate_events
   touch=`cat "$events" | cut -f2 -d'|'`
   pad=`cat "$events" | cut -f1 -d'|'`
   exec 7<> /tmp/check
   events=$(yad --tabnum=1 --plug=$$ --text-info --listen --geometry=400x400 <&7 &
   yad --tabnum=2 --plug=$$ --form --field="touchpad event id=:NUM" "$pad" --field="Touchscreen event id=:NUM" "$touch" &
   yad --key=$$ --title=Events --paned --tab="Xinput device info" --tab"Select device event number" --button="OK!gtk-ok:0" --button="Cancel!gtk-cancel:1" --button="Xinput:bash -c xinputfn" --width=600 --height=300 --splitter=260 --orient=vert &)
   [[ "$events" != "0|0|" ]] && echo "$events" >/etc/rotate_events || exit
   export pad=`echo "$events" | cut -f1 -d'|'`
   export touch=`echo "$events" | cut -f2 -d'|'`

}; export -f evntsfn

function pormal (){
    xinput set-prop "$pad" "$TRANSFORM" 1 0 0 0 1 0 0 0 1
   echo "pormal" >/etc/rotatep
}; export -f pormal

function pight (){
    xinput set-prop "$pad" "$TRANSFORM" 0 1 0 -1 0 1 0 0 1
   echo "pight" >/etc/rotatep
}; export -f pight

function perted (){
    xinput set-prop "$pad" "$TRANSFORM" -1 0 1 0 -1 1 0 0 1
    echo "perted" >/etc/rotatep
}; export -f perted

function peft (){
   xinput set-prop "$pad" "$TRANSFORM" 0 -1 1 1 0 0 0 0 1
   echo "peft" >/etc/rotatep
}; export -f peft

function chorm (){
   events=$(cat /etc/rotate_events)
   export touch=`echo "$events" | cut -f2 -d'|'`
   export pad=`echo "$events" | cut -f1 -d'|'`
   [ -z "$touch" ] && bash -c evntsfn
    xinput set-prop "$touch" "Evdev Axis Inversion" 1, 0
    xinput set-prop "$touch" "Evdev Axes Swap" 1
    echo "normal" >/etc/rotatet
}; export -f chorm

function chight (){
   events=$(cat /etc/rotate_events)
   export touch=`echo "$events" | cut -f2 -d'|'`
   export pad=`echo "$events" | cut -f1 -d'|'`
   [ -z "$touch" ] && bash -c evntsfn
    xinput set-prop "$touch" "Evdev Axis Inversion" 0, 1
    xinput set-prop "$touch" "Evdev Axes Swap" 1
    echo "chight" >/etc/rotatet
}; export -f chight

function chited (){
   events=$(cat /etc/rotate_events)
   export touch=`echo "$events" | cut -f2 -d'|'`
   export pad=`echo "$events" | cut -f1 -d'|'`
   [ -z "$touch" ] && bash -c evntsfn
    xinput set-prop "$touch" "Evdev Axis Inversion" 1, 1
    xinput set-prop "$touch" "Evdev Axes Swap" 0
    echo "chited" >/etc/rotatet
}; export -f chited

function cheft (){
   events=$(cat /etc/rotate_events)
   export touch=`echo "$events" | cut -f2 -d'|'`
   export pad=`echo "$events" | cut -f1 -d'|'`
   [ -z "$touch" ] && bash -c evntsfn
    xinput set-prop "$touch" "Evdev Axis Inversion" 1, 0
    xinput set-prop "$touch" "Evdev Axes Swap" 1
    echo "cheft" >/etc/rotatet
}; export -f cheft

function dimal (){
   xrandr --output "$connected" --rotate normal
   echo "dimal" >/etc/rotated
}; export -f dimal

function dight (){
   xrandr --output "$connected" --rotate right
   echo "dight" >/etc/rotated
}; export -f dight

function diserted (){
   xrandr --output "$connected" --rotate inverted
   echo "diserted" >/etc/rotated
}; export -f diserted

function deft (){
   xrandr --output "$connected" --rotate left
   echo "deft" >/etc/rotated
}; export -f deft

function left (){
   events=$(cat /etc/rotate_events)
   export touch=`echo "$events" | cut -f2 -d'|'`
   export pad=`echo "$events" | cut -f1 -d'|'`
   xrandr --output "$connected" --rotate left
    xinput set-prop "$touch" "Evdev Axis Inversion" 0, 1
    xinput set-prop "$touch" "Evdev Axes Swap" 1
   xinput set-prop "$pad" "$TRANSFORM" 0 -1 1 1 0 0 0 0 1
   echo "icon:/usr/share/pixmaps/leftr.png" >/tmp/RPIPE
   echo "left" >/etc/rotate
}; export -f left

function right (){
   events=$(cat /etc/rotate_events)
   export touch=`echo "$events" | cut -f2 -d'|'`
   export pad=`echo "$events" | cut -f1 -d'|'`
   xrandr --output "$connected" --rotate right
    xinput set-prop "$touch" "Evdev Axis Inversion" 0, 1
    xinput set-prop "$touch" "Evdev Axes Swap" 1
    xinput set-prop "$pad" "$TRANSFORM" 0 1 0 -1 0 1 0 0 1
   echo "icon:/usr/share/pixmaps/rightr.png" >/tmp/RPIPE
   echo "right" >/etc/rotate
}; export -f right

function inverted (){
   events=$(cat /etc/rotate_events)
   touch=`echo "$events" | cut -f2 -d'|'`
   pad=`echo "$events" | cut -f1 -d'|'`
   xrandr --output "$connected" --rotate inverted
    xinput set-prop "$touch" "Evdev Axis Inversion" 1, 1
    xinput set-prop "$touch" "Evdev Axes Swap" 0
    xinput set-prop "$pad" "$TRANSFORM" -1 0 1 0 -1 1 0 0 1
   echo "icon:/usr/share/pixmaps/invertedr.png" >/tmp/RPIPE
   echo "inverted" >/etc/rotate
}; export -f inverted

function normal (){
   events=$(cat /etc/rotate_events)
   touch=`echo "$events" | cut -f2 -d'|'`
   pad=`echo "$events" | cut -f1 -d'|'`
   [ -z "$touch" ] && bash -c eventsfn
   xrandr --output "$connected" --rotate normal
    xinput set-prop "$touch" "Evdev Axis Inversion" 0, 0
    xinput set-prop "$touch" "Evdev Axes Swap" 0
    xinput set-prop "$pad" "$TRANSFORM" 1 0 0 0 1 0 0 0 1
   echo "icon:/usr/share/pixmaps/normalr.png" >/tmp/RPIPE
   echo "normal" >/etc/rotate
}; export -f normal

function rotate_reset (){
   rm -f /etc/rotate
   rm -f /etc/rotate_events
   rm -f /etc/rotat*
}; export -f rotate_reset
   exec 7<> /tmp/check
   events=/etc/rotate_events
   export touch=`cat "$events" | cut -f2 -d'|'`
   export pad=`cat "$events" | cut -f1 -d'|'`
   events=$(xinput | yad --tabnum=1 --plug=$$ --text-info --listen --geometry=400x400 <&7 &
   yad --tabnum=2 --plug=$$ --form --field="touchpad event id=:NUM" "$pad" --field="Touchscreen event id=:NUM" "$touch" &
   yad --key=$$ --title=Events --paned --tab="Xinput device info" --tab"Select device event number" --button="OK!gtk-ok:0" --button="Xinput:bash -c xinputfn" --width=600 --height=250 --splitter=200 --orient=vert &)
   [[ "$events" != "0|0|" ]] && echo "$events" >/etc/rotate_events || exit
   export touch=`echo "$events" | cut -f2 -d'|'`
   export pad=`echo "$events" | cut -f1 -d'|'`
bash -c `cat /etc/rotate`
echo icon:"/usr/share/pixmaps/${state}.png" >/tmp/RPIPE
CMD="bash -c 'xdotool click 3'"
yad --notification --listen \
--text="Rotate Screen" \
--tray-icon="/usr/share/pixmaps/${state}.png" \
--command="bash -c 'xdotool click 3;xdotool click 3'" \
--menu="Rotate Left!bash -c left!/usr/share/pixmaps/leftr.png\
|Rotate right!bash -c right!/usr/share/pixmaps/rightr.png\
|Rotate Inverted!bash -c inverted!/usr/share/pixmaps/invertedr.png\
|Rotate pad Left!bash -c peft!/usr/share/pixmaps/lefty.png\
|Rotate pad right!bash -c pight!/usr/share/pixmaps/righty.png\
|Rotate pad Inverted!bash -c perted!/usr/share/pixmaps/invertedy.png\
|Rotate pad normal!bash -c pormal!/usr/share/pixmaps/normaly.png\
|Rotate touch Left!bash -c cheft!/usr/share/pixmaps/leftb.png\
|Rotate touch right!bash -c chight!/usr/share/pixmaps/rightb.png\
|Rotate touch Inverted!bash -c chited!/usr/share/pixmaps/invertedb.png\
|Rotate touch normal!bash -c chorm!/usr/share/pixmaps/normalb.png\
|Rotate display Left!bash -c deft!/usr/share/pixmaps/left.png\
|Rotate display right!bash -c dight!/usr/share/pixmaps/right.png\
|Rotate display Inverted!bash -c diserted!/usr/share/pixmaps/inverted.png\
|Rotate display normal!bash -c dimal!/usr/share/pixmaps/normal.png\
|Reset!bash -c rotate_reset!gtk-refresh|Events selection!bash -c evntsfn!gtk-refresh" <&3
if [ -z $(busybox which gxmessage) ]; then
   MESSAGE=xmessage
else
   MESSAGE=gxmessage
fi

export keg="yad xinput udevadm"
# check dependencies....use xmessage in case no yad
for i in $keg
do
   not=`busybox which $i`
   [[ -z "$not" ]] && echo "$i" >> /tmp/missdeps
done
missing=`cat /tmp/missdeps`
[[ ! -z "$missing" ]] && $MESSAGE -center "Without these missing dependencies
$missing

- YTSR may not be fully functional

YTSR copyright (c) 2018 Marcos Contant
GPL 3.0 license applies.
Version 2.0" -fore black -back green -timeout 4
[[ -f /tmp/missdeps ]] && rm -f /tmp/missdeps && exit
export connected=`xrandr | grep connected | cut -f1 -d' ' | head -1`
export TRANSFORM='Coordinate Transformation Matrix'
[[ ! -p /tmp/RPIPE ]] && mkfifo /tmp/RPIPE
exec 3<> /tmp/RPIPE
[[ ! -p /tmp/check ]] && mkfifo /tmp/check
exec 7<> /tmp/check
# get event number from xinput
function checkfn (){
   echo -e '\f' >/tmp/check
   udevadm info -e | grep input | grep -e "event${touch}" -e "event${pad}" >/tmp/check
}; export -f checkfn

function xinputfn (){
   echo -e '\f' >/tmp/check
   xinput | grep -v Virtual >/tmp/check
}; export -f xinputfn

function listeventsfn (){
   echo -e '\f' >/tmp/check
   cat /etc/rotate_events >/tmp/check
}; export -f listeventsfn

function evntsfn (){
   events=/etc/rotate_events
   touch=`cat "$events" | cut -f2 -d'|'`
   pad=`cat "$events" | cut -f1 -d'|'`
   exec 7<> /tmp/check
   events=$(yad --tabnum=1 --plug=$$ --text-info --listen --geometry=400x400 <&7 &
   yad --tabnum=2 --plug=$$ --form --field="Touchscreen event id=:NUM" "$touch"--field="touchpad event id=:NUM" "$pad" &
   yad --key=$$ --title=Events --paned --tab="Xinput device info" --tab"Select device event number" --button="OK!gtk-ok:0" --button="Cancel!gtk-cancel:1" --button="Xinput:bash -c xinputfn" --width=600 --height=300 --splitter=260 --orient=vert &)
   [[ "$events" != "0|0|" ]] && echo "$events" >/etc/rotate_events || exit
   export pad=`echo "$events" | cut -f1 -d'|'`
   export touch=`echo "$events" | cut -f2 -d'|'`

}; export -f evntsfn

function pormal (){
    xinput set-prop "$pad" "$TRANSFORM" 1 0 0 0 1 0 0 0 1
   echo "pormal" >/etc/rotatep
}; export -f pormal

function pight (){
    xinput set-prop "$pad" "$TRANSFORM" 0 1 0 -1 0 1 0 0 1
   echo "pight" >/etc/rotatep
}; export -f pight

function perted (){
    xinput set-prop "$pad" "$TRANSFORM" -1 0 1 0 -1 1 0 0 1
    echo "perted" >/etc/rotatep
}; export -f perted

function peft (){
   xinput set-prop "$pad" "$TRANSFORM" 0 -1 1 1 0 0 0 0 1
   echo "peft" >/etc/rotatep
}; export -f peft

function chorm (){
   events=$(cat /etc/rotate_events)
   export touch=`echo "$events" | cut -f2 -d'|'`
   export pad=`echo "$events" | cut -f1 -d'|'`
   [ -z "$touch" ] && bash -c evntsfn
    xinput set-prop "$touch" "Evdev Axis Inversion" 1, 0
    xinput set-prop "$touch" "Evdev Axes Swap" 1
    echo "normal" >/etc/rotatet
}; export -f chorm

function chight (){
   events=$(cat /etc/rotate_events)
   export touch=`echo "$events" | cut -f2 -d'|'`
   export pad=`echo "$events" | cut -f1 -d'|'`
   [ -z "$touch" ] && bash -c evntsfn
    xinput set-prop "$touch" "Evdev Axis Inversion" 0, 1
    xinput set-prop "$touch" "Evdev Axes Swap" 1
    echo "chight" >/etc/rotatet
}; export -f chight

function chited (){
   events=$(cat /etc/rotate_events)
   export touch=`echo "$events" | cut -f2 -d'|'`
   export pad=`echo "$events" | cut -f1 -d'|'`
   [ -z "$touch" ] && bash -c evntsfn
    xinput set-prop "$touch" "Evdev Axis Inversion" 1, 1
    xinput set-prop "$touch" "Evdev Axes Swap" 0
    echo "chited" >/etc/rotatet
}; export -f chited

function cheft (){
   events=$(cat /etc/rotate_events)
   export touch=`echo "$events" | cut -f2 -d'|'`
   export pad=`echo "$events" | cut -f1 -d'|'`
   [ -z "$touch" ] && bash -c evntsfn
    xinput set-prop "$touch" "Evdev Axis Inversion" 1, 0
    xinput set-prop "$touch" "Evdev Axes Swap" 1
    echo "cheft" >/etc/rotatet
}; export -f cheft

function dimal (){
   xrandr --output "$connected" --rotate normal
   echo "dimal" >/etc/rotated
}; export -f dimal

function dight (){
   xrandr --output "$connected" --rotate right
   echo "dight" >/etc/rotated
}; export -f dight

function diserted (){
   xrandr --output "$connected" --rotate inverted
   echo "diserted" >/etc/rotated
}; export -f diserted

function deft (){
   xrandr --output "$connected" --rotate left
   echo "deft" >/etc/rotated
}; export -f deft

function left (){
   events=$(cat /etc/rotate_events)
   export touch=`echo "$events" | cut -f2 -d'|'`
   export pad=`echo "$events" | cut -f1 -d'|'`
   xrandr --output "$connected" --rotate left
    xinput set-prop "$touch" "Evdev Axis Inversion" 0, 1
    xinput set-prop "$touch" "Evdev Axes Swap" 1
   xinput set-prop "$pad" "$TRANSFORM" 0 -1 1 1 0 0 0 0 1
   echo "icon:/usr/share/pixmaps/leftr.png" >/tmp/RPIPE
   echo "left" >/etc/rotate
}; export -f left

function right (){
   events=$(cat /etc/rotate_events)
   export touch=`echo "$events" | cut -f2 -d'|'`
   export pad=`echo "$events" | cut -f1 -d'|'`
   xrandr --output "$connected" --rotate right
    xinput set-prop "$touch" "Evdev Axis Inversion" 0, 1
    xinput set-prop "$touch" "Evdev Axes Swap" 1
    xinput set-prop "$pad" "$TRANSFORM" 0 1 0 -1 0 1 0 0 1
   echo "icon:/usr/share/pixmaps/rightr.png" >/tmp/RPIPE
   echo "right" >/etc/rotate
}; export -f right

function inverted (){
   events=$(cat /etc/rotate_events)
   touch=`echo "$events" | cut -f2 -d'|'`
   pad=`echo "$events" | cut -f1 -d'|'`
   xrandr --output "$connected" --rotate inverted
    xinput set-prop "$touch" "Evdev Axis Inversion" 1, 1
    xinput set-prop "$touch" "Evdev Axes Swap" 0
    xinput set-prop "$pad" "$TRANSFORM" -1 0 1 0 -1 1 0 0 1
   echo "icon:/usr/share/pixmaps/invertedr.png" >/tmp/RPIPE
   echo "inverted" >/etc/rotate
}; export -f inverted

function normal (){
   events=$(cat /etc/rotate_events)
   touch=`echo "$events" | cut -f2 -d'|'`
   pad=`echo "$events" | cut -f1 -d'|'`
   [ -z "$touch" ] && bash -c eventsfn
   xrandr --output "$connected" --rotate normal
    xinput set-prop "$touch" "Evdev Axis Inversion" 0, 0
    xinput set-prop "$touch" "Evdev Axes Swap" 0
    xinput set-prop "$pad" "$TRANSFORM" 1 0 0 0 1 0 0 0 1
   echo "icon:/usr/share/pixmaps/normalr.png" >/tmp/RPIPE
   echo "normal" >/etc/rotate
}; export -f normal

function rotate_reset (){
   rm -f /etc/rotate
   rm -f /etc/rotate_events
   rm -f /etc/rotat*
}; export -f rotate_reset
   exec 7<> /tmp/check
   events=/etc/rotate_events
   export touch=`cat "$events" | cut -f2 -d'|'`
   export pad=`cat "$events" | cut -f1 -d'|'`
   events=$(xinput | yad --tabnum=1 --plug=$$ --text-info --listen --geometry=400x400 <&7 &
   yad --tabnum=2 --plug=$$ --form --field="touchpad event id=:NUM" "$pad"  --field="Touchscreen event id=:NUM" "$touch" &
   yad --key=$$ --title=Events --paned --tab="Xinput device info" --tab"Select device event number" --button="OK!gtk-ok:0" --button="Xinput:bash -c xinputfn" --width=600 --height=250 --splitter=200 --orient=vert &)
   [[ "$events" != "0|0|" ]] && echo "$events" >/etc/rotate_events || exit
   export touch=`echo "$events" | cut -f2 -d'|'`
   export pad=`echo "$events" | cut -f1 -d'|'`
bash -c `cat /etc/rotate`
echo icon:"/usr/share/pixmaps/${state}.png" >/tmp/RPIPE
CMD="bash -c 'xdotool click 3'"
yad --notification --listen \
--text="Rotate Screen" \
--tray-icon="/usr/share/pixmaps/${state}.png" \
--command="bash -c 'xdotool click 3;xdotool click 3'" \
--menu="Rotate Left!bash -c left!/usr/share/pixmaps/leftr.png\
|Rotate right!bash -c right!/usr/share/pixmaps/rightr.png\
|Rotate Inverted!bash -c inverted!/usr/share/pixmaps/invertedr.png\
|Rotate pad Left!bash -c peft!/usr/share/pixmaps/lefty.png\
|Rotate pad right!bash -c pight!/usr/share/pixmaps/righty.png\
|Rotate pad Inverted!bash -c perted!/usr/share/pixmaps/invertedy.png\
|Rotate pad normal!bash -c pormal!/usr/share/pixmaps/normaly.png\
|Rotate touch Left!bash -c cheft!/usr/share/pixmaps/leftb.png\
|Rotate touch right!bash -c chight!/usr/share/pixmaps/rightb.png\
|Rotate touch Inverted!bash -c chited!/usr/share/pixmaps/invertedb.png\
|Rotate touch normal!bash -c chorm!/usr/share/pixmaps/normalb.png\
|Rotate display Left!bash -c deft!/usr/share/pixmaps/left.png\
|Rotate display right!bash -c dight!/usr/share/pixmaps/right.png\
|Rotate display Inverted!bash -c diserted!/usr/share/pixmaps/inverted.png\
|Rotate display normal!bash -c dimal!/usr/share/pixmaps/normal.png\
|Reset!bash -c rotate_reset!gtk-refresh|Events selection!bash -c evntsfn!gtk-refresh" <&3
Back to top
View user's profile Send private message MSN Messenger 
Display posts from previous:   Sort by:   
Page 1 of 1 [9 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Utilities
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1665s ][ Queries: 12 (0.0105s) ][ GZIP on ]