Code Monkey home page Code Monkey logo

tablet-pc-rotation's Introduction

Tablet pc rotation

The goal of this program is to rotate the display of my Linux convertible laptop every time I rotate it, like going from normal mode to tent mode, or landscape <=> portrait and adjust/disable/re-enable the various inputs/output (touchscreen, touchpad, keyboard) accordingly.

Linux sysfs exposes the various accelerometer analog values via the Linux IIO subsystem. The iio exposes values produced by the analog device and performs a Analog to Digital Conversion (ADC). So it's a poll model, I think there's no way of getting notified when the values change. I've found some interesting documentation about the IIO subsystem here: https://wiki.analog.com/software/linux/docs/iio/iio

In my laptop (Lenovo Yoga C940) there's only one accelerometer that captures the screen orientation in space in the 3 axes (x y z). The code details the meaning of these values.

This program is an adaptation of the python script rotate.py referenced in the Arch Linux wiki: https://gist.githubusercontent.com/ei-grad/4d9d23b1463a99d24a8d/raw/rotate.py It's also an attempt to learn Rust by doing something useful for me.

Usage

  • You need a working Rust installation, X.org, xinput and xrandr. Check your distribution on how to install them.
  • Clone this repository
  • cargo run --release
  • Rotate your 2-in-1 laptop and see what happens!

tablet-pc-rotation's People

Contributors

djebbz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.