Open techtino opened 3 years ago
not sure if its the right way, but i modified the sxmo rotate script a bit so its usable with sway. with systemd you can start a user service
https://wiki.archlinux.org/title/Sway#Manage_Sway-specific_daemons_with_systemd
#!/usr/bin/env sh
ROTATONLOG="/tmp/isrotated.log"
GRAVITY="16374"
THRESHOLD="400"
POLL_TIME=1
RIGHT_SIDE_UP="$(echo "$GRAVITY - $THRESHOLD" | bc)"
UPSIDE_DOWN="$(echo "-$GRAVITY + $THRESHOLD" | bc)"
FILE_X="$(find /sys/bus/iio/devices/iio:device*/ -iname in_accel_x_raw)"
FILE_Y="$(find /sys/bus/iio/devices/iio:device*/ -iname in_accel_y_raw)"
touch $ROTATONLOG
rotationlog() {
echo $1 > $ROTATONLOG
}
while true; do
getrotation=$(cat $ROTATONLOG)
y_raw="$(cat "$FILE_Y")"
x_raw="$(cat "$FILE_X")"
if [ "$x_raw" -ge "$RIGHT_SIDE_UP" ] && [ "$getrotation" != "norm" ]; then
rotationlog "norm"
swaymsg output DSI-1 transform 0
elif [ "$y_raw" -le "$UPSIDE_DOWN" ] && [ "$getrotation" != "left" ]; then
rotationlog "left"
swaymsg output DSI-1 transform 90
elif [ "$y_raw" -ge "$RIGHT_SIDE_UP" ] && [ "$getrotation" != "right" ]; then
rotationlog "right"
swaymsg output DSI-1 transform 270
fi
sleep "$POLL_TIME"
done
The rot8 configuration in the sway config file does not work, likely because x-file and y-file are not valid arguments apparently.
This is because the git clone command doesn't clone the forked version with the added args. This should be specified in the readme.