1
0
mirror of https://github.com/Dejvino/pinephone-sway-poc.git synced 2024-12-23 18:58:49 +00:00
pinephone-sway-poc/usr/local/bin/swayphone_rotated

36 lines
564 B
Plaintext
Raw Normal View History

2020-06-16 21:41:58 +00:00
#!/bin/bash
function rotate
{
kill -10 `pidof waybar`
}
ROTFILE=/tmp/sway_rotation
PREV=-1
if [[ -f $ROTFILE ]]
then
PREV=$(<$ROTFILE)
fi
TRANSFORM=`swaymsg -p -t get_outputs | grep -A 15 "Output DSI-1" | grep "Transform:"`
NOW=-1
if [[ $TRANSFORM == *"normal"* ]]; then
NOW=0
elif [[ $TRANSFORM == *"90"* ]]; then
NOW=1
elif [[ $TRANSFORM == *"180"* ]]; then
NOW=2
elif [[ $TRANSFORM == *"270"* ]]; then
NOW=3
fi
echo $NOW > $ROTFILE
if [[ $(($PREV % 2)) -eq $(($NOW % 2)) ]]; then
echo "No change."
else
echo Rotated from $PREV to $NOW.
rotate
fi