meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
ppaccessories [2022/04/27 09:48]
undef fix inline code blocks
ppaccessories [2022/05/12 12:19] (current)
kailueke Add user service for automated settings
Line 13: Line 13:
   * Fn+F8 and Fn+F10 Alias to = with the kernel driver.   * Fn+F8 and Fn+F10 Alias to = with the kernel driver.
  
 +== Automatic settings ==
  
-== Tweaks ​==+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'':​ 
 + 
 +<​code>​ 
 +[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 
 +</​code>​ 
 + 
 +and this file in ''​~/​bin/​kbd-gsettings.sh'':​ 
 + 
 +<​code>​ 
 +#​!/​bin/​bash 
 +set -euo pipefail 
 +LAST=""​ 
 +while true; do 
 +  if [ -e /​sys/​class/​power_supply/​ip5xxx-charger/​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 
 +</​code>​ 
 + 
 +and then enable the service: 
 + 
 +<​code>​ 
 +systemctl enable --user --now kbd-gsettings 
 +</​code>​ 
 + 
 +== Automatic settings (alternative version) ​==
  
 Automatic switch between onscreen and hardware keyboard on reboot. Automatic switch between onscreen and hardware keyboard on reboot.