feat(theme,display,wm,power,make): add Anodized theme, editors, multi-monitor arrangement, power timeouts, bar compaction, and replace state preservation
- Replace deprecated AnodeDefault with dark-silvery Anodized default theme - Add interactive theme editor, duplicator, and non-standard .xth importer to anode-themes (+ CLI --install) - Fix multi-monitor dwm/lock/vkbd/EDID edge cases and integrate monitor arrangement + 15s revert into anode-display and anode-apply-display - Gate anode-touchd behind WITH_TOUCHD=1 (keeping anode-vkbd unconditional) and add help/rebuild/install-touch/install-system targets to Makefile - Add idle screen dim, lock, suspend, and suspend-on-AC timeout controls to anode-power and anode-display backed by power.conf + SIGUSR1 - Prevent lockscreen subtitle overflow and progressively compact status bar segments so focused window titles remain visible - Preserve workspaces, active desktop, monitor state, floating/fullscreen states, and focus across anode-replace and restarts
This commit is contained in:
1 parent
bb81541b42
commit
4ec3f59e02
40 files changed
+5843
-768
No files matched your search
@@ -2,7 +2,9 @@
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "anode_scale.h"
|
||||
#include "anode_plat.h"
|
||||
@@ -14,6 +16,9 @@
|
||||
#include "anode_power_policy.h"
|
||||
#include "anode_xkb_parse.h"
|
||||
#include "anode_sys_parse.h"
|
||||
#include "anode_xth.h"
|
||||
#include "anode_display_cfg.h"
|
||||
#include "anode_bar_fmt.h"
|
||||
#include "anode-touch-gesture.h"
|
||||
|
||||
static void test_scale_math(void) {
|
||||
@@ -174,6 +179,62 @@ static void test_power_policy_and_gestures(void) {
|
||||
anode_power_policy_step(&cfg, &st, 1000, false, 2, true, false, &act);
|
||||
assert(act.warn_low_batt && act.suspend_now);
|
||||
|
||||
/* lock_ms < dim_ms ordering must still trigger lock */
|
||||
cfg = anode_power_cfg_default();
|
||||
cfg.dim_ms = 600000U;
|
||||
cfg.lock_ms = 300000U;
|
||||
cfg.suspend_ms = 1800000U;
|
||||
st = ANODE_PWR_ACTIVE;
|
||||
anode_power_policy_step(&cfg, &st, 310000U, true, 90, true, false, &act);
|
||||
assert(st == ANODE_PWR_LOCKED && act.lock_now);
|
||||
assert(anode_power_policy_next_wake_ms(&cfg, 1000U, true, false) == 15000);
|
||||
assert(anode_power_policy_next_wake_ms(&cfg, 295000U, true, false) == 5000);
|
||||
|
||||
/* Dim and lock disabled, battery-only suspend */
|
||||
cfg.dim_ms = 0U;
|
||||
cfg.lock_ms = 0U;
|
||||
cfg.suspend_ms = 1800000U;
|
||||
cfg.suspend_on_ac = false;
|
||||
st = ANODE_PWR_ACTIVE;
|
||||
anode_power_policy_step(&cfg, &st, 1900000U, true, 90, true, false, &act);
|
||||
assert(st == ANODE_PWR_ACTIVE && !act.suspend_now && !act.lock_now && !act.dim_now);
|
||||
anode_power_policy_step(&cfg, &st, 1900000U, false, 90, true, false, &act);
|
||||
assert(st == ANODE_PWR_SUSPENDED && act.suspend_now);
|
||||
|
||||
cfg.suspend_on_ac = true;
|
||||
assert(anode_power_policy_next_wake_ms(&cfg, 1796000U, true, false) == 4000);
|
||||
|
||||
/* Preset stepping & timeout formatting */
|
||||
char tfmt[16];
|
||||
anode_power_format_timeout(0U, tfmt, sizeof(tfmt));
|
||||
assert(strcmp(tfmt, "Off") == 0);
|
||||
anode_power_format_timeout(30000U, tfmt, sizeof(tfmt));
|
||||
assert(strcmp(tfmt, "30s") == 0);
|
||||
anode_power_format_timeout(300000U, tfmt, sizeof(tfmt));
|
||||
assert(strcmp(tfmt, "5m") == 0);
|
||||
anode_power_format_timeout(3600000U, tfmt, sizeof(tfmt));
|
||||
assert(strcmp(tfmt, "1h") == 0);
|
||||
assert(anode_power_step_screen_timeout_ms(0U, 1) == 30000U);
|
||||
assert(anode_power_step_screen_timeout_ms(45000U, 1) == 60000U);
|
||||
assert(anode_power_step_screen_timeout_ms(45000U, -1) == 30000U);
|
||||
assert(anode_power_step_suspend_timeout_ms(1800000U, 1) == 2700000U);
|
||||
assert(anode_power_step_suspend_timeout_ms(0U, -1) == 0U);
|
||||
|
||||
/* Atomic power.conf save/load round-trip */
|
||||
char ptmpl[] = "/tmp/anode-u-pwr-XXXXXX";
|
||||
char *pdir = mkdtemp(ptmpl);
|
||||
assert(pdir != NULL);
|
||||
char pconf[256];
|
||||
snprintf(pconf, sizeof(pconf), "%s/power.conf", pdir);
|
||||
anode_power_cfg_t wcfg = {0U, 180000U, 900000U, 10, true};
|
||||
assert(anode_power_cfg_save(pconf, &wcfg));
|
||||
anode_power_cfg_t rcfg;
|
||||
assert(anode_power_cfg_load(pconf, &rcfg));
|
||||
assert(rcfg.dim_ms == 0U && rcfg.lock_ms == 180000U && rcfg.suspend_ms == 900000U &&
|
||||
rcfg.crit_batt_pct == 10 && rcfg.suspend_on_ac == true);
|
||||
remove(pconf);
|
||||
rmdir(pdir);
|
||||
|
||||
/* Gestures at 1.0x and 2.0x scales */
|
||||
anode_touch_track_t tr = {0};
|
||||
anode_touch_begin(&tr, 1, 500, 1070, 1000);
|
||||
@@ -292,6 +353,156 @@ static void test_platform_probe(void) {
|
||||
assert(buf[0] == '/');
|
||||
}
|
||||
|
||||
static void test_xth_editor_and_import(void) {
|
||||
anode_xth_t x;
|
||||
anode_xth_init_anodized(&x);
|
||||
assert(strcmp(x.name, "Anodized") == 0);
|
||||
assert(strcmp(x.colors[ANODE_XTH_BG_MAIN], "#08090b") == 0);
|
||||
assert(strcmp(x.colors[ANODE_XTH_ACCENT], "#cfd6e0") == 0);
|
||||
assert(anode_xth_contrast_ratio("#08090b", "#cfd6e0") > 12.0);
|
||||
|
||||
char sname[64];
|
||||
anode_xth_sanitize_name(" My Cool Theme! 2.0 ", sname, sizeof(sname));
|
||||
assert(strcmp(sname, "My_Cool_Theme_2_0") == 0);
|
||||
anode_xth_sanitize_name("../..", sname, sizeof(sname));
|
||||
assert(sname[0] == '\0');
|
||||
|
||||
snprintf(x.name, sizeof(x.name), "SilverCustom");
|
||||
snprintf(x.colors[ANODE_XTH_BG_BAR], 16, "#101216");
|
||||
snprintf(x.colors[ANODE_XTH_SEL_BG], 16, "#445566");
|
||||
anode_xth_sync_derived(&x);
|
||||
assert(strcmp(x.colors[ANODE_XTH_DWM_NORM_BG], "#101216") == 0);
|
||||
assert(strcmp(x.colors[ANODE_XTH_DMENU_SEL_BG], "#445566") == 0);
|
||||
assert(strcmp(x.colors[ANODE_XTH_ST_CURSOR], "#cfd6e0") == 0);
|
||||
|
||||
char dir_tmpl[] = "/tmp/anode-u-xth-XXXXXX";
|
||||
char *tdir = mkdtemp(dir_tmpl);
|
||||
assert(tdir != NULL);
|
||||
|
||||
char p1[256], p2[256], badp[256], dest[512];
|
||||
snprintf(p1, sizeof(p1), "%s/src.xth", tdir);
|
||||
snprintf(badp, sizeof(badp), "%s/bad.bin", tdir);
|
||||
assert(anode_xth_save_file(p1, &x));
|
||||
|
||||
anode_xth_t loaded;
|
||||
assert(anode_xth_load_file(p1, &loaded));
|
||||
assert(strcmp(loaded.name, "SilverCustom") == 0);
|
||||
assert(strcmp(loaded.colors[ANODE_XTH_DWM_NORM_BG], "#101216") == 0);
|
||||
|
||||
assert(anode_xth_import_file(p1, tdir, "ImportedSilver!", dest, sizeof(dest)));
|
||||
assert(anode_xth_load_file(dest, &loaded));
|
||||
assert(strcmp(loaded.name, "ImportedSilver") == 0);
|
||||
|
||||
FILE *bf = fopen(badp, "wb");
|
||||
assert(bf != NULL);
|
||||
unsigned char zeros[8] = {0, 1, 2, 0, 3, 4, 5, 6};
|
||||
fwrite(zeros, 1, sizeof(zeros), bf);
|
||||
fclose(bf);
|
||||
assert(!anode_xth_load_file(badp, &loaded));
|
||||
|
||||
snprintf(p2, sizeof(p2), "%s/empty.xth", tdir);
|
||||
FILE *ef = fopen(p2, "w");
|
||||
assert(ef != NULL);
|
||||
fclose(ef);
|
||||
assert(!anode_xth_load_file(p2, &loaded));
|
||||
|
||||
remove(p1);
|
||||
remove(dest);
|
||||
remove(badp);
|
||||
remove(p2);
|
||||
rmdir(tdir);
|
||||
}
|
||||
|
||||
static void test_display_cfg_and_snap(void) {
|
||||
int ew = 0, eh = 0;
|
||||
anode_disp_eff_size(1920, 1080, 1, &ew, &eh);
|
||||
assert(ew == 1080 && eh == 1920);
|
||||
anode_disp_eff_size(1920, 1080, 0, &ew, &eh);
|
||||
assert(ew == 1920 && eh == 1080);
|
||||
|
||||
anode_disp_out_t outs[2];
|
||||
memset(outs, 0, sizeof(outs));
|
||||
snprintf(outs[0].name, 32, "eDP-1");
|
||||
outs[0].enabled = true; outs[0].primary = true;
|
||||
outs[0].w = 1920; outs[0].h = 1080; outs[0].hz = 60.0;
|
||||
snprintf(outs[1].name, 32, "HDMI-1");
|
||||
outs[1].enabled = true; outs[1].primary = false;
|
||||
outs[1].w = 2560; outs[1].h = 1440; outs[1].hz = 60.0;
|
||||
|
||||
anode_disp_apply_preset(outs, 2, 0, ANODE_DISP_PRESET_RIGHT);
|
||||
assert(outs[0].x == 0 && outs[0].y == 0 && outs[1].x == 1920 && outs[1].y == 0);
|
||||
|
||||
anode_disp_apply_preset(outs, 2, 0, ANODE_DISP_PRESET_LEFT);
|
||||
assert(outs[1].x == 0 && outs[0].x == 2560);
|
||||
|
||||
anode_disp_apply_preset(outs, 2, 0, ANODE_DISP_PRESET_ABOVE);
|
||||
assert(outs[1].y == 0 && outs[0].y == 1440);
|
||||
|
||||
anode_disp_apply_preset(outs, 2, 0, ANODE_DISP_PRESET_RIGHT);
|
||||
int sx = 0, sy = 0;
|
||||
anode_disp_snap(outs, 2, 1, 1900, 18, 32, &sx, &sy);
|
||||
assert(sx == 1920 && sy == 0);
|
||||
|
||||
char sig[128];
|
||||
anode_disp_signature(outs, 2, sig, sizeof(sig));
|
||||
assert(strcmp(sig, "HDMI-1,eDP-1") == 0);
|
||||
|
||||
char dir_tmpl[] = "/tmp/anode-u-disp-XXXXXX";
|
||||
char *tdir = mkdtemp(dir_tmpl);
|
||||
assert(tdir != NULL);
|
||||
char conf[256];
|
||||
snprintf(conf, sizeof(conf), "%s/displays.conf", tdir);
|
||||
assert(anode_disp_save_profile(conf, outs, 2));
|
||||
|
||||
anode_disp_out_t loaded[4];
|
||||
int nl = anode_disp_load_profile(conf, sig, loaded, 4);
|
||||
assert(nl == 2);
|
||||
assert(strcmp(loaded[0].name, "eDP-1") == 0 && loaded[0].primary);
|
||||
assert(strcmp(loaded[1].name, "HDMI-1") == 0 && loaded[1].x == 1920 && loaded[1].w == 2560);
|
||||
|
||||
const char *av[64];
|
||||
char tokbuf[512];
|
||||
int ac = anode_disp_build_xrandr_argv(loaded, nl, av, 64, tokbuf, sizeof(tokbuf));
|
||||
assert(ac > 8 && strcmp(av[0], "xrandr") == 0);
|
||||
|
||||
anode_disp_apply_preset(outs, 2, 0, ANODE_DISP_PRESET_PRIMARY_ONLY);
|
||||
assert(outs[0].enabled && outs[0].primary && !outs[1].enabled);
|
||||
|
||||
outs[0].enabled = false;
|
||||
assert(anode_disp_build_xrandr_argv(outs, 2, av, 64, tokbuf, sizeof(tokbuf)) == -1);
|
||||
|
||||
remove(conf);
|
||||
rmdir(tdir);
|
||||
}
|
||||
|
||||
static void test_bar_status_compaction(void) {
|
||||
const char *full = " VOL 75% | CPU 12% | RAM 45% | BAT 85%+ | us | 2026-11-27 08:02 ";
|
||||
char out[256];
|
||||
|
||||
anode_bar_compact_status(full, 0, out, sizeof(out));
|
||||
assert(strcmp(out, "VOL 75% | CPU 12% | RAM 45% | BAT 85%+ | us | 2026-11-27 08:02") == 0);
|
||||
|
||||
anode_bar_compact_status(full, 1, out, sizeof(out));
|
||||
assert(strcmp(out, "V:75% C:12% R:45% B:85%+ us 11-27 08:02") == 0);
|
||||
|
||||
anode_bar_compact_status(full, 2, out, sizeof(out));
|
||||
assert(strcmp(out, "V:75% B:85%+ us 08:02") == 0);
|
||||
|
||||
anode_bar_compact_status(full, 3, out, sizeof(out));
|
||||
assert(strcmp(out, "us 08:02") == 0);
|
||||
|
||||
const char *desk = " VOL MUTE | CPU 5% | RAM 30% | AC | de | 2026-11-27 08:02 ";
|
||||
anode_bar_compact_status(desk, 1, out, sizeof(out));
|
||||
assert(strcmp(out, "V:M C:5% R:30% AC de 11-27 08:02") == 0);
|
||||
anode_bar_compact_status(desk, 2, out, sizeof(out));
|
||||
assert(strcmp(out, "V:M de 08:02") == 0);
|
||||
anode_bar_compact_status(desk, 3, out, sizeof(out));
|
||||
assert(strcmp(out, "de 08:02") == 0);
|
||||
|
||||
anode_bar_compact_status("custom bar text", 2, out, sizeof(out));
|
||||
assert(strcmp(out, "custom bar text") == 0);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
test_scale_math();
|
||||
test_dns_validation();
|
||||
@@ -302,6 +513,9 @@ int main(void) {
|
||||
test_xkb_layout_parser();
|
||||
test_sys_parsers();
|
||||
test_platform_probe();
|
||||
test_xth_editor_and_import();
|
||||
test_display_cfg_and_snap();
|
||||
test_bar_status_compaction();
|
||||
printf("test_units: ALL PASSED\n");
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user