Skip to content

Instantly share code, notes, and snippets.

@ACamposPT
ACamposPT / auto_screen_rotation.sh
Last active October 25, 2023 18:52 — forked from mildmojo/rotate_desktop.sh
Script to rotate the screen and touch devices on modern Linux desktops. Great for convertible laptops.
#!/bin/bash
# Auto rotate screen based on device orientation
# Receives input from monitor-sensor (part of iio-sensor-proxy package)
# Screen orientation is set based upon accelerometer position
# This script should be added to startup applications for the user
# Rotates modern Linux desktop screen and input devices to match. Handy for
# convertible notebooks. Call this script from panel launchers, keyboard
# shortcuts, or touch gesture bindings (xSwipe, touchegg, etc.).
#!/bin/sh
# Get input device info
# This script parse the output of command:
# /proc/bus/input/devices
#
# How to use:
# . /input-device-info.sh
# MY_DEVICE_PATH=$(inputDeviceEventHandlerPath "my-device-name")
# echo 'MY_DEVICE_PATH:' ${MY_DEVICE_PATH}
[Unit]
Description=Auto read accelerometer data stream
[Service]
Type=simples
Restart=always
RestartSec=1
user=root
ExecStart=/usr/local/bin/auto_accel_read.sh
#!/bin/bash
# Auto read accelerometer data stream
# OEM install shutdown iio-sensor-proxy service
# Avoid need restart system after OEM Install
STATUS="$(systemctl is-active iio-sensor-proxy.service)"
if [ "${STATUS}" = "active" ]; then
echo "iio-sensor-proxy.service is active"
else
echo "iio-sensor-proxy.service is not active"
[Desktop Entry]
Type=Application
Name=AutoRotate
Exec=/usr/local/bin/auto_screen_rotation.sh
Terminal=false
adriano@adriano-Intel-powered-classmate-PC:~$ systemctl status iio-sensor-proxy
● iio-sensor-proxy.service - IIO Sensor Proxy service
Loaded: loaded (/lib/systemd/system/iio-sensor-proxy.service; static; vendor preset: enabled)
Active: inactive (dead) since Fri 2020-06-05 12:23:30 WEST; 2min 5s ago
Process: 612 ExecStart=/usr/sbin/iio-sensor-proxy (code=killed, signal=TERM)
Main PID: 612 (code=killed, signal=TERM)
jun 05 12:22:56 adriano-Intel-powered-classmate-PC systemd[1]: iio-sensor-proxy.service: Service h>
jun 05 12:22:58 adriano-Intel-powered-classmate-PC systemd[1]: iio-sensor-proxy.service: Service h>
jun 05 12:23:05 adriano-Intel-powered-classmate-PC systemd[1]: iio-sensor-proxy.service: Service h>