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
5 changes: 5 additions & 0 deletions packages/omamobile-gnss/install
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ fi
for f in bionic/prebuilt/stubs/*.so; do install -Dm644 "$f" "$v/stubs/${f##*/}"; done
for f in vendor/systemd/system/*; do install -Dm644 "$f" "$d/usr/lib/systemd/system/${f##*/}"; done
install -Dm644 vendor/systemd/user/omamobile-geoclue-agent.service "$d/usr/lib/systemd/user/omamobile-geoclue-agent.service"
# geoclue's own XDG autostart of its demo agent would run it at every login,
# Location on or off, and then our agent unit exits as a second instance:
# mask the unit systemd-xdg-autostart-generator makes of it (generator.late
# comes after /usr/lib/systemd/user, so the mask wins; geoclue's file stays).
ln -sfn /dev/null "$d/usr/lib/systemd/user/app-geoclue\x2ddemo\x2dagent@autostart.service"
install -Dm644 vendor/modprobe.d/omamobile-gnss.conf "$d/usr/lib/modprobe.d/omamobile-gnss.conf"
install -Dm644 polkit/50-omamobile-gnss.rules "$d/usr/share/polkit-1/rules.d/50-omamobile-gnss.rules"
install -Dm644 etc/geoclue/conf.d/90-omamobile-gnss.conf "$d/etc/geoclue/conf.d/90-omamobile-gnss.conf"
Expand Down
19 changes: 19 additions & 0 deletions packages/omamobile-gnss/test/all
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,24 @@ python3 -c 'import ast, sys; ast.parse(open(sys.argv[1]).read())' lib/omamobile-
# A running stack keeps the phone awake (SUSPEND-PLAN 6.1).
grep -qx 'ExecStart=/usr/bin/systemd-inhibit --what=sleep --mode=block "--who=Omarchy Mobile GNSS" "--why=A location session is running" /usr/lib/omamobile-vendor/omamobile-gnss-start' \
vendor/systemd/system/omamobile-gnss.service || fail "the stack holds a sleep inhibitor while it runs"
# One GeoClue agent, ours (2026-11-02): geoclue's XDG autostart of its demo
# agent ran at login, our unit exited as a second instance and stayed
# inactive. The mask must carry the generator's escaped name, and our unit
# must stop an autostart agent a running session already has.
mask='app-geoclue\x2ddemo\x2dagent@autostart.service'
gen=/usr/lib/systemd/user-generators/systemd-xdg-autostart-generator
if [[ -x $gen ]]; then
g=$(mktemp -d)
mkdir -p "$g/xdg/autostart" "$g/out"
printf '[Desktop Entry]\nName=Geoclue Demo agent\nExec=/bin/sh\nType=Application\n' > "$g/xdg/autostart/geoclue-demo-agent.desktop"
XDG_CONFIG_HOME=$g/home XDG_CONFIG_DIRS=$g/xdg "$gen" "$g/out" "$g/out" "$g/out" 2>/dev/null
[[ -f $g/out/$mask ]] || { ls "$g/out" >&2; rm -rf "$g"; fail "the autostart generator names the agent's unit differently"; }
rm -rf "$g"
fi
grep -qF "ln -sfn /dev/null \"\$d/usr/lib/systemd/user/$mask\"" install || fail "the autostart agent's unit must be masked"
grep -qxF "ExecStartPre=-/usr/bin/systemctl --user stop ${mask//\\/\\\\}" vendor/systemd/user/omamobile-geoclue-agent.service ||
fail "the agent unit must stop an autostart agent first (escaped once more for systemd's C escapes)"

