From b243c13bd8e38b391648a79bb5a4c484850f98a6 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 20 Nov 2019 22:26:52 +0200 Subject: [PATCH] Added autorotation Signed-off-by: Marko Korhonen --- home/.config/sway/conf.d/08-exec.conf | 2 ++ home/Scripts/autorotate.sh | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100755 home/Scripts/autorotate.sh diff --git a/home/.config/sway/conf.d/08-exec.conf b/home/.config/sway/conf.d/08-exec.conf index 57c19fc..e104d5c 100644 --- a/home/.config/sway/conf.d/08-exec.conf +++ b/home/.config/sway/conf.d/08-exec.conf @@ -20,6 +20,8 @@ exec { ydotoold wl-paste -t text --watch clipman store autotiling + $HOME/Scripts/autorotate.sh + squeekboard } exec_always { diff --git a/home/Scripts/autorotate.sh b/home/Scripts/autorotate.sh new file mode 100755 index 0000000..97cb94b --- /dev/null +++ b/home/Scripts/autorotate.sh @@ -0,0 +1,22 @@ +#!/bin/bash +function rotate_ms { + case $1 in + "normal") + swaymsg output eDP-1 transform 0 + ;; + "right-up") + swaymsg output eDP-1 transform 90 + ;; + "bottom-up") + swaymsg output eDP-1 transform 180 + ;; + "left-up") + swaymsg output eDP-1 transform 270 + ;; + esac +} + +while IFS='$\n' read -r line; do + rotation="$(echo $line | sed -En "s/^.*orientation changed: (.*)/\1/p")" + [[ ! -z $rotation ]] && rotate_ms $rotation +done < <(stdbuf -oL monitor-sensor)