Skip to content

Commit 3ff74dc

Browse files
asdf1nitguysoft
authored andcommitted
Added Rotate.sh
https://www.raspberrypi.org/forums/viewtopic.php?t=243564#p1485227 TLDR: The fkms driver while the best option for most pi's cant read the config.txt to set screen rotation on boot so we use this script and implement it in what ever way suits the specific use/
1 parent 5f05ec9 commit 3ff74dc

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

  • src/modules/gui/filesystem/home/pi/scripts
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
3+
if [ -z "$1" ] ; then
4+
echo "Usage: $0 [normal|inverted|left|right]"
5+
echo " "
6+
exit 1
7+
fi
8+
9+
function do_rotate
10+
{
11+
xrandr --output $1 --rotate $2
12+
13+
TRANSFORM='Coordinate Transformation Matrix'
14+
15+
POINTERS=`xinput | grep 'slave pointer'`
16+
POINTERS=`echo $POINTERS | sed s/↳\ /\$/g`
17+
POINTERS=`echo $POINTERS | sed s/\ id=/\@/g`
18+
POINTERS=`echo $POINTERS | sed s/\ \\\[slave\ pointer/\#/g`
19+
iIndex=2
20+
POINTER=`echo $POINTERS | cut -d "@" -f $iIndex | cut -d "#" -f 1`
21+
while [ "$POINTER" != "" ] ; do
22+
POINTER=`echo $POINTERS | cut -d "@" -f $iIndex | cut -d "#" -f 1`
23+
POINTERNAME=`echo $POINTERS | cut -d "$" -f $iIndex | cut -d "@" -f 1`
24+
#if [ "$POINTER" != "" ] && [[ $POINTERNAME = *"TouchPad"* ]]; then # ==> uncomment to transform only touchpads
25+
#if [ "$POINTER" != "" ] && [[ $POINTERNAME = *"TrackPoint"* ]]; then # ==> uncomment to transform only trackpoints
26+
#if [ "$POINTER" != "" ] && [[ $POINTERNAME = *"Digitizer"* ]]; then # ==> uncomment to transform only digitizers (touch)
27+
#if [ "$POINTER" != "" ] && [[ $POINTERNAME = *"MOUSE"* ]]; then # ==> uncomment to transform only optical mice
28+
if [ "$POINTER" != "" ] ; then # ==> uncomment to transform all pointer devices
29+
case "$2" in
30+
normal)
31+
[ ! -z "$POINTER" ] && xinput set-prop "$POINTER" "$TRANSFORM" 1 0 0 0 1 0 0 0 1
32+
;;
33+
inverted)
34+
[ ! -z "$POINTER" ] && xinput set-prop "$POINTER" "$TRANSFORM" -1 0 1 0 -1 1 0 0 1
35+
;;
36+
left)
37+
[ ! -z "$POINTER" ] && xinput set-prop "$POINTER" "$TRANSFORM" 0 -1 1 1 0 0 0 0 1
38+
;;
39+
right)
40+
[ ! -z "$POINTER" ] && xinput set-prop "$POINTER" "$TRANSFORM" 0 1 0 -1 0 1 0 0 1
41+
;;
42+
esac
43+
fi
44+
iIndex=$[$iIndex+1]
45+
done
46+
}
47+
48+
XDISPLAY=`xrandr --current | grep primary | sed -e 's/ .*//g'`
49+
if [ "$XDISPLAY" == "" ] || [ "$XDISPLAY" == " " ] ; then
50+
XDISPLAY=`xrandr --current | grep connected | sed -e 's/ .*//g' | head -1`
51+
fi
52+
53+
do_rotate $XDISPLAY $1

0 commit comments

Comments
 (0)