~mil/sxmo-utils

ref: dbc3b1ab509aab5f1db72c5cece2ee2a6eb521e8 sxmo-utils/scripts/core/sxmo_rotate.sh -rwxr-xr-x 1.0 KiB
dbc3b1abStacy Harper Allow the sendnewtextmenu to be used with a number as arg 1 year, 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env sh

# include common definitions
# shellcheck source=scripts/core/sxmo_common.sh
. "$(dirname "$0")/sxmo_common.sh"

applyptrmatrix() {
	PTRID="$(
		xinput | grep -iE 'touchscreen.+pointer' | grep -oE 'id=[0-9]+' | cut -d= -f2
	)"
	xinput set-prop "$PTRID" --type=float --type=float "Coordinate Transformation Matrix" "$@"
}

isrotated() {
	xrandr | grep primary | cut -d' ' -f 5 | grep right && return 0
	xrandr | grep primary | cut -d' ' -f 5 | grep left && return 0
	return 1
}

rotnormal() {
	sxmo_keyboard.sh close
	xrandr -o normal
	applyptrmatrix 0 0 0 0 0 0 0 0 0
	pidof lisgd && pkill lisgd | sxmo_lisgdstart.sh -o 0 &
	exit 0
}

rotright() {
	sxmo_keyboard.sh close
	xrandr -o right
	applyptrmatrix 0 1 0 -1 0 1 0 0 1
	pidof lisgd && pkill lisgd | sxmo_lisgdstart.sh -o 1 &
	exit 0
}

rotleft() {
	sxmo_keyboard.sh close
	xrandr -o left
	applyptrmatrix 0 -1 1 1 0 0 0 0 1
	pidof lisgd && pkill lisgd | sxmo_lisgdstart.sh -o -1 &
	exit 0
}


rotate() {
	if isrotated; then rotnormal; else rotright; fi
}

if [ -z "$1" ]; then
	rotate
else
	"$1"
fi