#!/bin/sh
# Toggles the on-screen keyboard. Installed to /usr/local/bin/toggle-keyboard, run
# from the dock's Keyboard button (configs/eww/eww.yuck) and bindable to any other
# tap target later.
#
# wvkbd, not squeekboard: squeekboard's auto-show behaviour is wired through Phosh's
# session/DBus setup, which this image doesn't run, so under plain Sway it would need
# the same manual-toggle treatment anyway while pulling in more of the GNOME-mobile
# stack. wvkbd is a small layer-shell surface built for exactly this — a wlroots
# kiosk with no shell-level input-method integration.
#
# KNOWN LIMITATION, documented rather than hidden: there is no automatic show-on-
# text-field-focus here (that needs the text-input-v3/virtual-keyboard-v1 protocols
# wired all the way through each app, which is inconsistent across Chromium/Firefox/
# Spotify under plain wlroots). The dock's Keyboard button is therefore the only way
# to open it — tap before typing, tap again to dismiss.
set -eu

if pgrep -u "$(id -u)" -x wvkbd-mobintl >/dev/null 2>&1; then
  pkill -u "$(id -u)" -x wvkbd-mobintl
else
  # -L: keyboard layer height in px. 280 is a starting point for a touch-panel-sized
  # screen, not measured against real hardware — see the README's verification list.
  wvkbd-mobintl -L 280 &
fi