# The bionic prebuilts are built on the computer with the Android toolchain
# and never committed; a checkout without them (CI) checks the rest only.
if [[ ! -f bionic/prebuilt/omamobile-fp-shim.so ]]; then
Expand Down Expand Up @@ -46,6 +64,7 @@ for f in usr/bin/omamobile-gnss usr/lib/omamobile-vendor/omamobile-vendor-chroot
etc/omamobile/gnss.conf; do
[[ -e $stage/$f ]] || fail "not staged: $f"
done
[[ $(readlink "$stage/usr/lib/systemd/user/$mask") == /dev/null ]] || fail "the autostart agent's mask not staged"
# Default-off: nothing is enabled by a wants link, and the stack itself has no [Install].
[[ -z $(find "$stage" -path '*.wants/*') ]] || fail "something is enabled by default"
grep -q '^\[Install\]' vendor/systemd/system/omamobile-gnss.service && fail "omamobile-gnss.service must not be installable"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,22 @@
# /etc/geoclue/conf.d/90-omamobile-gnss.conf are let through without a
# question; others get a notification. Enabled for all users by
# "omamobile-gnss on" (systemctl --global), disabled by "off".
#
# geoclue ships an XDG autostart of the same agent (geoclue-demo-agent.desktop),
# which the session would run at every login whatever the Location switch says.
# This package masks its generated unit (app-geoclue\x2ddemo\x2dagent@autostart
# .service, in /usr/lib/systemd/user), so this unit is the one agent. A session
# that started the autostart one before the mask (an upgrade from before 0.2.6,
# without a new login) still runs it, and a second agent only finds the
# first one and exits: stop that one first, so this unit takes over.
[Unit]
Description=GeoClue agent (location authorization)
After=graphical-session.target
PartOf=graphical-session.target
ConditionPathExists=/usr/lib/geoclue-2.0/demos/agent

[Service]
ExecStartPre=-/usr/bin/systemctl --user stop app-geoclue\\x2ddemo\\x2dagent@autostart.service
ExecStart=/usr/lib/geoclue-2.0/demos/agent
Restart=on-failure
RestartSec=5
Expand Down
2 changes: 1 addition & 1 deletion packages/omamobile-gnss/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.4
0.2.6
2 changes: 1 addition & 1 deletion packages/omamobile-shell/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Omarchy Mobile's phone profile for Omarchy's own shell. It isn't a fork: these a
| `bin/omamobile-osk-watch` | Reports squeekboard's visibility (sm.puri.OSK0) to the fingerprint, keyboard and launcher plugins |
| `bin/omamobile-osk-guard` | Turns the on-screen keyboard (`screen-keyboard-enabled`) back on when it was left off with no screensaver running (a user unit for every graphical session) |
| `bin/omamobile-sleepd` | Sleep (s2idle) once the screen has been off behind a secure lock for `OMAMOBILE_SLEEP_AFTER_OFF` s (30), and again 5 s after a dark resume; `now` for the power key (`omamobile-keys`), `check` to see what holds it awake. Refuses with the screen on, Stay awake on, an SSH session open, a logind sleep block inhibitor (calls, GNSS) or a RUNNING PipeWire sink. A user unit for every graphical session, **off until `omarchy-toggle omamobile-sleep on`** (device/cheetah/SUSPEND-PLAN.md 6.2) |
| `bin/omamobile-weather` | The current weather for the lock screen's glance (`~/.local/state/omamobile/weather.json`, with the `source` it used) from Open-Meteo, at login and every 30 minutes (`omamobile-weather.timer`, a user unit for every graphical session). Where, in order: the phone's position from GeoClue at city accuracy, at most every 3 h and only while the Location switch runs GeoClue's agent (never a prompt); the setting `~/.config/omamobile/weather.json` (`omamobile-weather set "State College, PA" F`, or `{"latitude", "longitude"}`; `"location": "fixed"` puts it before the position); the home screen's today widget's city, or the weather widget's named place. Unit: the setting's, else the locale's. A failure keeps the old reading; a run that starts before the network is back (login, or the catch-up run on resume) tries again with backoff for up to 75 s and then gives up without failing the unit. `omamobile-weather show` says where it would look |
| `bin/omamobile-weather` | The current weather for the lock screen's glance (`~/.local/state/omamobile/weather.json`, with the `source` it used) from Open-Meteo, at login and every 30 minutes (`omamobile-weather.timer`, a user unit for every graphical session). Where, in order: the phone's position from GeoClue at city accuracy, at most every 3 h and only while the Location switch is on and GeoClue has an agent for the user (omamobile-gnss's unit, or any other instance of GeoClue's demo agent the user runs; never a prompt); the setting `~/.config/omamobile/weather.json` (`omamobile-weather set "State College, PA" F`, or `{"latitude", "longitude"}`; `"location": "fixed"` puts it before the position); the home screen's today widget's city, or the weather widget's named place. Unit: the setting's, else the locale's. A failure keeps the old reading; a run that starts before the network is back (login, or the catch-up run on resume) tries again with backoff for up to 75 s and then gives up without failing the unit. `omamobile-weather show` says where it would look |
| `bin/omamobile-fp-enroll` | fprintd enrollment helper the fingerprint screen runs (JSON lines) |
| `bin/omamobile-bt-agent` | BlueZ pairing agent and discovery helper the quick-settings Bluetooth panel runs while open |
| `bin/omamobile-portal-access` | The xdg-desktop-portal Access backend (`org.freedesktop.impl.portal.desktop.omamobile`, a D-Bus-activated user unit) that shows the permission sheet and answers the portal |
Expand Down
64 changes: 57 additions & 7 deletions packages/omamobile-shell/bin/omamobile-weather
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ this order:

