Autorotation for framework12 on niri

This commit is contained in:
Aleksandr Lebedev 2025-07-31 19:01:48 +02:00
parent 889ecc9a44
commit 7539648198

View file

@ -360,4 +360,46 @@ in {
RestartSec = 5;
};
};
systemd.user.services.autorotate = lib.mkIf (hwconfig.hasTouchscreen) {
Unit = {
Description = "Adds auto rotation to Niri.";
};
Install = {
WantedBy = ["default.target"];
};
Service = {
ExecStart = "${pkgs.writeShellScript "autorotate" ''
transform="normal"
monitor-sensor | while read -r line; do
case "$line" in
*normal*)
new_transform="normal"
;;
*right-up*)
new_transform="270"
;;
*bottom-up*)
new_transform="180"
;;
*left-up*)
new_transform="90"
;;
*)
continue
;;
esac
if [[ "$new_transform" != "$transform" ]]; then
transform="$new_transform"
echo "Transform: $transform"
niri msg output eDP-1 transform "$transform"
systemctl --user restart lisgd-niri.service
fi
done
''}";
Restart = "on-failure";
RestartSec = 5;
};
};
}