Remove unnecessary background services and polling loops to improve battery life
This commit is contained in:
1 parent
726500085a
commit
68cf9c515b
17 files changed
+159
-22
No files matched your search
@@ -34,6 +34,8 @@ Release versions follow the `<year-letter><MM><DD>` 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.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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 || true
|
||||
|
||||
# Monitor the battery
|
||||
superctl start sxmo_battery_monitor
|
||||
|
||||
# It watch network changes and update the status bar icon by example
|
||||
superctl start sxmo_networkmonitor
|
||||
|
||||
|
||||
@@ -67,18 +67,12 @@ mainloop() {
|
||||
echo "$line" | grep -qE "^signal" && sxmo_modem.sh checkfornewtexts
|
||||
done &
|
||||
|
||||
# Check for new texts periodically
|
||||
sxmo_run_aligned.sh 300 sxmo_modem.sh checkfornewtexts &
|
||||
|
||||
# Monitor for finished calls
|
||||
dbus-monitor --system "interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',arg0='org.freedesktop.ModemManager1.Call'" |
|
||||
while read -r line; do
|
||||
echo "$line" | grep -qE "^signal" && sxmo_modem.sh checkforfinishedcalls
|
||||
done &
|
||||
|
||||
# Periodically remove finished calls
|
||||
sxmo_run_aligned.sh 300 sxmo_modem.sh checkforfinishedcalls &
|
||||
|
||||
# Monitor for modem state change
|
||||
dbus-monitor --system "interface='org.freedesktop.ModemManager1.Modem',type='signal',member='StateChanged'" |
|
||||
while read -r line; do
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
[D-BUS Service]
|
||||
Name=org.freedesktop.UPower
|
||||
Exec=/bin/false
|
||||
User=root
|
||||
@@ -46,12 +46,7 @@ if [ -n "$sysfs_dir" ] && [ -r "$sysfs_dir/capacity" ] && [ -r "$sysfs_dir/statu
|
||||
*) state="unknown" ;;
|
||||
esac
|
||||
else
|
||||
data="$(upower -i "$object" | grep . | sed -e 's|^ \+||' -e 's|: \+|:|')"
|
||||
type="$(printf "%b" "$data" | grep -m1 -v : | sed -e 's|^ \+||')"
|
||||
[ "$type" = "battery" ] || exit 0
|
||||
name="$(printf "%b" "$data" | grep "^native-path:" | cut -d: -f2)"
|
||||
state="$(printf "%b" "$data" | grep "^state:" | cut -d: -f2)"
|
||||
percentage="$(printf "%b" "$data" | grep "^percentage:" | cut -d: -f2 | cut -d% -f1)"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "$name" ] || [ -z "$state" ] || [ -z "$percentage" ] || [ "$state" = "unknown" ]; then
|
||||
|
||||
@@ -76,7 +76,6 @@ 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 [ "$(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
|
||||
|
||||
# Monitor the battery
|
||||
superctl start sxmo_battery_monitor
|
||||
|
||||
# It watch network changes and update the status bar icon by example
|
||||
superctl start sxmo_networkmonitor
|
||||
|
||||
|
||||
@@ -520,6 +520,7 @@ case "$1" in
|
||||
set_state
|
||||
set_time
|
||||
set_inputmethod
|
||||
sxmo_hook_battery.sh 2>/dev/null || true
|
||||
;;
|
||||
periodics) # 55 s loop
|
||||
set_time
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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"
|
||||
|
||||
|
||||
@@ -10,8 +10,13 @@
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <dirent.h>
|
||||
#include <dlfcn.h>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <sys/stat.h>
|
||||
#include <vector>
|
||||
|
||||
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<std::string> 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<OpenDisplayFn>(::dlsym(x11Handle, "XOpenDisplay")) : nullptr;
|
||||
static auto fnDefaultRoot = x11Handle ? reinterpret_cast<DefaultRootWindowFn>(::dlsym(x11Handle, "XDefaultRootWindow")) : nullptr;
|
||||
static auto fnStoreName = x11Handle ? reinterpret_cast<StoreNameFn>(::dlsym(x11Handle, "XStoreName")) : nullptr;
|
||||
static auto fnCloseDisplay = x11Handle ? reinterpret_cast<CloseDisplayFn>(::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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user