Skip to content

michele-perrone/linux-oneplus-tristatekey

Repository files navigation

OnePlus 6(T) tri-state key support in PostmarketOS

As the name suggest, the goal of this little project is to hook up the OnePlus6(T) tri-state key in PostmarketOS. This can be done in the userspace with the gpiod library.

Installation

Open your favorite terminal and type the following commands:

wget https://github.com/michele-perrone/postmarketos-oneplus6-tristatekey/releases/download/0.2.0-r0/tristatekey-daemon-0.2.0-r0.apk
sudo cp [email protected] /etc/apk/keys/[email protected]
sudo apk add tristatekey-daemon-0.2.0-r0.apk
sudo reboot now

Your OnePlus 6 will now reboot. Enjoy your tri-state key!

Building from source

From your terminal:

git clone https://github.com/michele-perrone/postmarketos-oneplus6-tristatekey
abuild

Keep in mind that if you're running abuild for the first time, you'll be asked to create your public-private key pair.
The default directory for the compiled package is in ~/packages/projects/aarch64/.

Gimme the pins

The OnePlus 6 has three GPIO chips. Each of them has several (many, actually) lines. The three pins that correspond to the tri-state key belong to gpiochip2 and are the following lines:

  • 24 (bottom)
  • 52 (middle)
  • 126 (up)

They are of the "active-high" type, which means that their value is 1 when triggered and 0 otherwise.

Putting it together

  1. The current value of the tri-state key has to be continuously polled by a daemon (inspiration here), in order to abstract it with a debouce algorithm (examples here). It could be also possible to use interrupts instead of polling
  2. The daemon should be an rc-service (follow these guidelines) since Alpine/PostmarketOS are OpenRC distributions and non Systemd ones
  3. Based on the (debouced) value of the tri-state key, the daemon should switch between the three ring/vibrate/mute properties of the current desktop environment

About

Hook up the OnePlus6(T) tri-state key in PostmarketOS!

Resources

Stars

Watchers

Forks