使用加速度计旋转屏幕

使用加速度计旋转屏幕
lsmod | grep acc
hp_accel               28672  0
lis3lv02d              20480  1 hp_accel

我怎样才能从这个东西中获取输出?

还有xrandr --output eDP1 --rotate normalinvertedleftright。我想使用传感器输出来触发这些命令并执行屏幕旋转。

编辑:

升级内核后,运行时出现此问题lsmod | grep acc

hid_sensor_accel_3d    16384  1
hid_sensor_trigger     16384  15 hid_sensor_incl_3d,hid_sensor_accel_3d,hid_sensor_magn_3d,hid_sensor_gyro_3d,hid_sensor_rotation
industrialio_triggered_buffer    16384  5 hid_sensor_incl_3d,hid_sensor_accel_3d,hid_sensor_magn_3d,hid_sensor_gyro_3d,hid_sensor_rotation
hid_sensor_iio_common    16384  6 hid_sensor_incl_3d,hid_sensor_accel_3d,hid_sensor_trigger,hid_sensor_magn_3d,hid_sensor_gyro_3d,hid_sensor_rotation
industrialio           69632  10 hid_sensor_incl_3d,hid_sensor_accel_3d,acpi_als,hid_sensor_trigger,hid_sensor_magn_3d,hid_sensor_gyro_3d,hid_sensor_rotation,industrialio_triggered_buffer,kfifo_buf
hp_accel               28672  0
lis3lv02d              20480  1 hp_accel
hid_sensor_hub         20480  8 hid_sensor_incl_3d,hid_sensor_accel_3d,hid_sensor_iio_common,hid_sensor_trigger,hid_sensor_magn_3d,hid_sensor_gyro_3d,hid_sensor_rotation,hid_sensor_custom

编辑2:

iio-sensor-proxy 未运行。尝试后sudo iio-sensor-proxy发现

** (process:2721): WARNING **: Failed to read float from /sys/devices/pci0000:00/0000:00:13.0/{33AECD58-B679-4E54-9BD9-A04D34F0C226}/001F:8086:22D8.0001/HID-SENSOR-200073.8.auto/iio:device6/in_scale

** (process:2721): WARNING **: Problem reading scan element information: /sys/devices/pci0000:00/0000:00:13.0/{33AECD58-B679-4E54-9BD9-A04D34F0C226}/001F:8086:22D8.0001/HID-SENSOR-200073.8.auto/iio:device6

并且终端保持空白,直到我^C

尝试sudo systemctl start iio-sensor-proxy直到超时才会输出任何内容

Job for iio-sensor-proxy.service failed because a timeout was exceeded. See "systemctl status iio-sensor-proxy.service" and "journalctl -xe" for details.

systemctl status iio-sensor-proxy.service

● iio-sensor-proxy.service - IIO Sensor Proxy service
   Loaded: loaded (/lib/systemd/system/iio-sensor-proxy.service; static; vendor preset: enabled)
   Active: failed (Result: timeout) since Wed 2017-05-24 16:12:03 EET; 5min ago
  Process: 3335 ExecStart=/usr/sbin/iio-sensor-proxy (code=killed, signal=TERM)
 Main PID: 3335 (code=killed, signal=TERM)

May 24 16:10:33 gas systemd[1]: Starting IIO Sensor Proxy service...
May 24 16:12:03 gas systemd[1]: iio-sensor-proxy.service: Start operation timed out. Terminating.
May 24 16:12:03 gas systemd[1]: Failed to start IIO Sensor Proxy service.
May 24 16:12:03 gas systemd[1]: iio-sensor-proxy.service: Unit entered failed state.
May 24 16:12:03 gas systemd[1]: iio-sensor-proxy.service: Failed with result 'timeout'.

journalctl -xe(可能没什么用)

