~mil/sxmo-utils

ref: a1a6c3eb43be13cae40dff841fc9e08487d123d6 sxmo-utils/scripts/core/sxmo_rotate.sh -rwxr-xr-x 1.6 KiB
a1a6c3ebStacy Harper Set minimum brightness to 5% 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env sh

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

applyptrmatrix() {
	TOUCH_POINTER_ID="${TOUCH_POINTER_ID:-8}"
	xinput set-prop "$TOUCH_POINTER_ID" --type=float --type=float "Coordinate Transformation Matrix" "$@"
}

swaytransforms() {
	swaymsg -p -t get_outputs | awk '
		/Output/ { printf $2 " " };
		/Transform/ { print $2 }'
}

xorgisrotated() {
	case "$(xrandr | grep primary | cut -d' ' -f 5)" in
		*right*|*left*) return 0;;
		*) return 1;;
	esac
}

swayisrotated() {
	swaytransforms | grep DSI-1 | grep -q 0
}

xorgrotnormal() {
	sxmo_keyboard.sh close
	xrandr -o normal
	applyptrmatrix 0 0 0 0 0 0 0 0 0
	sxmo_hooks.sh lisgdstart
	exit 0
}

swayrotnormal() {
	swaymsg -- output  DSI-1 transform 0
	sxmo_hooks.sh lisgdstart &
	exit 0
}

xorgrotright() {
	sxmo_keyboard.sh close
	xrandr -o right
	applyptrmatrix 0 1 0 -1 0 1 0 0 1
	sxmo_hooks.sh lisgdstart &
	exit 0
}

swayrotright() {
	swaymsg -- output  DSI-1 transform 90
	sxmo_hooks.sh lisgdstart
	exit 0
}

xorgrotleft() {
	sxmo_keyboard.sh close
	xrandr -o left
	applyptrmatrix 0 -1 1 1 0 0 0 0 1
	sxmo_hooks.sh lisgdstart
	exit 0
}

swayrotleft() {
	swaymsg -- output  DSI-1 transform 270
	sxmo_hooks.sh lisgdstart
	exit 0
}

isrotated() {
	case "$wm" in
		sway)
			"swayisrotated"
			;;
		dwm|xorg)
			"xorgisrotated"
			;;
	esac
}

wm="$(sxmo_wm.sh)"

if [ -z "$1" ] || [ "rotate" = "$1" ]; then
	shift
	if isrotated; then
		set -- rotnormal "$@"
	else
		set -- rotright "$@"
	fi
fi

case "$wm" in
	sway)
		"sway$1" "$@"
		;;
	dwm|xorg)
		"xorg$1" "$@"
		;;
esac