Fix xkopher link focus and unlock clock; battery longevity pass

Map xkopher link focus through wrapped display rows and reset horizontal scroll in no-wrap mode. Refresh the status bar clock on unlock and from dmenu before republishing root WM_NAME. Re-analysis found two low-risk wins: force lz4 for the active zram swap and disable proactive compaction. Rebuild dmenu.so and smallweb.so, update guards and docs, redeploy live, and rebuild the image.
This commit is contained in:
Luxferre committed 2026-11-08 08:45:53 +02:00
1 parent 85c6a7b886
commit 3543556735
22 files changed
+402 -54

No files matched your search

+2 -2
View File
@@ -57,7 +57,7 @@ All cross-compilation scripts run inside rootless Docker (`alpine:3.24` `armv7`
- **No emojis**: never use emojis in source code, UI strings, logs, or commit messages (use Nerd Font PUA codepoints defined in `neoui.h` / `phone_data.h` / `dmenu.c` for UI icons).
- **Unified theming**: never hardcode UI colors or font sizes in `dwm`, `dmenu`, `st`, or any DWM plugin. Read colors and proportional font sizes from `PluginTheme` (`src/neoui/neoui.h` / `src/dwm-plugins/theme.h`) / `.Xresources` (`theme.*`), and handle `RELOAD_THEME` on the plugin FIFO.
- **Zero-lag plugin model**: phone UI apps must run as preloaded resident daemons (`--preload`) guarded by `/tmp/dwm_plugin_<name>.lock`, sleeping at 0% CPU on `poll()` over `ConnectionNumber(dpy)` and `/tmp/dwm_plugin_<name>.fifo`, and rendering into an offscreen `Pixmap` (`240x296` at `X=0, Y=24`) copied with `XCopyArea` to prevent flicker.
- **Multiline text rendering**: on the target Pango/Xft stack `pango_xft_render_layout()` only paints the first line of a long multiline layout, so wrapped bodies must be drawn line by line with `pango_xft_render_layout_line()` using a scroll offset and a bounded visible line count (see `sms_plugin.cpp`, `dialer_plugin.cpp`, `modem_plugin.cpp`, and `neoui_draw_text_wrapped()`). Where the widget has a fixed rectangle, clip with `XftDrawSetClipRectangles()` and reset the clip afterwards so the softkey bar still draws; keep measurement and rendering at the same layout width. `scripts/check-rebuild.sh` guards `sms_plugin.cpp`.
- **Multiline text rendering**: on the target Pango/Xft stack `pango_xft_render_layout()` only paints the first line of a long multiline layout, so wrapped bodies must be drawn line by line with `pango_xft_render_layout_line()` using a scroll offset and a bounded visible line count (see `sms_plugin.cpp`, `dialer_plugin.cpp`, `modem_plugin.cpp`, and `neoui_draw_text_wrapped()`). Where the widget has a fixed rectangle, clip with `XftDrawSetClipRectangles()` and reset the clip afterwards so the softkey bar still draws; keep measurement and rendering at the same layout width. Wrapped document views must also map link focus through the same row expansion used for rendering (`buildRenderRows()` / `ensureFocusedLinkVisible()` in `smallweb_plugin.cpp`), so focusing a link scrolls the viewport in both wrap modes. `scripts/check-rebuild.sh` guards `sms_plugin.cpp` and the xkopher focus path.
- **SMS text accounting**: never treat `std::string::size()` (UTF-8 bytes) as an SMS character count. Use code-point-aware logic such as `smsTextMetrics()`: GSM-7 septets (160 per part, 153 when concatenated) or UCS-2 UTF-16 units (70 per part, 67 when concatenated). SMS log headers are parsed by `parseSmsHeaderLine()`, which strips `[SIM n]` tags; do not write those tags back into `sms.txt`.
- **Documentation**: keep `README.md`, `MANUAL.md`, `SDK.md`, and `CHANGELOG.md` synchronized with any new user-facing features, SDK functions, or keybindings, and do not leave third-party `.md` files inside `src/` or `edl/`.
- **Artifact sources**: `prebuilt/` is the single source of truth for compiled artifacts and `scripts/rootfs-packages.txt` for the `armv7` package set. Never edit `overlay/rootfs/` copies of binaries by hand; run `./scripts/sync-prebuilt-overlay.sh` after changing `prebuilt/`.
@@ -76,7 +76,7 @@ Sync net time** (`src/sxmo-dmenu/dmenu.c` +
`usr/bin/bananarchy-sync-net-time.sh`) forces the same burst manually and
notifies the user, and the helper's `sync` mode reports the result. Keep DNS
resolution outside the helper's `flock` so a long boot retry cannot swallow
network-up events, and keep `var/lib/chrony` owned by the `chrony` user. Deep standby is `bananarchy-suspend.sh` / `bananarchy-deep-standby.sh` / `sxmo_autosuspend.sh` / `sxmo_suspend.sh`, gated by `/etc/bananarchy-no-deep-standby` (shipped present = disabled) and inert because `CONFIG_SUSPEND` is off. A full custom module tree rebuild is deliberately **not** planned: this firmware has no PSCI `SYSTEM_SUSPEND`, so `CONFIG_SUSPEND` would only give s2idle (`freeze`), not `mem` / DDR self-refresh, for <1 mA of saving (see `BATTERY-OPTIMIZATION-ANALYSIS.md` §14). Never force `sxmo.noidle`/`sxmo.nosuspend` from the session scripts and never reintroduce the infinite `sxmo_not_suspendable` wakelock. `/etc/bananarchy/` is root-only.
network-up events, and keep `var/lib/chrony` owned by the `chrony` user. The status bar clock must be refreshed synchronously on unlock (`sxmo_hook_unlock.sh`) and by dmenu's `update_t9_status_indicator()` before `XStoreName()`; `sxmo_hook_statusbar.sh` forces a root-name refresh on `time` / `state_change`. `postmarketos-zram-swap` uses `/usr/bin/zramstart`, not `/etc/conf.d/zram-init`: keep `deviceinfo_zram_swap_algo="lz4"` in every `devices/*/deviceinfo*` file. Keep `vm.compaction_proactiveness=0` in `etc/sysctl.d/99-bananarchy-power.conf` and `etc/local.d/10-power-save.start`; see `BATTERY-OPTIMIZATION-ANALYSIS.md` §17. Deep standby is `bananarchy-suspend.sh` / `bananarchy-deep-standby.sh` / `sxmo_autosuspend.sh` / `sxmo_suspend.sh`, gated by `/etc/bananarchy-no-deep-standby` (shipped present = disabled) and inert because `CONFIG_SUSPEND` is off. A full custom module tree rebuild is deliberately **not** planned: this firmware has no PSCI `SYSTEM_SUSPEND`, so `CONFIG_SUSPEND` would only give s2idle (`freeze`), not `mem` / DDR self-refresh, for <1 mA of saving (see `BATTERY-OPTIMIZATION-ANALYSIS.md` §14 and §17). Never force `sxmo.noidle`/`sxmo.nosuspend` from the session scripts and never reintroduce the infinite `sxmo_not_suspendable` wakelock. `/etc/bananarchy/` is root-only.
- **Image residue**: `rebuild-image.sh` strips `/var/cache/apk`, all `apk.log*` files, and unused gettext locale trees before `mke2fs` and aborts the build if any apk cache/log remains; never add an `apk` call after that guard.
- **No on-device compiler**: `scripts/rootfs-packages.txt` ships no `gcc`/`g++`/`musl-dev`/`make` and no Janet runtime (`janet`, `janet-dev`, `jpm`); cross-compile native code with `scripts/build-*.sh`. On-device development uses the Yabasic FFI SDK (`neoui.yab` / `neonet.yab`), which requires `yabasic`, `libffi`, `libneoui.so`, and `libcurl.so.4` — never remove those. `scripts/check-rebuild.sh` guards both sides.
- **Core tools**: `curl`, `bc`, `ed`, `rlwrap`, `mandoc`, `nano`, `less`, and `frotz` are pinned core tools asserted by `scripts/check-rebuild.sh`. Perl, Lua, optional Tcl extensions, and the `sqlite` CLI are excluded, while `tcl`, `python3`, `bash`, `luajit`, `gawk`, `jq`, `gojq`, and `quickjs` remain as hard runtime dependencies.
+125
View File
@@ -913,3 +913,128 @@ Fixes, without changing the long steady-state poll interval:
failure. **Config -> Sync net time** calls it via
`bananarchy-sync-net-time.sh` and shows a desktop notification, so the user
can always force a sync without a shell.
---
## 17. Battery longevity re-analysis (post-`85c6a7b` live measurement)
A fresh 60 s idle window was measured on 2026-11-08 at ~10.3 h uptime with the
panel dark (`brightness=0`, `bl_power=4`), Wi-Fi connected to
`OffOurStreets_`, USB RNDIS up, and both SIM applications `ready`. The phone
was charging at `540000` uA with no `current_now` and no coulomb counter, so
all results below are wakeup/IRQ/context-switch counts, not discharge mA.
`capacity` was 44%, `health=Good`, `voltage_now=4054397` uV and
`voltage_ocv` returned `No data available`.
### 17.1 Measurement caveat: modem registration anomaly
`msm-modem-uim-selection status` reported
`NAS_REG_STATE=not-registered-searching`, `SEC_NAS_REG_STATE=not-registered`,
`mmcli -L` returned `No modems were found`, and the slot mapping was
`PRIMARY_GW_SLOT=2` / `SECONDARY_GW_SLOT=1` (swapped relative to the earlier
verified `1` / `2` state). `AT+COPS?` returned `+COPS: 0` with no operator.
This is a separate functional issue; no PIN verification was attempted. A
searching modem can draw more RF current than a registered idle modem, so the
radio-related conclusions below are conservative and need a battery-powered
A/B run once registration is restored.
### 17.2 Baseline: the application processor is already near its floor
60 s, screen off, Wi-Fi up, both SIM applications ready:
| Source | Rate |
| --- | --- |
| `arch_timer` | 15.01/s |
| `arch_mem_timer` | 11.64/s |
| `mmc0` | 0.56/s |
| `smd-edge` | 0.52/s |
| `wcn36xx_rx` | 0.34/s |
| `wcn36xx_tx` | 0.11/s |
| `pm8916_vm_bms` | 0.02/s |
| CPU idle | 97.93% overall, 99.48% cpu0, 96.37% cpu1 |
| `cpu-sleep-0` entries | 12.47/s cpu0, 7.54/s cpu1 |
| WFI entries | 0.97/s cpu0, 1.05/s cpu1 |
Top context-switch deltas were kernel threads (`rcu_preempt` 5.35/s,
`kcompactd0` 1.97/s, four `kworker` threads 1.11/1.10/0.50/0.47/s), then
`NetworkManager` 0.37/s, `wpa_supplicant` 0.26/s, `nmcli device monitor`
0.11/s, `dbus-daemon` 0.11/s, `udevd` 0.06/s and `init` 0.06/s. All 26
preloaded `dwm-plugin` daemons and `Xorg` were absent from the top 30, which
confirms the zero-lag resident-plugin model is not the remaining drain.
Runtime PM was already effective: `1c00000.gpu`, both SDHCI hosts, SPI, DMA
controllers, IOMMU and the modem `bam-dmux` were suspended; genpd `mx`,
`mx_ao`, `cx` and all GDSCs were off, with only `cx_ao` on. GPU devfreq was
`simple_ondemand` at 409.6 MHz with a 100 ms poll. 21 clocks remained enabled,
including `bimc_ddr_clk_src`, `gcc_mss_q6_bimc_axi_clk`, USB HS clocks and the
serial-console `gcc_blsp1_uart1_apps_clk`. Regulators with users were the dummy
regulator, `s2`, `l5`, `l7`, `l8` and `l13`.
`/sys/power/state` was still 0 bytes, `/proc/device-tree/psci` absent,
cpuidle driver `qcom_spm` with WFI + `cpu-sleep-0`, `CONFIG_SUSPEND` off,
`CONFIG_NO_HZ_IDLE=y`, `CONFIG_HZ=300`, `CONFIG_PREEMPT=y`,
`CONFIG_PERF_EVENTS=y`, `CONFIG_FUNCTION_GRAPH_TRACER=y`,
`CONFIG_ENERGY_MODEL` off and `CONFIG_CPU_IDLE_GOV_MENU=y`. The ABI-breaking
config list from section 14 still applies; a full pmaports module tree rebuild
remains declined.
### 17.3 Two low-risk wins found and implemented
1. **The active zram swap used `zstd`, not the shipped `lz4` setting.**
`postmarketos-zram-swap` calls `/usr/bin/zramstart`, which sources
`/usr/share/misc/source_deviceinfo` and defaults
`deviceinfo_zram_swap_algo` to `zstd`; it ignores
`/etc/conf.d/zram-init`. Live `/sys/block/zram0/comp_algorithm` showed
`[zstd]`. All five `devices/*/deviceinfo*` files now set
`deviceinfo_zram_swap_algo="lz4"`, and the `zram-init` config carries a
compatibility note. This restores the intended U12/K13 CPU saving without
changing the kernel or module ABI.
2. **Proactive compaction kept `kcompactd0` awake.** The default
`vm.compaction_proactiveness=20` produced 1.97 context switches/s from
`kcompactd0`. A controlled 60 s A/B with
`vm.compaction_proactiveness=0` reduced that to 0.02/s and raised measured
CPU idle from 97.93% to 99.22%; combined timer IRQs fell from 26.65/s to
17.39/s. The A/B window also showed a 3.42/s `ci_hdrc_msm` USB IRQ from
SSH/charger activity, so this is a wakeup saving, not a measured mA
saving. `vm.compaction_proactiveness=0` is now set in
`etc/sysctl.d/99-bananarchy-power.conf` and
`etc/local.d/10-power-save.start`.
### 17.4 DSDS eco A/B was inconclusive without discharge current
With `DSDS_SECONDARY_MODE=eco` and `DSDS_PARK_DELAY=2`, the secondary GW
session parked cleanly (`secondary_parked=yes`, `SECONDARY_GW_SLOT=0`) and
restored on wake. The 60 s IRQ rates did not improve versus baseline
(`mmc0` 1.24/s, `wcn36xx_rx` 0.74/s, `smd-edge` 0.61/s), likely because the
modem was already searching and the measurement included policy/config file
writes. Eco mode remains an opt-in trade (SIM2 unreachable while parked); its
RF saving can only be quantified on battery power with a registered modem.
### 17.5 Remaining opportunities, in priority order
1. **Restore modem registration and the primary/secondary slot mapping.**
This is a functional prerequisite for any radio-power A/B measurement.
2. **Battery-powered A/B for `WIFI_LISTEN_INTERVAL=10`, `MODEM_DRX_MODE=6-9`
and `DSDS_SECONDARY_MODE=eco`.** All three are already configurable via
`/etc/bananarchy-power-policy.conf`; defaults stay conservative because
higher DRX modes and longer listen intervals delay inbound data, and
`AT$QCDRX=9` previously made the AT channel briefly unresponsive.
3. **Replace `nmcli device monitor` with NetworkManager dispatcher hooks.**
It accounts for 0.11 context switches/s and duplicates the dispatcher path
already used for DPM and time sync.
4. **`commit=60` on the rootfs mount.** Could cut a fraction of the 0.56/s
`mmc0` IRQs, but risks data loss on sudden power cut; deliberately not
shipped.
5. **Remove `earlycon console=ttyMSM0` from the cmdline.** Cmdline-only and
ABI-safe, would gate the 3.686 MHz UART clock, but removes the serial debug
lifeline; deliberately kept.
6. **PSCI `SYSTEM_SUSPEND` in lk2nd.** Still the only path to DDR self-refresh
and `mem` suspend. Until then `bimc_ddr_clk_src` stays enabled and no
kernel config change can fix it.
7. **AP-side Wi-Fi DTIM tuning.** Not controllable from the phone.
The AP and userspace are already close to their idle floor. Further 24 h
battery life has to come from modem/Wi-Fi RF policy, DDR self-refresh, or a
battery-powered measurement campaign; another kernel config trim or full
module tree rebuild is not justified.
+47
View File
@@ -9,6 +9,53 @@ Release versions follow the `<year-letter><MM><DD>` format (where `2026` is `a`,
---
## Unreleased — xkopher focus scrolling, fresh unlock clock, battery longevity re-analysis
- **xkopher link focus visibility**: `smallweb_plugin.cpp` now builds display
rows through a shared `buildRenderRows()` helper and maps the focused link
to its first wrapped row via `ensureFocusedLinkVisible()`. Jumping to the
previous/next link always scrolls the viewport to the link in both `WRAP`
and `NOWRAP` modes; with wrapping off it also resets horizontal scroll so
the link label cannot remain off-screen. Toggling wrap re-applies the same
scroll, and Page End now uses display-row count rather than logical-line
count. `prebuilt/sxmo-x11` and `overlay/rootfs` `smallweb.so` were rebuilt.
- **Fresh status bar clock after unlock**: `dmenu.c` had republished the root
status from cached `sxmo_status` files whenever a menu opened or T9 mode
changed. Because `sxmo_hook_statusbar.sh periodics` is suppressed while the
panel is dark, this could show a pre-lock time for up to the 300 s periodic
interval. `update_t9_status_indicator()` now refreshes `099-time` with the
current local time and writes `sxmo_status_bar_cache` before `XStoreName()`.
`sxmo_hook_unlock.sh` additionally calls `sxmo_hook_statusbar.sh time`
synchronously after display-on, and `state_change` always refreshes the
time file and forces a root-name update. Live reproduction: deliberately
setting `099-time` to `00:00` and opening the Config menu rewrote the root
name to `00:00`; after the fix the same test shows the current time.
- **Battery longevity re-analysis**: `BATTERY-OPTIMIZATION-ANALYSIS.md`
section 17 records a fresh 60 s screen-off measurement (97.93% CPU idle,
26.65 timer IRQs/s, 20 cpuidle SPC entries/s, 26 sleeping plugin daemons,
runtime-suspended GPU/SDHCI/SPI/DMA/IOMMU, 21 enabled clocks, no PSCI or
`/sys/power/state`). It also documents a modem registration anomaly
(`not-registered-searching`, `mmcli -L` empty, swapped GW slots) as a
measurement caveat; no PIN verification was attempted.
- **Two low-risk battery wins implemented**: all deviceinfo files now set
`deviceinfo_zram_swap_algo="lz4"` because the active
`postmarketos-zram-swap` service uses `/usr/bin/zramstart` (which defaults
to `zstd` and ignores `/etc/conf.d/zram-init`); live
`/sys/block/zram0/comp_algorithm` had shown `[zstd]`.
`vm.compaction_proactiveness=0` is now set in
`etc/sysctl.d/99-bananarchy-power.conf` and
`etc/local.d/10-power-save.start`: a controlled A/B reduced `kcompactd0`
from 1.97 to 0.02 context switches/s and raised CPU idle from 97.93% to
99.22%. DSDS `eco` parking was A/B tested but inconclusive without discharge
current; the conservative defaults remain unchanged.
- `scripts/check-rebuild.sh` guards wrapped-row focus scrolling, dmenu clock
refresh, the synchronous unlock refresh, `lz4` deviceinfo and the
compaction sysctl. `prebuilt/sxmo-x11` was rebuilt for the two changed
plugins and mirrored with `scripts/sync-prebuilt-overlay.sh`; the image and
live phone were redeployed and verified.
---
## Unreleased — manual network time sync from the Config menu
- **Config -> Sync net time**: a new menu item in the built-in dmenu Config
+6 -1
View File
@@ -23,7 +23,7 @@ This manual covers flashing, operating, and customizing **Bananarchy Linux** (`2
### 1.3 Core architecture highlights
1. **Pure X11 (`Xlibre` + `sxmo-de-dwm`) for `240x320` QVGA displays**:
- Uses a lightweight cross-compiled **Xlibre** server with `modesetting` KMS, partial-rectangle `ShadowFB` SPI updates, and zero Wayland overhead.
- **Patched `dwm`** provides a `240x320` vertical bottom-stack (`bstack`) layout, a 24px top status bar, a transparent `"Menu"` / `"Names"` desktop softkey bar, a native `ParentRelative` desktop datetime overlay (`Fira Code` 32pt `%H:%M` and 14pt `%a %d %b %Y` with 1px drop shadow, rendered directly by `dwm` with zero external Conky process overhead and automatic live timezone/wallpaper refresh), and `< 2 ms` handling of physical slider (`SW_LID`) and wake keys.
- **Patched `dwm`** provides a `240x320` vertical bottom-stack (`bstack`) layout, a 24px top status bar, a transparent `"Menu"` / `"Names"` desktop softkey bar, a native `ParentRelative` desktop datetime overlay (`Fira Code` 32pt `%H:%M` and 14pt `%a %d %b %Y` with 1px drop shadow, rendered directly by `dwm` with zero external Conky process overhead and automatic live timezone/wallpaper refresh), and `< 2 ms` handling of physical slider (`SW_LID`) and wake keys. The status bar clock is refreshed synchronously on unlock and whenever dmenu updates its input-method indicator, so it cannot keep showing a pre-lock time after the panel wakes.
2. **Preloaded resident DWM plugins (`< 2 ms` wakeup)**:
- Core phone applications (`dmenu`, `xdrawer`, `dialer`, `calllog`, `callscreen`, `contacts`, `sms`, `files`, `camera`, `themes`, `passcode`, `modem`, `networks`, `ringtones`, `wallpapers`, `music`, `sip`, `email`, `irc`, `tox`, `smallweb`, `webarchy`, `gps`, `privacy`, `engmenu`, `locker`) run as preloaded resident daemons (`dwm-plugin <name> --preload`) that sleep at 0% CPU and open instantaneously over FIFO/socket IPC.
- All UI elements — including the `dunst` notification daemon (`bananarchy-sync-dunst-theme`) — share the **NeoUI SDK (`libneoui.so` + `/usr/include/neoui.h`)** and a single **XRDB theming engine** (`~/.xthemes/*.xth` -> `~/.Xresources`) with 21 preinstalled color schemes, proportional font sizing (`theme.baseFontSize`), and live reload without restarting X11. NeoUI exposes both C++20 classes and a C-compatible FFI (`neoui_*`) for building custom native or scripted (`yabasic` via `~/Projects/neoui.yab`, `~/Projects/neoui_demo.yab`, and `~/Projects/bulls_cows.yab`, paired with **NeoNet** in `~/Projects/neonet.yab` and `~/Projects/neonet_demo.yab` for `libcurl` HTTP/HTTPS and TCP/TLS/UDP socket networking) `240x320` GUI applications — see [SDK.md](./SDK.md) for the complete API reference and examples.
@@ -274,6 +274,11 @@ All twenty-five phone applications are compiled as shared-object plugins (`/usr/
- **`1` and `7`**: scroll left / right (`4` columns when line wrapping is off)
- **`3` and `9`**: jump to top / bottom of page
- **`*`**: toggle line wrapping (`WRAP` / `NOWRAP`)
- **Link focus always scrolls the viewport**: jumping to the previous /
next link (or toggling wrap) scrolls the focused link into view using
the actual wrapped display rows, in both `WRAP` and `NOWRAP` modes.
With wrapping off, horizontal scroll is reset to the start of the link
label. Page End also uses display rows rather than logical lines.
- **`#`**: toggle light / dark reader theme
- **`0`**: reload current page
- **`Call (green)`**: open URL address bar (`*` cycles input mode; `Call` inside the address bar toggles `Gopher TLS`)
+3 -3
View File
@@ -16,9 +16,9 @@
## Key features
### System and hardware support
- **Mainline Linux 6.12 kernel**: custom patches and out-of-tree drivers for Qualcomm **Adreno 304 (`FD304`, 96 KB GMEM)** 3D GPU acceleration (`drm/msm` + `qcom-iommu`), Qualcomm QDSP6/Q6Voice audio routing, Dual-SIM modem control, the rear 2MP GalaxyCore `GC2395` / `GC2385` / `GC2365` camera (`/dev/video0`), the `SY7807` flashlight LED (`white:torch`), physical keypad/slider events, and clean PM8909 poweroff. The kernel image is built from `config-bananarchy-msm8909.armv7` with the known-good pmaports module ABI, and ships with idle-blanking power management; `BATTERY-OPTIMIZATION-ANALYSIS.md` records the measured idle state and explains why suspend-to-RAM is unavailable on this firmware (PSCI `SYSTEM_SUSPEND` missing) and why a full custom module tree rebuild is not worthwhile. Runtime Wi-Fi listen-interval, modem DRX and DSDS secondary-SIM power policies are configurable in `/etc/bananarchy-power-policy.conf`; see `MANUAL.md`.
- **Mainline Linux 6.12 kernel**: custom patches and out-of-tree drivers for Qualcomm **Adreno 304 (`FD304`, 96 KB GMEM)** 3D GPU acceleration (`drm/msm` + `qcom-iommu`), Qualcomm QDSP6/Q6Voice audio routing, Dual-SIM modem control, the rear 2MP GalaxyCore `GC2395` / `GC2385` / `GC2365` camera (`/dev/video0`), the `SY7807` flashlight LED (`white:torch`), physical keypad/slider events, and clean PM8909 poweroff. The kernel image is built from `config-bananarchy-msm8909.armv7` with the known-good pmaports module ABI, and ships with idle-blanking power management; `BATTERY-OPTIMIZATION-ANALYSIS.md` records the measured idle state and explains why suspend-to-RAM is unavailable on this firmware (PSCI `SYSTEM_SUSPEND` missing) and why a full custom module tree rebuild is not worthwhile. Section 17 adds a post-`a1107` re-analysis and two low-risk wins: the active zram swap now uses `lz4` instead of `zramstart`'s `zstd` default, and `vm.compaction_proactiveness=0` removes ~2 `kcompactd0` wakeups/s. Runtime Wi-Fi listen-interval, modem DRX and DSDS secondary-SIM power policies are configurable in `/etc/bananarchy-power-policy.conf`; see `MANUAL.md`.
- **Alpine Linux Edge base**: full access to the Alpine package ecosystem with `< 95 MB` idle RAM usage on 512 MB devices and full local root access out of the box.
- **Network time synchronisation**: `chronyd` uses `iburst` with long `minpoll 12 maxpoll 16` polls; `bananarchy-time-sync.sh` re-resolves the NTP pool and requests an immediate burst over chronyd's root-only Unix socket when NetworkManager brings a connection up, so the clock is set within seconds of boot or a Wi-Fi reconnect without shortening the battery-friendly steady-state interval. **Config -> Sync net time** forces a burst manually and reports the result when autosync is slow. See `MANUAL.md` section 5.7.
- **Network time synchronisation**: `chronyd` uses `iburst` with long `minpoll 12 maxpoll 16` polls; `bananarchy-time-sync.sh` re-resolves the NTP pool and requests an immediate burst over chronyd's root-only Unix socket when NetworkManager brings a connection up, so the clock is set within seconds of boot or a Wi-Fi reconnect without shortening the battery-friendly steady-state interval. **Config -> Sync net time** forces a burst manually and reports the result when autosync is slow. The status bar clock is also refreshed synchronously on unlock and by dmenu itself, so it cannot show a stale pre-lock time. See `MANUAL.md` section 5.7.
- **Pure X11 graphical stack with GPU acceleration**: cross-compiled **Xlibre** (`X11Libre/xserver`) display server offloading 2D/3D screen rendering to the **Adreno 304 GPU** via **Glamor, DRI3, GLX, and Mesa Freedreno (`FD304`, OpenGL 3.1 / OpenGL ES 3.0)** over `panel-mipi-dbi` KMSRO, paired with a customized **Sxmo (`sxmo-de-dwm`)** window manager (`240x320` vertical stack layout, native `ParentRelative` desktop clock and softkey bar without Conky overhead, `< 2 ms` slider/key wake latency, and zero Wayland overhead).
### Keypad-first user experience and native DWM plugins
@@ -43,7 +43,7 @@ Instead of spawning slow shell scripts for everyday phone tasks, Bananarchy runs
- **Email client (`xemail` / `xmail` / `email.so`)**: multi-account `IMAP4rev1`, `POP3`, and `SMTP` client (`Inbox`, `Compose`, `Accounts`) supporting implicit TLS, `STARTTLS`, and plain TCP, SASL `PLAIN`/`LOGIN`, MIME RFC 2047/Base64/Quoted-Printable decoding, offline inbox cache, full-screen message reader, and composer.
- **IRCv3 client (`xirc` / `irc.so`)**: multi-server IRC client (`Buffers`, `Chat`, `Servers`) with OpenSSL TLS, IRCv3 capability negotiation (`CAP LS 302`: `sasl`, `server-time`, `message-tags`, `multi-prefix`, `away-notify`, `account-notify`, `chghost`, `cap-notify`), `SASL PLAIN` authentication, slash commands, and resident background mode with highlight vibration alerts.
- **Tox / Trifa P2P messenger and audio call client (`xtox` / `tox.so`)**: encrypted P2P messenger (`Friends`, `Chat`, `My Tox ID`) built on `c-toxcore` (`libtoxcore.so.2`) with DHT + TCP relay bootstrap, friend requests, persistent message history, and `ToxAV` 48 kHz Opus voice calls integrated with `xcallscreen`.
- **Kopher SmallWeb browser (`xkopher` / `kopher` / `xsmallweb` / `smallweb.so`)**: multi-protocol SmallWeb client for **Gopher** (`gopher://`) with optional TLS (`gophers://`), **Gemini** (`gemini://`), **Spartan** (`spartan://`), and **Nex** (`nex://`), featuring WAP-style default keypad controls from [Kopher](https://code.luxferre.top/luxferre/kopher.git), user-adjustable keybindings (`~/.config/sxmo/smallweb_controls.tsv`), 10 bookmarks, and custom homepage support.
- **Kopher SmallWeb browser (`xkopher` / `kopher` / `xsmallweb` / `smallweb.so`)**: multi-protocol SmallWeb client for **Gopher** (`gopher://`) with optional TLS (`gophers://`), **Gemini** (`gemini://`), **Spartan** (`spartan://`), and **Nex** (`nex://`), featuring WAP-style default keypad controls from [Kopher](https://code.luxferre.top/luxferre/kopher.git), user-adjustable keybindings (`~/.config/sxmo/smallweb_controls.tsv`), 10 bookmarks, custom homepage support, and link focus that always scrolls the viewport to the focused link in both wrapped and unwrapped modes.
- **Webarchy Web browser (`webarchy` / `xwebarchy` / `webarchy.so`)**: full-featured HTML5/CSS3/JS web browser built on WPE / WebKit (`webkit2gtk-4.1` + `libwpe-1.0`) with Adreno 304 hardware acceleration (`WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS`, WebGL, accelerated 2D canvas, and 512 MB RAM pressure tuning), default KaiOS 4.0 User-Agent (`Mozilla/5.0 (Mobile; rv:123.0) Gecko/123.0 Firefox/123.0 KAIOS/4.0`) with preset and custom User-Agent override (`~/.config/sxmo/webarchy_ua.txt`), `UTF-8` default encoding fallback, `Noto Sans` / `Noto Serif` (`font-noto` + `font-noto-emoji`) as the default non-monospace browser fonts and `Fira Code` with OpenType ligatures as the monospace font, full GStreamer multimedia (`MediaSource` / MSE, WebAudio, inline HTML5 `<video>`/`<audio>` autoplay without user gesture requirements), unobtrusive bookmarking (`*HTTPS`/`*HTTP` header badge, `*`+`0-9` save / `#`+`0-9` load chords, and bookmark manager), and dual navigation modes (keypad link-stepping mode with NeoUI multi-tap form input by default, plus an optional `*#` accelerated mouse cursor emulation mode).
- **GPS reception test utility (`bananarchy-gps`) and OpenStreetMap navigator (`xgps` / `xmaps` / `xnav` / `gps.so`)**: CLI GNSS/GPS diagnostic tool (`bananarchy-gps status|enable|disable|nmea|watch`) and 3-tab NeoUI GPS navigator (`1:GPS Status`, `2:OSM Map`, `3:Nav/Search`) with live NMEA/QMI PDS satellite and 3GPP cell telemetry, interactive `240x212` OpenStreetMap slippy-map tile viewer with offline PNG tile cache (`~/.cache/sxmo/osm_tiles/`), Nominatim place search, saved waypoints, and OSRM turn-by-turn route geometry and step navigation.
- **Themes (`xthemes`), wallpapers (`xwallpapers`), and ringtones (`xringtones`)**: installable `.Xresources` color and font themes (`~/.xthemes/*.xth`, 21 preinstalled schemes including `LynxLair.xth`) with live zero-restart reload across the entire UI, `dunst` notification popups (`bananarchy-sync-dunst-theme`), and terminal, alongside dedicated managers for desktop wallpapers and 3-tab call ringtones & notification/SMS alerts (`1:Ringtone`, `2:Notif/SMS`, `3:Settings`, supporting standard audio, tracker modules, and Nokia RTTTL `.nrt`/`.rtttl`/`.rtx`, Ericsson eMelody `.emy`, and IrDA iMelody `.imy` monophonic ringtones via `/usr/bin/bananarchy-melody`, wired into `sxmo_notifs.sh` and `sxmo_hook_notification.sh`) with 3-level vibration control.
+3
View File
@@ -11,6 +11,9 @@ deviceinfo_dtb="qcom-msm8905-nokia-argon"
deviceinfo_append_dtb="true"
deviceinfo_arch="armv7"
deviceinfo_swap_size_recommended="512"
# postmarketos-zram-swap reads this via /usr/share/misc/source_deviceinfo.
# lz4 is much cheaper than zramstart's zstd default on a 512 MB Cortex-A7.
deviceinfo_zram_swap_algo="lz4"
# Device related
deviceinfo_chassis="handset"
+3
View File
@@ -8,6 +8,9 @@ deviceinfo_dtb="qcom-msm8905-nokia-beatles"
deviceinfo_append_dtb="true"
deviceinfo_arch="armv7"
deviceinfo_swap_size_recommended="512"
# postmarketos-zram-swap reads this via /usr/share/misc/source_deviceinfo.
# lz4 is much cheaper than zramstart's zstd default on a 512 MB Cortex-A7.
deviceinfo_zram_swap_algo="lz4"
# Device related
deviceinfo_chassis="handset"
+3
View File
@@ -11,6 +11,9 @@ deviceinfo_dtb="qcom-msm8909-nokia-sparkler"
deviceinfo_append_dtb="true"
deviceinfo_arch="armv7"
deviceinfo_swap_size_recommended="512"
# postmarketos-zram-swap reads this via /usr/share/misc/source_deviceinfo.
# lz4 is much cheaper than zramstart's zstd default on a 512 MB Cortex-A7.
deviceinfo_zram_swap_algo="lz4"
# Device related
deviceinfo_chassis="handset"
@@ -11,6 +11,9 @@ deviceinfo_dtb="qcom-msm8909-nokia-leo"
deviceinfo_append_dtb="true"
deviceinfo_arch="armv7"
deviceinfo_swap_size_recommended="512"
# postmarketos-zram-swap reads this via /usr/share/misc/source_deviceinfo.
# lz4 is much cheaper than zramstart's zstd default on a 512 MB Cortex-A7.
deviceinfo_zram_swap_algo="lz4"
# Device related
deviceinfo_chassis="handset"
+3
View File
@@ -8,6 +8,9 @@ deviceinfo_dtb="qcom-msm8905-nokia-coconut"
deviceinfo_append_dtb="true"
deviceinfo_arch="armv7"
deviceinfo_swap_size_recommended="512"
# postmarketos-zram-swap reads this via /usr/share/misc/source_deviceinfo.
# lz4 is much cheaper than zramstart's zstd default on a 512 MB Cortex-A7.
deviceinfo_zram_swap_algo="lz4"
# Device related
deviceinfo_chassis="handset"
+5 -1
View File
@@ -1,4 +1,8 @@
# zram settings...
# NOTE: the shipped postmarketos-zram-swap service uses /usr/bin/zramstart,
# which reads deviceinfo_zram_swap_algo from /usr/share/misc/source_deviceinfo.
# This file is kept for zram-init compatibility; keep algo0 in sync with the
# deviceinfo files (lz4, not zramstart's zstd default).
# SPDX-License-Identifier: GPL-2.0-only
# load zram kernel module on start?
@@ -136,7 +140,7 @@ args3=
type3=swap
flag3=
size3=512
algo3=zstd
algo3=lz4
labl3=zram_swap2
uuid3=
args3=
@@ -12,6 +12,8 @@ fi
{ echo 30 > /proc/sys/vm/stat_interval; } 2>/dev/null || true
{ echo 6000 > /proc/sys/vm/dirty_writeback_centisecs; } 2>/dev/null || true
{ echo 6000 > /proc/sys/vm/dirty_expire_centisecs; } 2>/dev/null || true
# Disable proactive compaction: kcompactd0 otherwise wakes ~2/s.
{ echo 0 > /proc/sys/vm/compaction_proactiveness; } 2>/dev/null || true
{ echo 0 > /proc/sys/kernel/nmi_watchdog; } 2>/dev/null || true
{ echo "1 4 1 1" > /proc/sys/kernel/printk; } 2>/dev/null || true
{ echo Y > /sys/module/workqueue/parameters/power_efficient; } 2>/dev/null || true
@@ -2,3 +2,7 @@
# VPN tunnels). Removes ND/MLD multicast that keeps Wi-Fi out of BMPS.
# The ipv6 module stays loaded for WireGuard/Tor and for ::1 on lo.
net.ipv6.conf.default.disable_ipv6=1
# Proactive compaction wakes kcompactd0 ~2/s on this 512 MB target. Measured
# with vm.compaction_proactiveness=0: CPU idle rose from 97.93% to 99.22%.
vm.compaction_proactiveness=0
Binary file not shown.
Binary file not shown.
@@ -501,6 +501,7 @@ is_screen_dark() {
}
sxmo_debug "$@"
force_bar=0
case "$1" in
network)
is_screen_dark && exit 0
@@ -514,6 +515,7 @@ case "$1" in
time)
is_screen_dark && exit 0
set_time 1
force_bar=1
;;
modem|volume)
is_screen_dark && exit 0
@@ -524,8 +526,11 @@ case "$1" in
;;
state_change)
set_state
# Always refresh the time file, even if this state-change raced ahead of
# display-on; dmenu reads these files directly after unlock.
set_time
force_bar=1
if ! is_screen_dark; then
set_time
set_inputmethod
if [ -z "$SXMO_NO_MODEM" ]; then
set_modem
@@ -570,7 +575,7 @@ if ! is_screen_dark && [ "${SXMO_WM:-dwm}" = "dwm" ] && command -v xsetroot >/de
_bar_cache="${XDG_RUNTIME_DIR:-/run/user/10000}/sxmo_status_bar_cache"
_bar_prev=""
[ -r "$_bar_cache" ] && { read -r _bar_prev < "$_bar_cache" 2>/dev/null || _bar_prev=""; }
if [ "$_bar" != "$_bar_prev" ]; then
if [ "$force_bar" = "1" ] || [ "$_bar" != "$_bar_prev" ]; then
printf '%s\n' "$_bar" > "$_bar_cache" 2>/dev/null || true
DISPLAY="${DISPLAY:-:0}" xsetroot -name "$_bar" 2>/dev/null || true
fi
@@ -14,6 +14,9 @@ if [ -z "$SXMO_DISABLE_LEDS" ]; then
fi
sxmo_wm.sh display on
# Refresh the clock synchronously: periodics are suppressed while dark and
# dmenu republishes the root status from these files as soon as it opens.
sxmo_hook_statusbar.sh time >/dev/null 2>&1 || true
( sxmo_hook_statusbar.sh state_change >/dev/null 2>&1 & )
if [ -z "$SXMO_NO_VIRTUAL_KEYBOARD" ]; then
sxmo_wm.sh inputevent touchscreen on
Binary file not shown.
Binary file not shown.
+53
View File
@@ -217,6 +217,59 @@ if ! grep -q 'var/lib/chrony' "$BASE_DIR/rebuild-image.sh"; then
fail "rebuild-image.sh no longer fixes chrony driftfile ownership"
fi
echo "[check] xkopher link focus visibility..."
SMALLWEB_SRC="$BASE_DIR/src/dwm-plugins/smallweb_plugin.cpp"
if ! grep -q 'buildRenderRows' "$SMALLWEB_SRC"; then
fail "smallweb_plugin.cpp lost its shared wrapped-row builder"
fi
if ! grep -q 'ensureFocusedLinkVisible' "$SMALLWEB_SRC"; then
fail "smallweb_plugin.cpp lost focused-link viewport scrolling"
fi
if grep -q 'scrollTopLine = std::max(0, static_cast<int>(i) - 4);' "$SMALLWEB_SRC"; then
fail "link focus still scrolls by logical line index instead of display rows"
fi
FOCUS_CALLS="$(grep -c 'ensureFocusedLinkVisible();' "$SMALLWEB_SRC" 2>/dev/null || echo 0)"
if [ "$FOCUS_CALLS" -lt 2 ]; then
fail "link focus and wrap toggle must both call ensureFocusedLinkVisible"
fi
echo "[check] Status bar clock freshness..."
DMENU_SRC="$BASE_DIR/src/sxmo-dmenu/dmenu.c"
UNLOCK_HOOK="$BASE_DIR/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_unlock.sh"
STATUS_HOOK="$BASE_DIR/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_statusbar.sh"
for token in refresh_status_time write_status_cache 099-time sxmo_status_bar_cache; do
if ! grep -q "$token" "$DMENU_SRC"; then
fail "dmenu.c no longer refreshes the status clock/cache ($token)"
fi
done
if ! grep -q 'sxmo_hook_statusbar.sh time' "$UNLOCK_HOOK"; then
fail "unlock hook no longer refreshes the clock synchronously"
fi
if ! grep -q 'force_bar' "$STATUS_HOOK"; then
fail "statusbar hook no longer forces a root-name refresh on unlock"
fi
for f in "$UNLOCK_HOOK" "$STATUS_HOOK"; do
if ! sh -n "$f" 2>/dev/null; then
fail "shell syntax: ${f#$BASE_DIR/}"
fi
done
echo "[check] Battery longevity settings..."
for f in "$BASE_DIR"/devices/*/deviceinfo "$BASE_DIR"/devices/*/deviceinfo.nokia-leo; do
[ -f "$f" ] || continue
if ! grep -q 'deviceinfo_zram_swap_algo="lz4"' "$f"; then
fail "${f#$BASE_DIR/} no longer selects the lz4 zram algorithm"
fi
done
if ! grep -q 'vm.compaction_proactiveness=0' \
"$BASE_DIR/overlay/rootfs/etc/sysctl.d/99-bananarchy-power.conf"; then
fail "sysctl.d no longer disables proactive compaction"
fi
if ! grep -q 'compaction_proactiveness' \
"$BASE_DIR/overlay/rootfs/etc/local.d/10-power-save.start"; then
fail "10-power-save.start no longer disables proactive compaction"
fi
echo "[check] Docker availability..."
if ! command -v docker >/dev/null 2>&1; then
fail "docker is not installed"
+72 -39
View File
@@ -200,6 +200,44 @@ struct PageDocument {
std::vector<LinkItem> links;
};
// Display geometry shared by rendering and link-focus scrolling. Wrapped
// pages have more display rows than logical lines, so focus must be mapped
// through the same expansion that render() uses.
constexpr int kContentY = 36;
constexpr int kStatusY = 296 - static_cast<int>(NEO_SOFTBAR_H) - 18;
constexpr int kContentH = kStatusY - kContentY;
constexpr int kLineH = 16;
constexpr int kMaxVisLines = kContentH / kLineH;
constexpr int kWrapCols = 30;
struct RenderRow {
std::string text;
int linkIndex;
bool isHeading;
bool isQuote;
bool isError;
};
std::vector<RenderRow> buildRenderRows(const PageDocument& doc,
bool wrapLines) {
std::vector<RenderRow> rows;
for (const auto& dl : doc.lines) {
if (!wrapLines || dl.text.size() <= static_cast<size_t>(kWrapCols)) {
rows.push_back({dl.text, dl.linkIndex, dl.isHeading, dl.isQuote,
dl.isError});
} else {
size_t pos = 0;
while (pos < dl.text.size()) {
size_t take = std::min<size_t>(kWrapCols, dl.text.size() - pos);
rows.push_back({dl.text.substr(pos, take), dl.linkIndex,
dl.isHeading, dl.isQuote, dl.isError});
pos += take;
}
}
}
return rows;
}
void parseGophermap(const std::string& raw, const std::string& scheme,
PageDocument& doc) {
std::istringstream iss(raw);
@@ -642,16 +680,31 @@ int smallweb_run_main(int argc, char** argv) {
// Load initial homepage (bookmark #0 or about:kopher)
navigateTo(!bookmarks[0].empty() ? bookmarks[0] : "about:kopher");
// Keep the focused link visible in the actual display rows. With wrapping
// on, one logical line can become several rows; with wrapping off, a stale
// horizontal offset can hide the start of the link label.
auto ensureFocusedLinkVisible = [&]() {
if (currentDoc.links.empty() || focusedLinkIdx < 0 ||
focusedLinkIdx >= static_cast<int>(currentDoc.links.size())) return;
std::vector<RenderRow> rows = buildRenderRows(currentDoc, wrapLines);
int firstRow = -1;
for (int i = 0; i < static_cast<int>(rows.size()); ++i) {
if (rows[i].linkIndex == focusedLinkIdx) {
firstRow = i;
break;
}
}
if (firstRow < 0) return;
int maxTop = std::max(0, static_cast<int>(rows.size()) - kMaxVisLines);
scrollTopLine = std::clamp(std::max(0, firstRow - 4), 0, maxTop);
if (!wrapLines) scrollLeftCol = 0;
};
auto focusLinkRelative = [&](int delta) {
if (currentDoc.links.empty()) return;
int cnt = static_cast<int>(currentDoc.links.size());
focusedLinkIdx = (focusedLinkIdx + delta + cnt) % cnt;
for (size_t i = 0; i < currentDoc.lines.size(); ++i) {
if (currentDoc.lines[i].linkIndex == focusedLinkIdx) {
scrollTopLine = std::max(0, static_cast<int>(i) - 4);
break;
}
}
ensureFocusedLinkVisible();
};
auto render = [&]() {
@@ -673,39 +726,17 @@ int smallweb_run_main(int argc, char** argv) {
neoui_draw_header(kIconGlobe, NEO_TEXT_GREEN,
currentDoc.hostTitle.c_str(), protoBadge.c_str());
constexpr int kContentY = 36;
constexpr int kStatusY = 296 - NEO_SOFTBAR_H - 18;
constexpr int kContentH = kStatusY - kContentY;
constexpr int kLineH = 16;
int maxVisLines = kContentH / kLineH;
int maxVisLines = kMaxVisLines;
// Expand wrapped lines if wrapLines is enabled
struct RenderRow {
std::string text;
int linkIndex;
bool isHeading;
bool isQuote;
bool isError;
};
std::vector<RenderRow> rows;
for (const auto& dl : currentDoc.lines) {
if (!wrapLines || dl.text.size() <= 30) {
std::string sliced = dl.text;
if (!wrapLines && scrollLeftCol > 0) {
if (static_cast<size_t>(scrollLeftCol) < sliced.size()) {
sliced = sliced.substr(scrollLeftCol);
} else {
sliced.clear();
}
}
rows.push_back({sliced, dl.linkIndex, dl.isHeading, dl.isQuote, dl.isError});
} else {
size_t pos = 0;
while (pos < dl.text.size()) {
size_t take = std::min<size_t>(30, dl.text.size() - pos);
rows.push_back({dl.text.substr(pos, take), dl.linkIndex,
dl.isHeading, dl.isQuote, dl.isError});
pos += take;
// Build the same display rows used by link-focus scrolling, then apply
// horizontal slicing only in no-wrap mode.
std::vector<RenderRow> rows = buildRenderRows(currentDoc, wrapLines);
if (!wrapLines && scrollLeftCol > 0) {
for (auto& r : rows) {
if (static_cast<size_t>(scrollLeftCol) < r.text.size()) {
r.text = r.text.substr(scrollLeftCol);
} else {
r.text.clear();
}
}
}
@@ -1022,6 +1053,7 @@ int smallweb_run_main(int argc, char** argv) {
} else if (ch == ctrls.keyToggleWrap) {
wrapLines = !wrapLines;
scrollLeftCol = 0;
ensureFocusedLinkVisible();
} else if (ch == ctrls.keyLineStart) {
scrollLeftCol = 0;
} else if (ch == ctrls.keyLineEnd) {
@@ -1029,7 +1061,8 @@ int smallweb_run_main(int argc, char** argv) {
} else if (ch == ctrls.keyPageTop) {
scrollTopLine = 0;
} else if (ch == ctrls.keyPageEnd) {
scrollTopLine = static_cast<int>(currentDoc.lines.size());
scrollTopLine = static_cast<int>(
buildRenderRows(currentDoc, wrapLines).size());
}
render();
}
+58 -6
View File
@@ -327,30 +327,81 @@ t9_mode_badge(int mode)
}
}
static void
refresh_status_time(const char *status_dir)
{
char path[512], tbuf[128];
const char *fmt = getenv("SXMO_STATUS_DATE_FORMAT");
time_t now;
struct tm lt;
FILE *fp;
if (!fmt || !*fmt)
fmt = "%H:%M";
now = time(NULL);
if (!localtime_r(&now, &lt))
return;
if (!strftime(tbuf, sizeof(tbuf), fmt, &lt))
return;
snprintf(path, sizeof(path), "%s/099-time", status_dir);
fp = fopen(path, "w");
if (fp) {
fprintf(fp, " %s\n", tbuf);
fclose(fp);
}
}
static void
write_status_cache(const char *base, const char *status_line)
{
char path[512];
FILE *fp;
snprintf(path, sizeof(path), "%s/sxmo_status_bar_cache", base);
fp = fopen(path, "w");
if (fp) {
fprintf(fp, "%s\n", status_line);
fclose(fp);
}
}
static void
update_t9_status_indicator(void)
{
const char *rdir = getenv("XDG_RUNTIME_DIR");
const char *base = (rdir && rdir[0]) ? rdir : "/run/user/10000";
const char *status_name = getenv("SXMO_STATUS_NAME");
const char *badge = t9_mode_badge(t9_mode);
char path[256];
char path[512], status_dir[512];
FILE *fp;
if (!status_name || !*status_name)
status_name = "default";
snprintf(path, sizeof(path), "%s/sxmo_status", base);
mkdir(path, 0755);
snprintf(status_dir, sizeof(status_dir), "%s/sxmo_status/%s", base,
status_name);
mkdir(status_dir, 0755);
snprintf(path, sizeof(path), "%s/sxmo_t9_mode", base);
FILE *fp = fopen(path, "w");
fp = fopen(path, "w");
if (fp) {
fprintf(fp, "%s\n", badge);
fclose(fp);
}
snprintf(path, sizeof(path), "%s/sxmo_status/default/005-input-method", base);
snprintf(path, sizeof(path), "%s/005-input-method", status_dir);
fp = fopen(path, "w");
if (fp) {
fprintf(fp, "%s\n", badge);
fclose(fp);
}
/* The statusbar hook skips periodics while the panel is dark. Refresh the
* clock here so opening dmenu or changing T9 mode after unlock cannot
* republish a stale root WM_NAME from the cached status files. */
refresh_status_time(status_dir);
if (dpy && root) {
char status_dir[256];
snprintf(status_dir, sizeof(status_dir), "%s/sxmo_status/default", base);
DIR *dir = opendir(status_dir);
if (dir) {
char names[32][64];
@@ -377,7 +428,7 @@ update_t9_status_indicator(void)
size_t pos = 0;
status_line[0] = '\0';
for (int i = 0; i < count; i++) {
char fpath[320];
char fpath[640];
snprintf(fpath, sizeof(fpath), "%s/%s", status_dir, names[i]);
FILE *sfp = fopen(fpath, "r");
if (!sfp)
@@ -398,6 +449,7 @@ update_t9_status_indicator(void)
fclose(sfp);
}
if (pos > 0) {
write_status_cache(base, status_line);
XStoreName(dpy, root, status_line);
XFlush(dpy);
}