1. location: the phone's position from GeoClue at city accuracy (no GNSS
power-up), asked at most every 3 h, and only while the Location switch
has GeoClue's agent running (omamobile-geoclue-agent.service, from
omamobile-gnss); the client is GeoClue's where-am-i, which GeoClue lets
through without asking, so a timer never raises a prompt. A fix that
is on and GeoClue has an agent for this user (omamobile-gnss's
omamobile-geoclue-agent.service, or any other instance of GeoClue's
demo agent this user runs); the client is GeoClue's where-am-i, which
GeoClue lets through without asking, so a timer never raises a prompt. A fix that
fails or times out falls back to the last one, up to a day old.
2. widget: the city the home screen's "today" widget is set to (the newest
~/.local/state/omamobile/owl/owl_simonschubert.today_*.json), or else
Expand Down Expand Up @@ -74,6 +75,9 @@ PLACE = os.path.join(STATE_DIR, "weather-place.json")
OWL_TODAY = os.path.join(STATE_DIR, "owl", "owl_simonschubert.today_*.json")
WHERE_AM_I = os.environ.get("OMAMOBILE_WHERE_AM_I", "/usr/lib/geoclue-2.0/demos/where-am-i")
GEOCLUE_AGENT = "omamobile-geoclue-agent.service"
GEOCLUE_AGENT_BIN = os.environ.get("OMAMOBILE_GEOCLUE_AGENT", "/usr/lib/geoclue-2.0/demos/agent")
LOCATION_SOCKET = "omamobile-gnss-nmea.socket"
PROC = "/proc"
FIX_FRESH = 3 * 3600 # ask GeoClue at most this often
FIX_KEEP = 24 * 3600 # a failed fix falls back to the last one this young
GEOCLUE_FOR = 22 # where-am-i under timeout -k 2 20
Expand Down Expand Up @@ -223,13 +227,59 @@ def home_widget_place(layout):
return None


def location_switch():
"""The Location switch (omamobile-gnss): True on, False off, None
without omamobile-gnss (no such socket unit)."""
try:
out = subprocess.run(["systemctl", "is-enabled", LOCATION_SOCKET], capture_output=True,
text=True, env=dict(os.environ, LC_ALL="C")).stdout.strip()
except OSError:
return None
return None if not out else out == "enabled"


