meta data for this page
  •  

This is an old revision of the document!


Pinephone Accessories

Pinephone Keyboard

Known Issues
  • You cannot see the charger capacity in settings
  • The Charger defaults to charging at 500 mA, so it may not be enough to charge the phone when in operation
  • You need to `modprobe i2c-dev` to use megi's tools. They also need to be compiled from source, as the release version segfaults
  • Fn+F8 and Fn+F10 Alias to = with the kernel driver.
Automatic settings

The following user session service detects the hardware keyboard and disables the on-screen keyboard.

Create this file as ~/.config/systemd/user/kbd-gsettings.service:

[Unit]
Description=PinePhone Keyboard Case detector to disable on-screen keyboard
[Service]
Restart=on-failure
ExecStart=/home/mobian/bin/kbd-gsettings.sh
[Install]
WantedBy=default.target

and this file in ~/bin/kbd-gsettings.sh:

#!/bin/bash
set -euo pipefail
LAST=""
while true; do
  if [ -e /sys/class/power_supply/ip5xxx-battery/voltage_now ]; then
    NEW="false"
  else
    NEW="true"
  fi
  if [ "$NEW" != "$LAST" ] || [ "$(ps -p $(pgrep -n -U $UID phosh) -o etimes=)" -lt 120 ]; then
    gsettings set org.gnome.desktop.a11y.applications screen-keyboard-enabled "$NEW"
    echo "Keyboard case change, using on-screen keyboard: $NEW" >&2
    LAST="$NEW"
  fi
  sleep 30
done

and then enable the service:

systemctl enable --user --now kbd-gsettings
Automatic settings (alternative version)

Automatic switch between onscreen and hardware keyboard on reboot.

Make a script like this. I named it ~/.local/bin/keyboard-external.sh. I “scale 1” in landscape mode, don't forget to change it to your needs.

#!/usr/bin/env bash
# required: sudo apt-get install wlr-randr #for screen rotation and dpi settings
#
# obsolete 'kb151' driver
# if [ -L "/sys/bus/i2c/drivers/kb151/2-0015" ]; then
# changed to use with 'pinephone-keyboard' driver
if [ -e /sys/class/power_supply/ip5xxx-battery/voltage_now ]; then
  gsettings set org.gnome.desktop.a11y.applications screen-keyboard-enabled false
  wlr-randr --output DSI-1 --scale 1 --transform 270
else
  gsettings set org.gnome.desktop.a11y.applications screen-keyboard-enabled true
  wlr-randr --output DSI-1 --transform normal
fi
# return status
gsettings get org.gnome.desktop.a11y.applications screen-keyboard-enabled

Add this to “~/.config/autostart/keyboard-external.desktop”.

[Desktop Entry]
Name=Keyboard
Type=Application
Icon=object-rotate-left-symbolic
Exec=/home/mobian/.local/bin/keyboard-external.sh
Categories=Utility;
NoDisplay=true

May be there are better solutions. But this works for me at the moment.

Charging

The keyboard charges the phone with 500mA by default, to change it to 1500mA do this PinePhone:

echo 1500000 | sudo tee /sys/class/power_supply/axp20x-usb/input_current_limit

PinePhone Pro:

echo 1500000 | sudo tee /sys/class/power_supply/rk818-usb/input_current_limit
Symbol Keys

With the latest version of the keyboard drivers, the Fn-symbol keys disappear. This can be fixed by:

  • Installing xkb-data >= 2.35.1-1mobian1.
  • Setting XKB_DEFAULT_MODEL=ppkb in Phosh's environment. Add the following to /usr/lib/systemd/system/phosh.service.d/override.conf:
[Service]
Environment=XKB_DEFAULT_MODEL=ppkb
  • Reboot or restart Phosh.

After this, the top row symbols will be available as L3-{0-9}. The L3 key can be configured in settings → keyboard → Alternative Characters Key.