The Yoga 900 has an accelerometer which should allow auto-rotation behavior.
On installing https://github.com/hadess/iio-sensor-proxy (Linux*, LightDM) it is possible to run monitor-sensor.
➜ ~ monitor-sensor
Waiting for iio-sensor-proxy to appear
+++ iio-sensor-proxy appeared
=== Has accelerometer (orientation: undefined)
=== Has ambient light sensor (value: 0.000000, unit: lux)
Accelerometer orientation changed: normal
Light changed: 49.999999 (lux)
Light changed: 79.999998 (lux)
Accelerometer orientation changed: left-up
Accelerometer orientation changed: normal
Accelerometer orientation changed: left-up
Accelerometer orientation changed: bottom-up
With iio-sensor-proxy the data is made available on dbus. It has the form:
signal time=1479631365.562013 sender=:1.15 -> destination=(null destination) serial=449861 path=/com/ubuntu/Upstart; interface=com.ubuntu.Upstart0_6; member=EventEmitted
string "dbus"
array [
string "SIGNAL=PropertiesChanged"
string "BUS=system"
string "INTERFACE=org.freedesktop.DBus.Properties"
string "OBJPATH=/net/hadess/SensorProxy"
string "SENDER=:1.4"
string "ARG0=net.hadess.SensorProxy"
]
Is it possible to run a script that only wakes up on certain dbus events? Preferably I re-use an event loop in a daemon that already exists rather than building my own Python script or C program. Something like adding a file to
/etc/dbus.d/handlers/net/hadess/SensorProxywould be really cool.If I don't run
monitor-sensorI do not seem messages appearing on dbus, even thoughiio-sensor-proxyis actually run. Are these messages only sent if someone is listening for them?
[*] Linux V 4.8.1-040801-generic #201610071031 SMP Fri Oct 7 14:34:10 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
PS: According to powertop when using monitor-sensor:
14.7 mW 1.5 ms/s 8.8 Process dbus-monitor
The answer should describe the canonical way to handle this on Linux and be the most friendly solution from a battery usage perspective.