Port Quagr NeoUI pager plugin, opt-in receiver daemon, and cover alerts

- Port Quagr (<=30-byte SHA-256 + XOR + checksum) as C++20 NeoUI DWM plugin quagr.so (xquagr / quagr) across all targets with 3-tab UI (Receive, Send, Config) and independent Rx/Tx Passphrase or Raw 64-Hex key support.
- Enforce strict receiver autostart gating in quagr_plugin_init and --preload (starts only when autostart_rx=1 and a valid Rx key/passphrase is set) with atomic $SXMO_NOTIFDIR system notification emission and duress-mode blocking.
- Integrate QUAGR/QUAGR_CLEAR full-message wrapped rendering, extended ASCII 5x7 glyphs, persistent hold, and any-side-button dismissal into bananarchy-cover-idle and bananarchy-cover-event.sh for nokia-beatles.
- Rebuild and pin a1120 (cocojamboo) images and release archives for nokia-argon, nokia-beatles, nokia-coconut, and nokia-sparkler, and add scripts/test-quagr.py.
This commit is contained in:
Luxferre committed 2026-11-16 17:36:05 +02:00
1 parent 0d8047ddfe
commit f6b42ff604
81 files changed
+3182 -58

No files matched your search

+181 -28
View File
@@ -303,6 +303,13 @@ static const struct glyph font[] = {
{'!', {0x00, 0x00, 0x5f, 0x00, 0x00}}, {'?', {0x02, 0x01, 0x51, 0x09, 0x06}},
{'_', {0x40, 0x40, 0x40, 0x40, 0x40}}, {'[', {0x00, 0x7f, 0x41, 0x41, 0x00}},
{']', {0x00, 0x41, 0x41, 0x7f, 0x00}}, {'\'', {0x00, 0x05, 0x03, 0x00, 0x00}},
{'@', {0x32, 0x49, 0x79, 0x41, 0x3e}}, {'$', {0x24, 0x2a, 0x7f, 0x2a, 0x12}},
{'&', {0x36, 0x49, 0x55, 0x22, 0x50}}, {'=', {0x14, 0x14, 0x14, 0x14, 0x14}},
{'"', {0x00, 0x07, 0x00, 0x07, 0x00}}, {';', {0x00, 0x56, 0x36, 0x00, 0x00}},
{'<', {0x08, 0x14, 0x22, 0x41, 0x00}}, {'>', {0x00, 0x41, 0x22, 0x14, 0x08}},
{'~', {0x08, 0x04, 0x08, 0x10, 0x08}}, {'^', {0x04, 0x02, 0x01, 0x02, 0x04}},
{'`', {0x00, 0x01, 0x02, 0x04, 0x00}}, {'\\', {0x02, 0x04, 0x08, 0x10, 0x20}},
{'{', {0x00, 0x08, 0x36, 0x41, 0x00}}, {'}', {0x00, 0x41, 0x36, 0x08, 0x00}},
{' ', {0x00, 0x00, 0x00, 0x00, 0x00}},
};
@@ -515,6 +522,73 @@ static void draw_fit_centered(struct frame *fb, const char *text, int y,
frame_text_centered(fb, buf, y, scale, color);
}
static void draw_wrapped_centered(struct frame *fb, const char *text,
int area_top, int area_bottom,
int pref_scale, uint32_t color)
{
char clean[192];
char lines[6][48];
int scale = pref_scale > 0 ? pref_scale : 2;
int max_lines;
int line_count = 0;
int i;
if(!text || !*text)
return;
sanitize_cover_text(text, clean, sizeof(clean));
if(!clean[0])
return;
for(;; scale = 1) {
int max_chars = ((int)fb->width - 16) / (6 * scale);
int row_h = 7 * scale + (scale > 1 ? 8 : 5);
const char *p = clean;
if(max_chars < 1)
max_chars = 1;
if(max_chars >= (int)sizeof(lines[0]))
max_chars = (int)sizeof(lines[0]) - 1;
max_lines = (area_bottom - area_top) / row_h;
if(max_lines < 1)
max_lines = 1;
if(max_lines > 6)
max_lines = 6;
line_count = 0;
while(*p && line_count < max_lines) {
int rem = (int)strlen(p);
int take = rem <= max_chars ? rem : max_chars;
if(rem > max_chars) {
int sp = -1;
int k;
for(k = take; k > 0; k--) {
if(p[k] == ' ') {
sp = k;
break;
}
}
if(sp > 0)
take = sp;
}
memcpy(lines[line_count], p, (size_t)take);
lines[line_count][take] = '\0';
while(take > 0 && lines[line_count][take - 1] == ' ')
lines[line_count][--take] = '\0';
line_count++;
p += take;
while(*p == ' ')
p++;
}
if(*p == '\0' || scale <= 1)
break;
}
{
int row_h = 7 * scale + (scale > 1 ? 8 : 5);
int total_h = line_count * row_h - (scale > 1 ? 8 : 5);
int start_y = area_top + ((area_bottom - area_top) - total_h) / 2;
if(start_y < area_top)
start_y = area_top;
for(i = 0; i < line_count; i++)
frame_text_centered(fb, lines[i], start_y + i * row_h, scale, color);
}
}
static int read_uint_file(const char *path, unsigned int *value)
{
FILE *handle = fopen(path, "r");
@@ -603,6 +677,9 @@ struct state {
char call_sim[16];
char message[128];
char network[96];
int quagr_active;
char quagr_msg[128];
char quagr_time[16];
int enabled;
int battery;
int sms;
@@ -610,6 +687,7 @@ struct state {
int visible;
long long last_input_ms;
long long closed_since_ms;
long long quagr_dismissed_ms;
long long blank_ms;
long long wake_blank_ms;
int wake_capped;
@@ -618,12 +696,17 @@ struct state {
int backlight_level;
};
static int cover_hold_awake(const struct state *state)
static int call_hold_awake(const struct state *state)
{
return strcmp(state->call, "incoming") == 0 ||
strcmp(state->call, "muted") == 0;
}
static int cover_hold_awake(const struct state *state)
{
return call_hold_awake(state) || state->quagr_active;
}
/* A lit cover needs a lit framebuffer, a lit backlight and an unblanked fbdev;
* everything else is "fully off". TEST modes are diagnostic overrides. */
static int cover_is_lit(const struct state *state)
@@ -684,7 +767,7 @@ static void render_frame(struct frame *fb, const struct state *state)
rgb888(245, 245, 245));
} else if(!cover_is_lit(state)) {
frame_rect(fb, 0, 0, (int)width, (int)height, rgb888(0, 0, 0));
} else if(cover_hold_awake(state)) {
} else if(call_hold_awake(state)) {
int muted = strcmp(state->call, "muted") == 0;
char subhdr[48];
char name_san[64];
@@ -720,6 +803,22 @@ static void render_frame(struct frame *fb, const struct state *state)
(int)height - 34, 1, rgb888(250, 210, 60));
frame_text_centered(fb, "PWR: HANG UP",
(int)height - 18, 1, rgb888(255, 110, 110));
} else if(state->quagr_active) {
uint32_t accent = rgb888(0, 220, 245);
frame_rect(fb, 0, 0, (int)width, (int)height, rgb888(8, 12, 26));
frame_rect(fb, 0, 0, (int)width, 4, accent);
frame_text_centered(fb, "QUAGR PAGE", 16, 2, accent);
frame_text_centered(fb, state->quagr_time[0] ? state->quagr_time : clock,
38, 1, rgb888(140, 180, 240));
draw_wrapped_centered(fb, state->quagr_msg, 58, (int)height - 48,
2, rgb888(245, 248, 255));
if(state->battery >= 0) {
snprintf(battery, sizeof(battery), "BAT %d%%", state->battery);
frame_text_centered(fb, battery, (int)height - 34, 1,
rgb888(250, 210, 60));
}
frame_text_centered(fb, "ANY KEY: DISMISS",
(int)height - 18, 1, rgb888(250, 210, 60));
} else {
int clock_scale = width >= 220 ? 5 : 3;
int clock_h = 7 * clock_scale;
@@ -2394,7 +2493,7 @@ static void cover_wake(struct state *state, int *redraw)
refresh_blank_timeout(state);
if(strcmp(state->lid, "closed") == 0 && state->enabled && !state->test) {
state->visible = 1;
state->wake_capped = 1;
state->wake_capped = cover_hold_awake(state) ? 0 : 1;
state->last_input_ms = now_ms();
*redraw = 1;
}
@@ -2455,6 +2554,11 @@ static void handle_command(char *buffer, struct state *state,
state->wake_capped = 0;
state->last_input_ms = now;
state->closed_since_ms = new_closed ? now : 0;
if(!new_closed) {
state->quagr_active = 0;
state->quagr_msg[0] = '\0';
state->quagr_time[0] = '\0';
}
*redraw = 1;
}
} else if(strcmp(command, "BUTTON") == 0 ||
@@ -2463,35 +2567,84 @@ static void handle_command(char *buffer, struct state *state,
/* Trusted external side button, or a main-panel wake request that the
* closed-lid gate forwarded to the cover display. Ignore WAKE (never
* BUTTON) during the 450 ms close-settle window so dwm's spurious
* SW_KEYPAD_SLIDE wake on close does not light the cover by itself. */
if(!hw->sim && strcmp(command, "WAKE") == 0 &&
state->closed_since_ms > 0 &&
now_ms() - state->closed_since_ms < 450)
return;
if(strcmp(command, "BUTTON") == 0 && sub &&
strcmp(state->lid, "closed") == 0 && cover_hold_awake(state)) {
upper_string(sub);
if(strcmp(sub, "VOLUP") == 0 || strcmp(sub, "VOLDOWN") == 0) {
if(strcmp(state->call, "incoming") == 0) {
safe_copy(state->call, sizeof(state->call), "muted");
spawn_cover_event("mute-ring", state->call_num);
}
cover_wake(state, redraw);
*redraw = 1;
* SW_KEYPAD_SLIDE wake on close does not light the cover by itself, or
* right after dismissing a held Quagr page. */
if(strcmp(command, "WAKE") == 0) {
long long now = now_ms();
if(!hw->sim && state->closed_since_ms > 0 &&
now - state->closed_since_ms < 450)
return;
}
if(strcmp(sub, "POWER") == 0) {
safe_copy(state->call, sizeof(state->call), "none");
state->call_num[0] = '\0';
state->call_name[0] = '\0';
state->call_sim[0] = '\0';
spawn_cover_event("hangup-call", "");
cover_wake(state, redraw);
if(state->quagr_dismissed_ms > 0 &&
now - state->quagr_dismissed_ms < 600)
return;
}
if(strcmp(command, "BUTTON") == 0 && strcmp(state->lid, "closed") == 0) {
if(sub && call_hold_awake(state)) {
upper_string(sub);
if(strcmp(sub, "VOLUP") == 0 || strcmp(sub, "VOLDOWN") == 0) {
if(strcmp(state->call, "incoming") == 0) {
safe_copy(state->call, sizeof(state->call), "muted");
spawn_cover_event("mute-ring", state->call_num);
}
cover_wake(state, redraw);
*redraw = 1;
return;
}
if(strcmp(sub, "POWER") == 0) {
safe_copy(state->call, sizeof(state->call), "none");
state->call_num[0] = '\0';
state->call_name[0] = '\0';
state->call_sim[0] = '\0';
spawn_cover_event("hangup-call", "");
cover_wake(state, redraw);
*redraw = 1;
return;
}
} else if(state->quagr_active) {
state->quagr_active = 0;
state->quagr_msg[0] = '\0';
state->quagr_time[0] = '\0';
state->quagr_dismissed_ms = now_ms();
state->visible = 0;
state->wake_capped = 0;
*redraw = 1;
return;
}
}
cover_wake(state, redraw);
} else if(strcmp(command, "QUAGR") == 0) {
char *rest = save;
while(rest && (*rest == ' ' || *rest == '\t'))
rest++;
if(!rest || !*rest) {
state->quagr_active = 0;
state->quagr_msg[0] = '\0';
state->quagr_time[0] = '\0';
if(state->visible)
*redraw = 1;
} else {
time_t now_t;
struct tm tm_now;
ba_refresh_tz();
now_t = time(NULL);
localtime_r(&now_t, &tm_now);
strftime(state->quagr_time, sizeof(state->quagr_time), "%H:%M", &tm_now);
safe_copy(state->quagr_msg, sizeof(state->quagr_msg), rest);
trim(state->quagr_msg);
if(state->quagr_msg[0]) {
state->quagr_active = 1;
state->quagr_dismissed_ms = 0;
cover_wake(state, redraw);
if(state->visible)
*redraw = 1;
}
}
} else if(strcmp(command, "QUAGR_CLEAR") == 0) {
state->quagr_active = 0;
state->quagr_msg[0] = '\0';
state->quagr_time[0] = '\0';
if(state->visible)
*redraw = 1;
} else if(strcmp(command, "NETWORK") == 0) {
char *rest = save;
while(rest && (*rest == ' ' || *rest == '\t'))
@@ -2774,11 +2927,11 @@ static void reply_for(char *buffer, const struct state *state,
snprintf(reply, len,
"OK lid=%s backend=%s enabled=%d visible=%d blank_ms=%lld "
"battery=%d call=%s sms=%d network=%s spi=%d mux=%s "
"bits=%d probe=%s\n",
"bits=%d quagr=%d probe=%s\n",
state->lid, state->backend, state->enabled, state->visible,
state->blank_ms, state->battery, state->call, state->sms,
state->network, hw->spi_enabled, mux,
hw->word_bits, hw->probe_desc);
hw->word_bits, state->quagr_active, hw->probe_desc);
} else if(strcmp(command, "LID") == 0) {
snprintf(reply, len, "OK lid=%s\n", state->lid);
} else if(strcmp(command, "TEST") == 0) {
+5 -1
View File
@@ -332,6 +332,9 @@ static const char *resolve_plugin_name_from_argv0(const char *argv0) {
if (strcasecmp(base, "xprivacy") == 0 || strcasecmp(base, "privacy") == 0) {
return "privacy";
}
if (strcasecmp(base, "xquagr") == 0 || strcasecmp(base, "quagr") == 0) {
return "quagr";
}
return NULL;
}
@@ -430,7 +433,8 @@ int main(int argc, char **argv) {
strcmp(plugin_name, "irc") == 0 ||
strcmp(plugin_name, "sip") == 0 ||
strcmp(plugin_name, "engmenu") == 0 ||
strcmp(plugin_name, "privacy") == 0)) {
strcmp(plugin_name, "privacy") == 0 ||
strcmp(plugin_name, "quagr") == 0)) {
const char *a1 = (sub_argc >= 2 && sub_argv[1]) ? sub_argv[1] : "";
if (strcmp(a1, "--preload") != 0 && strcmp(a1, "close") != 0) {
return 1;
+2
View File
@@ -2080,6 +2080,7 @@ inline void closeOtherPlugins(const char* selfPluginName,
{"xpasscode.pid", "passcode"},
{"xengmenu.pid", "engmenu"},
{"xprivacy.pid", "privacy"},
{"xquagr.pid", "quagr"},
};
for (const auto& p : kAllPlugins) {
if ((selfPluginName && std::strcmp(p.name, selfPluginName) == 0) ||
@@ -2135,6 +2136,7 @@ inline bool isAnotherPluginActive(const char* selfPluginName) {
{"xpasscode.pid", "passcode"},
{"xengmenu.pid", "engmenu"},
{"xprivacy.pid", "privacy"},
{"xquagr.pid", "quagr"},
};
for (const auto& p : kAllPlugins) {
if (selfPluginName && std::strcmp(p.name, selfPluginName) == 0) {
File diff suppressed because it is too large. Load diff
+14 -2
View File
@@ -981,7 +981,8 @@ trigger_plugin_open(const char *plugin_spec)
strcmp(plugin_name, "irc") == 0 ||
strcmp(plugin_name, "sip") == 0 ||
strcmp(plugin_name, "engmenu") == 0 ||
strcmp(plugin_name, "privacy") == 0)) {
strcmp(plugin_name, "privacy") == 0 ||
strcmp(plugin_name, "quagr") == 0)) {
return;
}
@@ -2406,9 +2407,11 @@ add_parsed_choice_line(const char *line)
if (access("/tmp/bananarchy_duress_mode", F_OK) == 0) {
if (strstr(label, "Bantam") || strstr(label, "SIP") ||
strstr(label, "IRC") || strstr(label, "Tox") ||
strstr(label, "Quagr") ||
strstr(label, "Passcode") || strstr(label, "Terminal") ||
strstr(cmd, "xsip") || strstr(cmd, "xirc") ||
strstr(cmd, "xtox") || strstr(cmd, "xpasscode") ||
strstr(cmd, "xtox") || strstr(cmd, "xquagr") ||
strstr(cmd, "xpasscode") ||
strstr(cmd, "sxmo_terminal.sh") || strncmp(cmd, "st ", 3) == 0 ||
strcmp(cmd, "st") == 0)
return;
@@ -2434,6 +2437,8 @@ add_parsed_choice_line(const char *line)
return;
if (items[i].text && strstr(label, "Tox Messenger") && strstr(items[i].text, "Tox Messenger"))
return;
if (items[i].text && strstr(label, "Quagr") && strstr(items[i].text, "Quagr"))
return;
if (items[i].text && strstr(label, "Kopher") && strstr(items[i].text, "Kopher"))
return;
if (items[i].text && strstr(label, "GPS & Maps") && strstr(items[i].text, "GPS & Maps"))
@@ -2798,6 +2803,9 @@ open_builtin_menu(const char *menu_name, int keep_idx)
snprintf(label, sizeof(label), "%s Tox Messenger", ICON_MSG);
add_menu_item(label, "@plugin:tox", 0);
snprintf(label, sizeof(label), "%s Quagr Pager", ICON_BEL);
add_menu_item(label, "@plugin:quagr", 0);
}
snprintf(label, sizeof(label), "%s Webarchy Browser", ICON_GLB);
@@ -2887,6 +2895,8 @@ open_builtin_menu(const char *menu_name, int keep_idx)
add_menu_item(label, "@plugin:irc", 0);
snprintf(label, sizeof(label), "%s Tox Messenger", ICON_MSG);
add_menu_item(label, "@plugin:tox", 0);
snprintf(label, sizeof(label), "%s Quagr Pager", ICON_BEL);
add_menu_item(label, "@plugin:quagr", 0);
snprintf(label, sizeof(label), "%s Privacy Center", ICON_SHD);
add_menu_item(label, "@plugin:privacy", 0);
}
@@ -3359,6 +3369,7 @@ any_other_plugin_active(void)
"xpasscode.pid",
"xengmenu.pid",
"xprivacy.pid",
"xquagr.pid",
};
const char *rdir = getenv("XDG_RUNTIME_DIR");
const char *base = (rdir && rdir[0]) ? rdir : "/run/user/10000";
@@ -3413,6 +3424,7 @@ close_other_active_plugins(void)
{ "xpasscode.pid", "/tmp/dwm_plugin_passcode.fifo" },
{ "xengmenu.pid", "/tmp/dwm_plugin_engmenu.fifo" },
{ "xprivacy.pid", "/tmp/dwm_plugin_privacy.fifo" },
{ "xquagr.pid", "/tmp/dwm_plugin_quagr.fifo" },
};
const char *rdir = getenv("XDG_RUNTIME_DIR");
const char *base = (rdir && rdir[0]) ? rdir : "/run/user/10000";
+2
View File
@@ -1102,6 +1102,7 @@ static int xdrawer_run_main(int argc, char** argv) {
"xthemes.pid", "xmodem.pid", "xnetworks.pid", "xringtones.pid",
"xwallpapers.pid", "xmusic.pid", "xsip.pid", "xemail.pid",
"xirc.pid", "xtox.pid", "xsmallweb.pid", "xwebarchy.pid", "xgps.pid",
"xquagr.pid",
};
for (const char* pf : kPids) {
int p = readIntFile(getRuntimeFile(pf), -1);
@@ -1140,6 +1141,7 @@ static int xdrawer_run_main(int argc, char** argv) {
closeOtherPlugin("xsmallweb.pid", "/tmp/dwm_plugin_smallweb.fifo");
closeOtherPlugin("xwebarchy.pid", "/tmp/dwm_plugin_webarchy.fifo");
closeOtherPlugin("xgps.pid", "/tmp/dwm_plugin_gps.fifo");
closeOtherPlugin("xquagr.pid", "/tmp/dwm_plugin_quagr.fifo");
if (::access("/tmp/dwm_plugin_dmenu.active", F_OK) == 0) {
int dfd = ::open("/tmp/dwm_plugin_dmenu.fifo", O_WRONLY | O_NONBLOCK | O_CLOEXEC);
if (dfd >= 0) {