diff --git a/CHANGELOG.md b/CHANGELOG.md index 0356f8a..c358f98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,8 @@ Release versions follow the `
` format (where `2026` is `a`, - Added direct C-level `_BANANARCHY_DWM_CMD` IPC between `dmenu` and `dwm` for instant window management (`Kill window`, `Close Terminal`, `Move to WS 1..4`, `Go to WS 1..4`, `Shift stack`, `Swap stack`, `Toggle Layout`) and restored application context menus (`Right softkey` inside `st`, `nano`, and X11 apps). - Updated the `fcitx5` `superd` service wrapper (`bananarchy-fcitx5.sh`) and XIM environment propagation across `st`, `dmenu`, and `dwm-plugin` so T9 keypad input stays supervised and active across all terminal and menu sessions. - Removed the non-applicable `Toggle Bar` entry from the `Config` menu. +- **Battery life and background service optimizations**: + - Removed `upowerd` and `sxmo_battery_monitor` (eliminating 3.5-second D-Bus broadcasts and shell forks in favor of direct `sysfs` `/sys/class/power_supply/` reads), `sxmo-x11-status` (updating the X11 root statusbar directly from `sxmo_hook_statusbar.sh`, `fcitx5-t9`, and `dmenu`), redundant 5-minute `mmcli` polling loops in `sxmo_modemmonitor.sh`, eMMC `/swapfile` (relying exclusively on compressed RAM `/dev/zram0`), `hkdm`, `haveged`, `iio-sensor-proxy`, `sleep-inhibitor`, `kill-plymouth`, `nftables`, `logbookd`, `openrc-user`, and unused `tty2`–`tty6` / `ttyMSM0` `getty` instances. --- diff --git a/overlay/rootfs/etc/inittab b/overlay/rootfs/etc/inittab new file mode 100644 index 0000000..dc868cc --- /dev/null +++ b/overlay/rootfs/etc/inittab @@ -0,0 +1,14 @@ +# /etc/inittab + +::sysinit:/sbin/openrc sysinit +::sysinit:/sbin/openrc boot +::wait:/sbin/openrc default + +# Keep a single console getty on tty1 +tty1::respawn:/sbin/getty 38400 tty1 + +# Stuff to do for the 3-finger salute +::ctrlaltdel:/sbin/reboot + +# Stuff to do before rebooting +::shutdown:/sbin/openrc shutdown diff --git a/overlay/rootfs/home/user/.config/sxmo/hooks/sxmo_hook_start.sh b/overlay/rootfs/home/user/.config/sxmo/hooks/sxmo_hook_start.sh index 1d0579c..cf64ada 100755 --- a/overlay/rootfs/home/user/.config/sxmo/hooks/sxmo_hook_start.sh +++ b/overlay/rootfs/home/user/.config/sxmo/hooks/sxmo_hook_start.sh @@ -76,9 +76,8 @@ superctl start dunst # load X11 dwm services [ "$(command -v sxmo_xob)" ] && superctl start sxmo_xob -pidof -s sxmo_status_xsetroot.sh >/dev/null 2>&1 || superctl start sxmo-x11-status [ "$(command -v bonsaid)" ] && superctl start bonsaid -if ! pidof -s fcitx5 >/dev/null 2>&1 && [ "$(command -v fcitx5)" ]; then +if [ "$(command -v fcitx5)" ]; then superctl start fcitx5 fi [ -n "$SXMO_MONITOR" ] && xrandr --output "$SXMO_MONITOR" --primary @@ -109,9 +108,6 @@ fi # Start the desktop widget (e.g. clock) pidof -s conky >/dev/null 2>&1 || DISPLAY=:0 CONKY_DPY=:0 conky -c /home/user/.config/sxmo/conky.conf -d >/dev/null 2>&1 /dev/null 2>&1 || superctl start sxmo-x11-status [ "$(command -v bonsaid)" ] && superctl start bonsaid if [ "$(command -v fcitx5)" ]; then superctl start fcitx5 @@ -109,9 +108,6 @@ fi # Start the desktop widget (e.g. clock) pidof -s conky >/dev/null 2>&1 || DISPLAY=:0 CONKY_DPY=:0 conky -c /home/user/.config/sxmo/conky.conf -d >/dev/null 2>&1 /dev/null || true ;; periodics) # 55 s loop set_time diff --git a/prebuilt/fcitx5-t9/usr/lib/fcitx5/libt9.so b/prebuilt/fcitx5-t9/usr/lib/fcitx5/libt9.so index 6398d78..7ac4805 100755 Binary files a/prebuilt/fcitx5-t9/usr/lib/fcitx5/libt9.so and b/prebuilt/fcitx5-t9/usr/lib/fcitx5/libt9.so differ diff --git a/prebuilt/fcitx5-t9/usr/lib/fcitx5/t9.so b/prebuilt/fcitx5-t9/usr/lib/fcitx5/t9.so index 6398d78..7ac4805 100755 Binary files a/prebuilt/fcitx5-t9/usr/lib/fcitx5/t9.so and b/prebuilt/fcitx5-t9/usr/lib/fcitx5/t9.so differ diff --git a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/dmenu.so b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/dmenu.so index adca216..0623463 100755 Binary files a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/dmenu.so and b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/dmenu.so differ diff --git a/scripts/apply-bananarchy-overlay.sh b/scripts/apply-bananarchy-overlay.sh index dea7ae2..1e3e64f 100755 --- a/scripts/apply-bananarchy-overlay.sh +++ b/scripts/apply-bananarchy-overlay.sh @@ -132,7 +132,20 @@ rm -rf \ "$TARGET_ROOTFS/usr/share/wallpapers/postmarketos.jpg" \ "$TARGET_ROOTFS/usr/share/wallpapers/bananarchy.jpg" \ "$TARGET_ROOTFS/usr/share/wallpapers/bananarchy-240x240.png" \ - "$TARGET_ROOTFS/usr/share/wallpapers/bananarchy-landscape.png" + "$TARGET_ROOTFS/usr/share/wallpapers/bananarchy-landscape.png" \ + "$TARGET_ROOTFS/etc/runlevels/default/hkdm" \ + "$TARGET_ROOTFS/etc/runlevels/default/haveged" \ + "$TARGET_ROOTFS/etc/runlevels/default/iio-sensor-proxy" \ + "$TARGET_ROOTFS/etc/runlevels/default/sleep-inhibitor" \ + "$TARGET_ROOTFS/etc/runlevels/default/kill-plymouth" \ + "$TARGET_ROOTFS/etc/runlevels/default/swapfile" \ + "$TARGET_ROOTFS/etc/runlevels/default/nftables" \ + "$TARGET_ROOTFS/etc/runlevels/boot/logbookd" \ + "$TARGET_ROOTFS/etc/init.d/user.user" \ + "$TARGET_ROOTFS/usr/share/superd/services/sxmo_battery_monitor.service" \ + "$TARGET_ROOTFS/usr/share/superd/services/sxmo-x11-status.service" \ + "$TARGET_ROOTFS/swapfile" \ + "$TARGET_ROOTFS/var/log/logbookd.db"* mkdir -p "$TARGET_ROOTFS/var/lib/tinydm" ln -sf /usr/share/xsessions/sxmo.desktop "$TARGET_ROOTFS/var/lib/tinydm/default-session.desktop" diff --git a/src/fcitx5-t9/src/t9.cpp b/src/fcitx5-t9/src/t9.cpp index e752117..b61056c 100644 --- a/src/fcitx5-t9/src/t9.cpp +++ b/src/fcitx5-t9/src/t9.cpp @@ -10,8 +10,13 @@ #include #include #include +#include +#include +#include +#include #include #include +#include namespace { @@ -233,6 +238,67 @@ void writeStatusIndicator(const std::string& badge) { std::fprintf(fp, "%s\n", badge.c_str()); std::fclose(fp); } + + DIR* dir = ::opendir(statusDir.c_str()); + if (!dir) { + return; + } + std::vector names; + while (struct dirent* ent = ::readdir(dir)) { + if (ent->d_name[0] == '.') { + continue; + } + names.emplace_back(ent->d_name); + } + ::closedir(dir); + std::sort(names.begin(), names.end()); + + std::string statusLine; + char lineBuf[256]; + for (const auto& name : names) { + std::string fpath = statusDir + "/" + name; + FILE* fp = std::fopen(fpath.c_str(), "r"); + if (!fp) { + continue; + } + if (std::fgets(lineBuf, sizeof(lineBuf), fp)) { + size_t len = std::strlen(lineBuf); + while (len > 0 && (lineBuf[len - 1] == '\n' || lineBuf[len - 1] == '\r')) { + lineBuf[--len] = '\0'; + } + if (len > 0) { + if (!statusLine.empty()) { + statusLine.push_back(' '); + } + statusLine.append(lineBuf, len); + } + } + std::fclose(fp); + } + + if (statusLine.empty()) { + return; + } + + using OpenDisplayFn = void* (*)(const char*); + using DefaultRootWindowFn = unsigned long (*)(void*); + using StoreNameFn = int (*)(void*, unsigned long, const char*); + using CloseDisplayFn = int (*)(void*); + + static void* x11Handle = ::dlopen("libX11.so.6", RTLD_LAZY | RTLD_LOCAL); + static auto fnOpenDisplay = x11Handle ? reinterpret_cast(::dlsym(x11Handle, "XOpenDisplay")) : nullptr; + static auto fnDefaultRoot = x11Handle ? reinterpret_cast(::dlsym(x11Handle, "XDefaultRootWindow")) : nullptr; + static auto fnStoreName = x11Handle ? reinterpret_cast(::dlsym(x11Handle, "XStoreName")) : nullptr; + static auto fnCloseDisplay = x11Handle ? reinterpret_cast(::dlsym(x11Handle, "XCloseDisplay")) : nullptr; + + if (fnOpenDisplay && fnDefaultRoot && fnStoreName && fnCloseDisplay) { + const char* disp = std::getenv("DISPLAY"); + void* x11Dpy = fnOpenDisplay((disp && disp[0]) ? disp : ":0"); + if (x11Dpy) { + fnStoreName(x11Dpy, fnDefaultRoot(x11Dpy), statusLine.c_str()); + fnCloseDisplay(x11Dpy); + } + } } } // namespace diff --git a/src/sxmo-dmenu/dmenu.c b/src/sxmo-dmenu/dmenu.c index 0bc8320..8003b62 100644 --- a/src/sxmo-dmenu/dmenu.c +++ b/src/sxmo-dmenu/dmenu.c @@ -278,6 +278,62 @@ update_t9_status_indicator(void) fprintf(fp, "%s\n", badge); fclose(fp); } + + 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]; + int count = 0; + struct dirent *ent; + while ((ent = readdir(dir)) != NULL && count < 32) { + if (ent->d_name[0] == '.') + continue; + snprintf(names[count], sizeof(names[count]), "%s", ent->d_name); + count++; + } + closedir(dir); + for (int i = 0; i < count - 1; i++) { + for (int j = i + 1; j < count; j++) { + if (strcmp(names[i], names[j]) > 0) { + char tmp[64]; + memcpy(tmp, names[i], sizeof(tmp)); + memcpy(names[i], names[j], sizeof(names[i])); + memcpy(names[j], tmp, sizeof(names[j])); + } + } + } + char status_line[512]; + size_t pos = 0; + status_line[0] = '\0'; + for (int i = 0; i < count; i++) { + char fpath[320]; + snprintf(fpath, sizeof(fpath), "%s/%s", status_dir, names[i]); + FILE *sfp = fopen(fpath, "r"); + if (!sfp) + continue; + char lbuf[128]; + if (fgets(lbuf, sizeof(lbuf), sfp)) { + size_t len = strlen(lbuf); + while (len > 0 && (lbuf[len - 1] == '\n' || lbuf[len - 1] == '\r')) + lbuf[--len] = '\0'; + if (len > 0 && pos + len + 2 < sizeof(status_line)) { + if (pos > 0) + status_line[pos++] = ' '; + memcpy(status_line + pos, lbuf, len); + pos += len; + status_line[pos] = '\0'; + } + } + fclose(sfp); + } + if (pos > 0) { + XStoreName(dpy, root, status_line); + XFlush(dpy); + } + } + } } static void