def agent_unit_active():
"""omamobile-gnss's agent unit runs for this user."""
try:
return subprocess.run(["systemctl", "--user", "--quiet", "is-active", GEOCLUE_AGENT],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode == 0
except OSError:
return False


def agent_process(proc=None, uid=None):
"""GeoClue's demo agent runs as this user, from whatever started it (an
XDG autostart of geoclue's own, before omamobile-gnss 0.2.6 hid it)."""
proc = proc or PROC
uid = os.getuid() if uid is None else uid
try:
pids = [p for p in os.listdir(proc) if p.isdigit()]
except OSError:
return False
for pid in pids:
try:
if os.stat(os.path.join(proc, pid)).st_uid != uid:
continue
with open(os.path.join(proc, pid, "cmdline"), "rb") as f:
argv0 = f.read().split(b"\0")[0]
except OSError:
continue
if argv0.decode("utf-8", "replace") == GEOCLUE_AGENT_BIN:
return True
return False


def geoclue_usable():
"""GeoClue answers this user only while its agent runs (the Location
switch); without it a request queues for ever, so it isn't made."""
"""GeoClue answers this user only while an agent is registered for the
user; without one a request queues for ever, so it isn't made. The agent
is omamobile-gnss's unit (the Location switch) or any other instance of
GeoClue's demo agent run by this user. With the Location switch off,
GeoClue isn't asked whatever agent runs."""
if not os.access(WHERE_AM_I, os.X_OK):
return False
return subprocess.run(["systemctl", "--user", "--quiet", "is-active", GEOCLUE_AGENT],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode == 0
if location_switch() is False:
return False
return agent_unit_active() or agent_process()


def where_am_i():
Expand Down
35 changes: 35 additions & 0 deletions packages/omamobile-shell/test/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,3 +317,38 @@ def fetch(url):
W.WHERE_AM_I = os.path.join(home, "missing")
ok(W.geoclue_usable() is False, "no where-am-i: GeoClue isn't usable")
print("ok - weather: GeoClue's where-am-i is read at city accuracy, and missing means not usable")

# Which agent counts (2026-11-02: geoclue's own XDG autostart ran the demo
# agent, so omamobile-gnss's unit exited as a second instance and weather
# took Location for off). Any demo agent of this user's counts; the
# Location switch off means no, whatever agent runs.
W.WHERE_AM_I = fake_wai
W.GEOCLUE_AGENT_BIN = "/usr/lib/geoclue-2.0/demos/agent"
proc = os.path.join(home, "proc")


def fake_proc(*cmdlines):
shutil.rmtree(proc, ignore_errors=True)
os.makedirs(os.path.join(proc, "self"))
for i, argv in enumerate(cmdlines, 100):
os.makedirs(os.path.join(proc, str(i)))
with open(os.path.join(proc, str(i), "cmdline"), "wb") as f:
f.write(b"\0".join(a.encode() for a in argv) + b"\0")


W.PROC = proc
fake_proc(["/usr/bin/bash"], ["/usr/lib/geoclue-2.0/demos/where-am-i", "-a", "4"])
ok(W.agent_process() is False, "no demo agent process: none")
fake_proc(["/usr/bin/bash"], ["/usr/lib/geoclue-2.0/demos/agent"])
ok(W.agent_process() is True, "the demo agent run by this user counts")
ok(W.agent_process(uid=os.getuid() + 1) is False, "another user's demo agent doesn't")
ok(W.agent_process(proc=os.path.join(home, "no-proc")) is False, "no /proc: none")
cases = [ # the Location switch, our unit, a demo agent process -> usable
(True, True, False, True), (True, False, True, True), (None, False, True, True),
(True, False, False, False), (False, True, True, False), (None, False, False, False)]
for switch, unit, process, want in cases:
W.location_switch = lambda s=switch: s
W.agent_unit_active = lambda u=unit: u
W.agent_process = lambda p=process: p
ok(W.geoclue_usable() is want, "switch %s, our unit %s, a demo agent %s: usable %s" % (switch, unit, process, want))
print("ok - weather: any GeoClue demo agent of this user's counts, and Location off means no")
2 changes: 1 addition & 1 deletion packages/omamobile-shell/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.82
0.2.86