config snippets: rotate screen for ppkb

I call this script on startup to rotate the display when the keyboard is attached. I’ll probably replace the name with a variable and move it to the settings file, but for now it’s hard coded.

rotate.sh:

#!/bin/bash
. ~/bin/settings.sh

rotate_right() {
    xrandr -o right
    xinput set-prop  "pointer:Goodix Capacitive TouchScreen" --type=float "Coordinate Transformation Matrix"  0 1 0 -1 0 1  0 0 1 
    xinput set-prop "keyboard:Goodix Capacitive TouchScreen" --type=float "Coordinate Transformation Matrix"  0 1 0 -1 0 1  0 0 1 
}

rotate_left() {
    xrandr -o left
    xinput set-prop  "pointer:Goodix Capacitive TouchScreen" --type=float "Coordinate Transformation Matrix"  0 -1 1 1  0 0 0  0 1
    xinput set-prop "keyboard:Goodix Capacitive TouchScreen" --type=float "Coordinate Transformation Matrix"  0 -1 1 1  0 0 0  0 1
}

rotate_normal() {
    xrandr -o normal
    xinput set-prop  "pointer:Goodix Capacitive TouchScreen" --type=float "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1
    xinput set-prop "keyboard:Goodix Capacitive TouchScreen" --type=float "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1
}

if is_kb_present ; then
    rotate_right
fi

settings.sh:

#!/bin/bash
#
# Some common settings about the hafl env on pinephone.
#

##
# 0 exit when more than the internal battery is present
is_kb_present() {
    local BATTERIES=( $(ls -d /sys/class/power_supply/*-battery) )
    test ${#BATTERIES[@]} -gt 1
}

Tags

#pinephonepro

#pinephone

Navigation

index

tags

Backlinks

2023-02-15 - PinePhone Pro Updates and Configs

updated: 2023-02-15 18:31:15

generated: 2024-03-07