Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/omamobile-shell/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ depends=(omarchy omamobile-apps 'omamobile-omarchy>=0.1.11' 'omamobile-owl-widge
xdg-desktop-portal-gnome) # the file chooser (portal/hyprland-portals.conf)
checkdepends=(nodejs) # test/weather.py runs HomeModel.js under node
optdepends=('fprintd: fingerprint setup and unlock (with omamobile-fingerprint)'
'fcitx5-mozc: Japanese input (omamobile-ime on)'
'omamobile-voice: the speech model for voice input, so Voxtype works with no download (the root image has it)'
'voxtype-bin: voice input (the root image has it; or Install > AI > Dictation)')
backup=(etc/xdg/xdg-desktop-portal/hyprland-portals.conf)
Expand Down
6 changes: 6 additions & 0 deletions packages/omamobile-shell/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ machine: the model comes from a pinned commit of whisper.cpp's model
repository with a pinned sha256, and makepkg keeps it in its source cache
afterwards.

## Japanese input

`omamobile-ime on` (with `fcitx5-mozc` installed) hands the input method to fcitx5 with Mozc, and `omamobile-ime off` gives it back to squeekboard. Hyprland gives it to one client, so with it on squeekboard no longer sees text fields: double-tap the home strip to show it. Type romaji, Space converts, Enter commits. It needs hyprland 0.57.0-3.4, which resends squeekboard's keymap to fcitx5. At login `omamobile-ime.service` restarts squeekboard once fcitx5 holds the input method.

Not yet: picking a candidate by tap (fcitx5's window takes no taps; a candidate bar above the keyboard, through fcitx5's kimpanel, would), showing the keyboard when a field takes focus, and the Kana layout (it needs more keycodes than a keymap has).

## File dialogs

Open, save and choose-a-folder requests through the portal (Qt, GTK, Electron and Flatpak apps alike) get Nautilus's libadwaita file chooser from xdg-desktop-portal-gnome, not xdg-desktop-portal-gtk's GTK 3 desktop chooser, whose Places sidebar took half of the 480 px width. Nautilus's chooser folds its sidebar away at phone width and has touch-sized rows; `hypr/phone.lua` tiles it, even when it has a parent window, so it fills the screen between the bar and the on-screen keyboard. Only FileChooser goes to the gnome backend: its other interfaces need gnome-shell. It runs without gnome-shell (its Mutter service channel is missing, so it falls back to a plain Wayland connection). xdg-desktop-portal-gtk stays as the fallback and for its other interfaces. GTK apps that would draw their own chooser in-process are sent to the portal too (`GTK_USE_PORTAL=1` for GTK 3, `GDK_DEBUG=portals` for GTK 4, in `environment.d/20-omamobile-osk.conf`); Qt Widgets apps keep Omarchy's `QT_QPA_PLATFORMTHEME=gtk3` for now.
Expand Down
160 changes: 160 additions & 0 deletions packages/omamobile-shell/bin/omamobile-ime
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
#!/bin/bash
# SPDX-License-Identifier: MIT
# omamobile-ime: Japanese input (fcitx5 with Mozc) on or off, for the user.
#
# omamobile-ime status on or off, and whether fcitx5 and Mozc are there
# omamobile-ime on fcitx5 (Mozc) takes the input method, from now on
# omamobile-ime off squeekboard takes it back, as before
# omamobile-ime session omamobile-ime.service: restart squeekboard once
# fcitx5 is up, then follow the keyboard's language
#
# Hyprland gives the input method to one client. squeekboard holds it by
# default and shows itself when a text field takes focus. With this on,
# fcitx5 holds it and converts what squeekboard types (its keys reach fcitx5
# through the keyboard grab; hyprland 0.57.0-3.4 resends squeekboard's
# keymap there), but squeekboard no longer sees text fields: double-tap the
# home strip to show or hide it. Mozc converts only while the keyboard's
# language (the globe key) is Japanese (romaji), jp+romaji: a copy of the US
# layout, since jp.yaml's kana views need more keycodes than a keymap can
# carry. With any other language fcitx5 passes keys through as typed (a
# password in English is safe). "on" adds that language to the keyboard's
# list. Space converts, Enter commits; candidates
# appear in fcitx5's own window, which takes no taps. The switch is
# ~/.config/omamobile/fcitx5 (the drop-in on omarchy-fcitx5.service reads
# it too).
set -euo pipefail

CONF=${XDG_CONFIG_HOME:-$HOME/.config}
FLAG=$CONF/omamobile/fcitx5
FCITX=$CONF/fcitx5
SYSTEMCTL=${OMAMOBILE_SYSTEMCTL:-systemctl}
MOZC=${OMAMOBILE_MOZC_ADDON:-/usr/share/fcitx5/addon/mozc.conf}
GSETTINGS=${OMAMOBILE_GSETTINGS:-gsettings}
REMOTE=${OMAMOBILE_FCITX5_REMOTE:-fcitx5-remote}
# How long session waits for squeekboard, and for fcitx5 to answer, in seconds
OSK_WAIT=${OMAMOBILE_IME_OSK_WAIT:-20}
REMOTE_WAIT=${OMAMOBILE_IME_REMOTE_WAIT:-10}
# squeekboard is restarted once per login session (and again after "on")
RESTARTED=${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/omamobile-ime-osk-restarted
SCHEMA=org.gnome.desktop.input-sources

die() { echo "omamobile-ime: $*" >&2; exit 1; }

# squeekboard as Omarchy's autostart starts it, through Hyprland's exec:
# started straight from a script it didn't come back (omamobile-keyboard-theme).
# OMAMOBILE_IME_OSK_RESTART runs instead, for tests.
restart_squeekboard() {
if [[ -n ${OMAMOBILE_IME_OSK_RESTART:-} ]]; then "$OMAMOBILE_IME_OSK_RESTART"; return; fi
pkill -x squeekboard 2>/dev/null || true
for _ in $(seq 30); do pgrep -x squeekboard >/dev/null || break; sleep 0.1; done
local sig=${HYPRLAND_INSTANCE_SIGNATURE:-}
[[ -n $sig ]] || sig=$(ls "${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/hypr" 2>/dev/null | head -1)
[[ -n $sig ]] || die "no Hyprland session to start squeekboard in"
HYPRLAND_INSTANCE_SIGNATURE=$sig hyprctl dispatch 'hl.dsp.exec_cmd("uwsm-app -- squeekboard")' >/dev/null
}

# fcitx5's profile: two groups, English (the US keyboard) and Japanese (Mozc
# alone, so it converts as soon as the group is chosen). A group is global,
# unlike activating Mozc, which reaches only the focused field (none while
# the language sheet is open). Only written when the user has no profile or
# config of their own.
write_config() {
mkdir -p "$FCITX"
if [[ ! -e $FCITX/profile ]]; then
cat > "$FCITX/profile" <<'EOF'
[Groups/0]
Name=English
Default Layout=us
DefaultIM=keyboard-us

[Groups/0/Items/0]
Name=keyboard-us
Layout=

[Groups/1]
Name=Japanese
Default Layout=us
DefaultIM=mozc

[Groups/1/Items/0]
Name=mozc
Layout=

[GroupOrder]
0=English
1=Japanese
EOF
fi
if [[ ! -e $FCITX/config ]]; then
printf '[Behavior]\nActiveByDefault=False\nShareInputState=All\n' > "$FCITX/config"
fi
}

# squeekboard shows the first of the input sources; Mozc for Japanese only.
# A failure (fcitx5 not up yet, or restarting) is logged, not fatal: the
# follower keeps running and applies the next change.
language() { "$GSETTINGS" get $SCHEMA sources | grep -o "'xkb', '[^']*'" | head -1 | sed "s/.*, '//; s/'$//"; }
apply() {
local group=English
[[ $(language) == jp+romaji ]] && group=Japanese
"$REMOTE" -g "$group" && return 0
echo "omamobile-ime: fcitx5 didn't take the $group group" >&2
return 1
}

# Add Japanese (romaji) to the keyboard's languages, last, if it isn't there.
add_language() {
local now
now=$("$GSETTINGS" get $SCHEMA sources)
grep -q "'jp+romaji'" <<<"$now" && return 0
if [[ $now == *"('"* ]]; then
"$GSETTINGS" set $SCHEMA sources "${now%]}, ('xkb', 'jp+romaji')]"
else
"$GSETTINGS" set $SCHEMA sources "[('xkb', 'us'), ('xkb', 'jp+romaji')]"
fi
}

status() {
local state=off mozc=no
[[ -e $FLAG ]] && state=on
[[ -e $MOZC ]] && mozc=yes
echo "japanese input: $state"
echo "mozc installed: $mozc"
echo "fcitx5: $("$SYSTEMCTL" --user is-active omarchy-fcitx5.service 2>/dev/null || true)"
}

case ${1:-} in
status) status ;;
on)
[[ -e $MOZC ]] || die "fcitx5-mozc isn't installed (sudo pacman -S fcitx5-mozc)"
write_config
add_language
mkdir -p "${FLAG%/*}"; : > "$FLAG"
rm -f "$RESTARTED"
"$SYSTEMCTL" --user restart omarchy-fcitx5.service
"$SYSTEMCTL" --user restart omamobile-ime.service
echo "Japanese input on: pick Japanese (romaji) with the globe key; double-tap the home strip for the keyboard"
;;
off)
rm -f "$FLAG" "$RESTARTED"
"$SYSTEMCTL" --user stop omamobile-ime.service omarchy-fcitx5.service 2>/dev/null || true
restart_squeekboard
echo "Japanese input off"
;;
session)
# Hyprland's autostart may start squeekboard before fcitx5 is up, and
# then squeekboard keeps the input method: wait for it, then restart it,
# once per login session, so a restart of this unit doesn't take the
# keyboard away again.
if [[ ! -e $RESTARTED ]]; then
for _ in $(seq $((OSK_WAIT * 5))); do pgrep -x squeekboard >/dev/null && break; sleep 0.2; done
restart_squeekboard
: > "$RESTARTED"
fi
applied=
for _ in $(seq "$REMOTE_WAIT"); do apply 2>/dev/null && { applied=1; break; }; sleep 1; done
[[ -n $applied ]] || apply || true
"$GSETTINGS" monitor $SCHEMA sources | while read -r _; do apply || true; done
;;
*) die "usage: omamobile-ime status|on|off" ;;
esac
13 changes: 11 additions & 2 deletions packages/omamobile-shell/bin/omamobile-keyboard-languages
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@ the same evdev.xml), "layout+variant" for a variant.

Layouts that can be added are the ones the keyboard has: the layouts in
/usr/share/omamobile/squeekboard/keyboards/ (squeekboard's own, with our
action row), not yet in the list. squeekboard's Emoji and Terminal overlays
action row), not yet in the list. Japanese (romaji) is offered only while
Japanese input is on (omamobile-ime's switch, ~/.config/omamobile/fcitx5):
without it, it is the US keyboard under a Japanese name. squeekboard's Emoji and Terminal overlays
are not sources and can't be chosen from outside squeekboard (docs/VOICE-PLAN.md,
"The language sheet").

OMAMOBILE_XKB_RULES and OMAMOBILE_KEYBOARDS_DIR point elsewhere for tests."""
OMAMOBILE_XKB_RULES, OMAMOBILE_KEYBOARDS_DIR and XDG_CONFIG_HOME point
elsewhere for tests."""

import ast
import glob
Expand All @@ -43,6 +46,10 @@ RULES = os.environ.get("OMAMOBILE_XKB_RULES", "/usr/share/X11/xkb/rules/evdev.xm
KEYBOARDS = os.environ.get("OMAMOBILE_KEYBOARDS_DIR", "/usr/share/omamobile/squeekboard/keyboards")
# What squeekboard shows with no sources at all (src/state.rs, Application::new)
FALLBACK = "us"
# Layouts only for Japanese input (omamobile-ime), and its switch
IME_ONLY = {"jp+romaji"}
IME_SWITCH = os.path.join(os.environ.get("XDG_CONFIG_HOME") or os.path.expanduser("~/.config"),
"omamobile", "fcitx5")


def gsettings(*args):
Expand Down Expand Up @@ -106,6 +113,8 @@ def carried():
name = os.path.basename(path)[:-len(".yaml")]
if not name.endswith("_wide"):
out.add(name)
if not os.path.exists(IME_SWITCH):
out -= IME_ONLY
return out


Expand Down
3 changes: 3 additions & 0 deletions packages/omamobile-shell/install
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ ln -sfn ../omamobile-setup-user.service "$destination/usr/lib/systemd/user/graph
install -Dm644 systemd/user/omamobile-osk-guard.service "$destination/usr/lib/systemd/user/omamobile-osk-guard.service"
install -d "$destination/usr/lib/systemd/user/graphical-session.target.wants"
ln -sfn ../omamobile-osk-guard.service "$destination/usr/lib/systemd/user/graphical-session.target.wants/omamobile-osk-guard.service"
# Japanese input (omamobile-ime on): squeekboard after fcitx5 at login; inert while off.
install -Dm644 systemd/user/omamobile-ime.service "$destination/usr/lib/systemd/user/omamobile-ime.service"
ln -sfn ../omamobile-ime.service "$destination/usr/lib/systemd/user/graphical-session.target.wants/omamobile-ime.service"
# Sleep on screen-off, for every user's graphical session; it does nothing
# until the user turns the omamobile-sleep toggle on.
install -Dm644 systemd/user/omamobile-sleepd.service "$destination/usr/lib/systemd/user/omamobile-sleepd.service"
Expand Down
5 changes: 4 additions & 1 deletion packages/omamobile-shell/squeekboard/generate
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ HEADER_END = "# omamobile-setup-user links it into ~/.local/share/squeekboard/ke
# The globe key: squeekboard's popover out, our language sheet in
GLOBE_UPSTREAM = 'action: "show_prefs"'
GLOBE = 'keysym: "XF86MediaLanguageMenu"'
HAND_MADE = {"terminal/us.yaml", "terminal/us_wide.yaml"}
HAND_MADE = {"terminal/us.yaml", "terminal/us_wide.yaml",
# Japanese (romaji) for omamobile-ime: copies of the US layouts
"jp+romaji.yaml", "jp+romaji_wide.yaml",
"terminal/jp+romaji.yaml", "terminal/jp+romaji_wide.yaml"}
# Greek (gr, gr_wide): a row of its own under the action row with the accented
# vowels, one key each, so ά is one tap and not two (open the accents view,
# then tap; it closes itself after one key). The accents view stays for the rest of what is only there.
Expand Down
119 changes: 119 additions & 0 deletions packages/omamobile-shell/squeekboard/keyboards/jp+romaji.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# Japanese (romaji), for Japanese input (omamobile-ime): a copy of
# us.yaml, whose header follows, so its keymap stays within
# the 255 keycodes an input method's keymap can carry (jp.yaml's kana
# views need 709). omamobile-ime turns Mozc on only while this layout is
# the keyboard's language. Listed in squeekboard/generate's HAND_MADE.
# squeekboard 1.43.1's us.yaml (https://gitlab.gnome.org/World/Phosh/squeekboard,
# tag v1.43.1, GPL-3.0-or-later), with two changes for Omarchy Mobile: the
# action row (Mic, Paste, Emoji, Hide; XF86 keysyms that hypr/phone.lua
# binds for squeekboard only) on top of every view, and the globe key
# sending XF86MediaLanguageMenu (the shell's language sheet) instead of
# opening squeekboard's popover. Made by
# squeekboard/generate (change the generator, not this file). The row
# sums to the widest row's 356.57: 2 x 106.971 + 2 x 71.314.
# omamobile-setup-user links it into ~/.local/share/squeekboard/keyboards/.
# Language: Japanese (romaji)
---
outlines:
default: { width: 35.657, height: 52 }
change-view: { width: 53.485, height: 52 }
change-view-2: { width: 62.399, height: 52 }
large: { width: 44.571, height: 52 }
spaceline: { width: 142.63, height: 52 }
special: { width: 44.571, height: 52 }
special-2: { width: 53.485, height: 52 }
special-3: { width: 62.399, height: 52 }
mic: { width: 106.971, height: 40 }
paste: { width: 106.971, height: 40 }
emoji: { width: 71.314, height: 40 }
hide: { width: 71.314, height: 40 }

views:
base:
- "Mic Paste Emoji Hide"
- "q w e r t y u i o p"
- "a s d f g h j k l"
- "show_upper z x c v b n m BackSpace"
- "show_numbers preferences space . Return"
upper:
- "Mic Paste Emoji Hide"
- "Q W E R T Y U I O P"
- "A S D F G H J K L"
- "show_upper Z X C V B N M BackSpace"
- "show_numbers preferences space . Return"
numbers:
- "Mic Paste Emoji Hide"
- "1 2 3 4 5 6 7 8 9 0"
- "@ # $ % & - _ + ( )"
- "show_symbols , \" ' : ; ! ? BackSpace"
- "show_letters preferences space . Return"
symbols:
- "Mic Paste Emoji Hide"
- "~ ` | · √ π τ ÷ × ¶"
- "© ® £ € ¥ ^ ° * { }"
- "show_numbers_from_symbols \\ / < > = [ ] BackSpace"
- "show_letters preferences space . Return"

buttons:
show_upper:
action:
locking:
lock_view: "upper"
unlock_view: "base"
outline: "change-view"
icon: "key-shift"
BackSpace:
outline: "special-2"
icon: "edit-clear-symbolic"
action: "erase"
preferences:
keysym: "XF86MediaLanguageMenu"
outline: "special"
icon: "keyboard-mode-symbolic"
show_numbers:
action:
set_view: "numbers"
outline: "change-view-2"
label: "123"
show_numbers_from_symbols:
action:
set_view: "numbers"
outline: "change-view"
label: "123"
show_letters:
action:
set_view: "base"
outline: "change-view-2"
label: "ABC"
show_symbols:
action:
set_view: "symbols"
outline: "change-view"
label: "*/="
.:
outline: "large"
space:
outline: "spaceline"
text: " "
Return:
outline: "special-3"
icon: "key-enter"
keysym: "Return"
# The action row (hypr/phone.lua binds the keysyms)
Mic:
outline: "mic"
keysym: "XF86Dictate"
label: "󰍬 Mic"
Paste:
outline: "paste"
keysym: "XF86Paste"
label: "󰆒 Paste"
Emoji:
outline: "emoji"
keysym: "XF86EmojiPicker"
label: "󰞅 Emoji"
Hide:
outline: "hide"
keysym: "XF86Keyboard"
label: "󰌏 Hide"
Loading