May 24 16:11:26 gas kernel: intel-vbtn INT33D6:01: unknown event index 0xcd
May 24 16:12:03 gas systemd[1]: iio-sensor-proxy.service: Start operation timed out. Terminating.
May 24 16:12:03 gas systemd[1]: Failed to start IIO Sensor Proxy service.
-- Subject: Unit iio-sensor-proxy.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit iio-sensor-proxy.service has failed.
-- 
-- The result is failed.
May 24 16:12:03 gas systemd[1]: iio-sensor-proxy.service: Unit entered failed state.
May 24 16:12:03 gas systemd[1]: iio-sensor-proxy.service: Failed with result 'timeout'.
May 24 16:12:03 gas sudo[3855]: pam_unix(sudo:session): session closed for user root
May 24 16:12:17 gas gnome-session[2010]: (nm-applet:2383): nm-applet-WARNING **: ModemManager is not avai
May 24 16:12:17 gas gnome-session[2010]: (nm-applet:2383): nm-applet-WARNING **: ModemManager is not avai
May 24 16:12:17 gas gnome-session[2010]: (nm-applet:2383): nm-applet-WARNING **: ModemManager is not avai
May 24 16:12:17 gas gnome-session[2010]: (nm-applet:2383): nm-applet-WARNING **: ModemManager is not avai
May 24 16:12:17 gas gnome-session[2010]: (nm-applet:2383): nm-applet-WARNING **: ModemManager is not avai
May 24 16:12:17 gas gnome-session[2010]: (nm-applet:2383): nm-applet-WARNING **: ModemManager is not avai
May 24 16:12:17 gas gnome-session[2010]: (nm-applet:2383): nm-applet-WARNING **: ModemManager is not avai
May 24 16:12:17 gas gnome-session[2010]: (nm-applet:2383): nm-applet-WARNING **: ModemManager is not avai
May 24 16:12:17 gas gnome-session[2010]: (nm-applet:2383): nm-applet-WARNING **: ModemManager is not avai
May 24 16:13:40 gas anacron[775]: Job `cron.daily' terminated
May 24 16:13:40 gas anacron[775]: Normal exit (1 job run)
May 24 16:13:50 gas org.gnome.zeitgeist.SimpleIndexer[1779]: ** (zeitgeist-fts:2514): WARNING **: Unable 
May 24 16:14:14 gas gnome-session[2010]: (nm-applet:2383): nm-applet-WARNING **: ModemManager is not avai
May 24 16:14:14 gas gnome-session[2010]: (nm-applet:2383): nm-applet-WARNING **: ModemManager is not avai
May 24 16:14:14 gas gnome-session[2010]: (nm-applet:2383): nm-applet-WARNING **: ModemManager is not avai
May 24 16:14:14 gas gnome-session[2010]: (nm-applet:2383): nm-applet-WARNING **: ModemManager is not avai
May 24 16:14:14 gas gnome-session[2010]: (nm-applet:2383): nm-applet-WARNING **: ModemManager is not avai
May 24 16:14:14 gas gnome-session[2010]: (nm-applet:2383): nm-applet-WARNING **: ModemManager is not avai
May 24 16:14:14 gas gnome-session[2010]: (nm-applet:2383): nm-applet-WARNING **: ModemManager is not avai
May 24 16:14:14 gas gnome-session[2010]: (nm-applet:2383): nm-applet-WARNING **: ModemManager is not avai
May 24 16:14:14 gas gnome-session[2010]: (nm-applet:2383): nm-applet-WARNING **: ModemManager is not avai
May 24 16:14:43 gas org.gnome.zeitgeist.SimpleIndexer[1779]: ** (zeitgeist-fts:2514): WARNING **: Unable 
May 24 16:15:01 gas CRON[4519]: pam_unix(cron:session): session opened for user root by (uid=0)
May 24 16:15:01 gas CRON[4520]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
May 24 16:15:01 gas CRON[4519]: pam_unix(cron:session): session closed for user root
May 24 16:15:02 gas org.gnome.zeitgeist.SimpleIndexer[1779]: ** (zeitgeist-fts:2514): WARNING **: Unable 
May 24 16:15:15 gas org.gnome.zeitgeist.SimpleIndexer[1779]: ** (zeitgeist-fts:2514): WARNING **: Unable 
May 24 16:15:26 gas org.gnome.zeitgeist.SimpleIndexer[1779]: ** (zeitgeist-fts:2514): WARNING **: Unable 
May 24 16:15:49 gas /usr/lib/snapd/snapd[790]: snapmgr.go:450: No snaps to auto-refresh found
May 24 16:15:49 gas snapd[790]: 2017/05/24 16:15:49.321528 snapmgr.go:450: No snaps to auto-refresh found
May 24 16:15:51 gas org.gnome.zeitgeist.SimpleIndexer[1779]: ** (zeitgeist-fts:2514): WARNING **: Unable 
May 24 16:16:13 gas gnome-session[2010]: (nm-applet:2383): nm-applet-WARNING **: ModemManager is not avai
May 24 16:16:13 gas gnome-session[2010]: (nm-applet:2383): nm-applet-WARNING **: ModemManager is not avai
May 24 16:16:13 gas gnome-session[2010]: (nm-applet:2383): nm-applet-WARNING **: ModemManager is not avai
May 24 16:16:13 gas gnome-session[2010]: (nm-applet:2383): nm-applet-WARNING **: ModemManager is not avai
May 24 16:16:13 gas gnome-session[2010]: (nm-applet:2383): nm-applet-WARNING **: ModemManager is not avai
May 24 16:16:13 gas gnome-session[2010]: (nm-applet:2383): nm-applet-WARNING **: ModemManager is not avai
May 24 16:16:13 gas gnome-session[2010]: (nm-applet:2383): nm-applet-WARNING **: ModemManager is not avai
May 24 16:16:13 gas gnome-session[2010]: (nm-applet:2383): nm-applet-WARNING **: ModemManager is not avai
May 24 16:16:13 gas gnome-session[2010]: (nm-applet:2383): nm-applet-WARNING **: ModemManager is not avai
May 24 16:16:58 gas org.gnome.zeitgeist.SimpleIndexer[1779]: ** (zeitgeist-fts:2514): WARNING **: Unable 
May 24 16:17:01 gas CRON[4669]: pam_unix(cron:session): session opened for user root by (uid=0)
May 24 16:17:01 gas CRON[4670]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
May 24 16:17:01 gas CRON[4669]: pam_unix(cron:session): session closed for user root
May 24 16:17:46 gas org.gnome.zeitgeist.SimpleIndexer[1779]: ** (zeitgeist-fts:2514): WARNING **: Unable 
May 24 16:18:00 gas org.gnome.zeitgeist.SimpleIndexer[1779]: ** (zeitgeist-fts:2514): WARNING **: Unable

...是的,我的电脑名字是 gas X'D

我希望我们能修复这个传感器问题。我迫切希望它能正常工作。看来我们快要成功了 :)

答案1

这不是一个解决方案,而是一个指向正确方向的指针。我也一直在寻找一种方法来做到这一点。我遇到了 iio-sensor-proxyhttps://github.com/hadess/iio-sensor-proxy我正在编写一个小守护进程来解决这个问题。

这是我运行监视器传感器并将屏幕向右旋转 90 度时得到的结果。

> 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: 6.098000 (lux)
    Light changed: 168.823008 (lux)
    Light changed: 167.266008 (lux)
    Light changed: 161.816008 (lux)
    Light changed: 183.098009 (lux)
    Accelerometer orientation changed: left-up
    Light changed: 204.379010 (lux)
    Light changed: 214.241010 (lux)
    Light changed: 214.371010 (lux)
    Accelerometer orientation changed: normal
    Light changed: 179.724009 (lux)
    Light changed: 170.121008 (lux)
    Light changed: 170.900008 (lux)

相关内容