Skip to content
Merged
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
4 changes: 4 additions & 0 deletions packages/omamobile-shell/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,7 @@ Open, save and choose-a-folder requests through the portal (Qt, GTK, Electron an
The package contract follows omarchy-mac's: `./install DESTDIR` stages files and enables nothing, `test/all` runs the package's own tests, and `version` holds the version.

Develop on a desktop with `phone/dev/run-desktop` from the repo root.

## Device settings

After the shared rules, `hypr/phone.lua` loads `/usr/share/omamobile/hypr/device.lua` if a device package installs one, for settings only that phone needs (an inner and an outer panel, its own input devices). Every session that loads `phone.lua` (setup-user adds it to `looknfeel.lua`) gets it, new and existing users alike. It runs under `pcall`: a syntax or runtime error in the device file is logged and the shared rules stay in force. With no device file nothing changes, so every phone today is unaffected.
11 changes: 11 additions & 0 deletions packages/omamobile-shell/hypr/phone.lua
Original file line number Diff line number Diff line change
Expand Up @@ -247,3 +247,14 @@ elseif o.cmd_present("voxtype") then
{ "Stop dictation (push-to-talk)", "voxtype record stop", { release = true } },
})
end

-- Device packages may add their own session settings in one optional file,
-- loaded after the shared rules above. pcall: a broken device file logs its
-- error and the shared rules stay in force. No file, no change.
local device_hook = "/usr/share/omamobile/hypr/device.lua"
local device_file = io.open(device_hook, "r")
if device_file then
device_file:close()
local ok, err = pcall(dofile, device_hook)
if not ok then print("omamobile: " .. device_hook .. ": " .. tostring(err)) end
end
5 changes: 5 additions & 0 deletions packages/omamobile-shell/test/all
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,11 @@ lua=$(command -v lua || command -v lua5.4 || command -v luajit || true)
if [[ -n $lua ]]; then
out=$("$lua" test/phone-rules.lua) || { grep -v '^ok' <<<"$out"; fail "phone.lua window rules"; }
pass "phone.lua: edge to edge, opaque, dialogs, picture-in-picture"
# The optional device.lua: a broken one is reported, the shared rules stand.
for hook in valid syntax runtime; do
out=$(DEVICE_HOOK_CASE=$hook "$lua" test/phone-rules.lua) || { grep -v '^ok' <<<"$out"; fail "phone.lua with a $hook device.lua"; }
done
pass "phone.lua: device.lua runs after the shared rules, and an error in it leaves them standing"
# Dictation keys under Omarchy 4.5's helpers: four homes, four bindings.lua
dk=$(mktemp -d)
mkdir -p "$dk/plain/.config/hypr" "$dk/migrated/.config/hypr" "$dk/own/.config/hypr"
Expand Down
25 changes: 25 additions & 0 deletions packages/omamobile-shell/test/phone-rules.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,29 @@ o = {
o.bind("CTRL + ALT + DELETE", "Close all windows", "omarchy-hyprland-window-close-all")
o.bind("ALT + TAB", "Focus on next window", hl.dsp.window.cycle_next())
o.bind("F9", "Start dictation (push-to-talk)", "voxtype record start")
-- The optional device hook (/usr/share/omamobile/hypr/device.lua), with no
-- file, a valid one, a syntax error and a runtime error (DEVICE_HOOK_CASE).
-- Only that one path is redirected, to a temporary file; with no case set
-- the hook path reads as absent, so no file on the host takes part.
local hook_case = os.getenv("DEVICE_HOOK_CASE") or "absent"
local real_open, real_dofile = io.open, dofile
local hook_path = "/usr/share/omamobile/hypr/device.lua"
local hook_tmp = os.tmpname()
local hook_source = {
valid = "omamobile_hook_ran = true",
syntax = "this is not Lua!",
runtime = 'error("fixture device error")',
}
os.remove(hook_tmp)
if hook_source[hook_case] then
local f = assert(real_open(hook_tmp, "w"))
f:write(hook_source[hook_case]); f:close()
end
io.open = function(path, ...) return real_open(path == hook_path and hook_tmp or path, ...) end
dofile = function(path) return real_dofile(path == hook_path and hook_tmp or path) end
dofile("hypr/phone.lua")
io.open, dofile = real_open, real_dofile
os.remove(hook_tmp)

local failed = false
local function check(ok, what)
Expand Down Expand Up @@ -158,4 +180,7 @@ check(#find("ALT + TAB") == 2 and find("ALT + TAB")[1].dispatcher.dsp == "cycle_
local f9 = find("F9", true)
check(#f9 == 1 and f9[1].dispatcher == "voxtype record stop", "F9 still stops Voxtype on release")

check(omamobile_hook_ran == (hook_case == "valid" or nil),
"device hook (" .. hook_case .. "): runs only when valid, and the shared rules stand")

os.exit(failed and 1 or 0)
2 changes: 1 addition & 1 deletion packages/omamobile-shell/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.134
0.2.135