Autorotation for framework12 on niri
This commit is contained in:
parent
889ecc9a44
commit
7539648198
1 changed files with 42 additions and 0 deletions
|
|
@ -360,4 +360,46 @@ in {
|
||||||
RestartSec = 5;
|
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;
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue