diff --git a/MANUAL.md b/MANUAL.md index 6667039..a7a5450 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -99,7 +99,9 @@ Open the **Wallpaper** tab directly via `geminux-themes --wallpaper`, the **Wall ### GUI modes and controls -- **Image Wallpaper**: Browse quickly via **Home**, **Pictures**, **SD Card** (`/media/sdcard`), or **Root /** (`All` toggle reveals non-image files), type or paste paths, preview layout with a simulated DWM top bar, choose among six scaling modes (**Fill**, **Fit**, **Center**, **Tile**, **Stretch**, **Span**), and set a matte color matching the active theme or a custom `#RRGGBB`. +Geminux bundles `geminux-dark.png` (configured as the default wallpaper on first boot) and `geminux-light.png` under `/usr/share/geminux/wallpapers/`. + +- **Image Wallpaper**: Browse quickly via **Stock** (`/usr/share/geminux/wallpapers`), **Home**, **Pictures**, **SD Card** (`/media/sdcard`), or **/** (`All` toggle reveals non-image files), type or paste paths (or pass short names like `geminux-apply-wallpaper geminux-light`), preview layout with a simulated DWM top bar, choose among six scaling modes (**Fill**, **Fit**, **Center**, **Tile**, **Stretch**, **Span**), and set a matte color matching the active theme or a custom `#RRGGBB`. - **Solid Color**: Pick **Match Active Theme Background**, dial custom RGB sliders, paste hex codes, or choose quick theme and dark swatches. ### CLI & automatic restore diff --git a/overlay/rootfs/etc/skel/.config/geminux/wallpaper.conf b/overlay/rootfs/etc/skel/.config/geminux/wallpaper.conf new file mode 100644 index 0000000..9596007 --- /dev/null +++ b/overlay/rootfs/etc/skel/.config/geminux/wallpaper.conf @@ -0,0 +1,6 @@ +# Geminux wallpaper configuration +TYPE=image +PATH=/usr/share/geminux/wallpapers/geminux-dark.png +MODE=fill +COLOR=#08090b +USE_THEME_BG=1 diff --git a/overlay/rootfs/usr/bin/geminux-session b/overlay/rootfs/usr/bin/geminux-session index 73e3ddf..f298c06 100755 --- a/overlay/rootfs/usr/bin/geminux-session +++ b/overlay/rootfs/usr/bin/geminux-session @@ -61,6 +61,10 @@ if command -v geminux-sync-gtk-theme >/dev/null 2>&1; then fi WP_CONF="${XDG_CONFIG_HOME:-$HOME_DIR/.config}/geminux/wallpaper.conf" +if [ ! -f "$WP_CONF" ] && [ -f /etc/skel/.config/geminux/wallpaper.conf ]; then + mkdir -p "$(dirname "$WP_CONF")" + cp -f /etc/skel/.config/geminux/wallpaper.conf "$WP_CONF" 2>/dev/null || true +fi if [ -n "${DISPLAY:-}" ] && [ -r "$WP_CONF" ] && command -v geminux-apply-wallpaper >/dev/null 2>&1; then geminux-apply-wallpaper --restore >/dev/null 2>&1 || true fi diff --git a/prebuilt/geminux/usr/bin/geminux-themes b/prebuilt/geminux/usr/bin/geminux-themes index 72d90b2..054127b 100755 Binary files a/prebuilt/geminux/usr/bin/geminux-themes and b/prebuilt/geminux/usr/bin/geminux-themes differ diff --git a/scripts/apply-geminux-overlay.sh b/scripts/apply-geminux-overlay.sh index ee43bb5..ad96443 100755 --- a/scripts/apply-geminux-overlay.sh +++ b/scripts/apply-geminux-overlay.sh @@ -84,6 +84,12 @@ else if [ -d "$BASE_DIR/overlay/rootfs" ]; then cp -af "$BASE_DIR/overlay/rootfs/." "$TARGET_ROOTFS/" fi + if [ -d "$BASE_DIR/artwork/wallpapers" ]; then + mkdir -p "$TARGET_ROOTFS/usr/share/geminux/wallpapers" + cp -af "$BASE_DIR/artwork/wallpapers/." "$TARGET_ROOTFS/usr/share/geminux/wallpapers/" + chmod 0755 "$TARGET_ROOTFS/usr/share/geminux/wallpapers" + chmod 0644 "$TARGET_ROOTFS/usr/share/geminux/wallpapers/"* 2>/dev/null || true + fi for subdir in xlibre suckless dunst geminux bantam gsocket gdk-pixbuf webarchy gtkttk; do if [ -d "$BASE_DIR/prebuilt/$subdir" ]; then cp -af "$BASE_DIR/prebuilt/$subdir/." "$TARGET_ROOTFS/" diff --git a/scripts/check-rebuild.sh b/scripts/check-rebuild.sh index ba97b76..14caa9e 100755 --- a/scripts/check-rebuild.sh +++ b/scripts/check-rebuild.sh @@ -399,7 +399,11 @@ for req_rel in ("etc/pam.d/autologin", "etc/init.d/geminux-hwinit", "home/user/.config/xsettingsd/xsettingsd.conf", "etc/NetworkManager/dispatcher.d/30-geminux-chrony", "etc/polkit-1/rules.d/10-geminux.rules", - "usr/bin/geminux-apply-wallpaper"): + "usr/bin/geminux-apply-wallpaper", + "usr/share/geminux/wallpapers/geminux-dark.png", + "usr/share/geminux/wallpapers/geminux-light.png", + "etc/skel/.config/geminux/wallpaper.conf", + "home/user/.config/geminux/wallpaper.conf"): if not os.path.lexists(os.path.join(rootfs, req_rel)): raise SystemExit(f"FAIL: missing required path {os.path.join(rootfs, req_rel)}") if os.path.lexists(os.path.join(rootfs, "usr/lib/geminux-mpv")): @@ -431,6 +435,8 @@ for rel, needle in ( ("usr/bin/geminux-launcher", "Webarchy Browser"), ("usr/bin/geminux-launcher", "Bantam AI agent"), ("usr/bin/geminux-launcher", "Wallpaper"), + ("etc/skel/.config/geminux/wallpaper.conf", "PATH=/usr/share/geminux/wallpapers/geminux-dark.png"), + ("home/user/.config/geminux/wallpaper.conf", "PATH=/usr/share/geminux/wallpapers/geminux-dark.png"), ): p = os.path.join(rootfs, rel) with open(p, "r", encoding="utf-8") as f: @@ -519,6 +525,15 @@ docker run --rm -i -v "$IMAGES_DIR:/images:ro" -v "$BASE_DIR/prebuilt/kernel/boo debugfs -R "stat /home/user" /images/geminux-rootfs.img | grep -qE "User:[[:space:]]*10000\b" || { echo "FAIL: geminux-rootfs.img /home/user is not UID 10000" >&2; exit 1; } + debugfs -R "stat /usr/share/geminux/wallpapers/geminux-dark.png" /images/geminux-rootfs.img | grep -qE "Mode:[[:space:]]*0?(10)?0644\b" || { + echo "FAIL: geminux-rootfs.img /usr/share/geminux/wallpapers/geminux-dark.png missing or not 0644" >&2; exit 1; + } + debugfs -R "stat /usr/share/geminux/wallpapers/geminux-light.png" /images/geminux-rootfs.img | grep -qE "Mode:[[:space:]]*0?(10)?0644\b" || { + echo "FAIL: geminux-rootfs.img /usr/share/geminux/wallpapers/geminux-light.png missing or not 0644" >&2; exit 1; + } + debugfs -R "stat /home/user/.config/geminux/wallpaper.conf" /images/geminux-rootfs.img | grep -qE "User:[[:space:]]*10000\b" || { + echo "FAIL: geminux-rootfs.img /home/user/.config/geminux/wallpaper.conf missing or not UID 10000" >&2; exit 1; + } DTS_OUT="$(dtc -I dtb -O dts /kboot/mt6797-gemini-pda-geminux.dtb 2>/dev/null)" printf "%s\n" "$DTS_OUT" | grep -qE "^\tmemory \{$" || { echo "FAIL: DTB missing /memory node" >&2; exit 1; } if printf "%s\n" "$DTS_OUT" | grep -qE "^\tmemory@40000000 \{$"; then diff --git a/scripts/package-local-apks.sh b/scripts/package-local-apks.sh index 93e0d21..c788bf0 100755 --- a/scripts/package-local-apks.sh +++ b/scripts/package-local-apks.sh @@ -296,6 +296,17 @@ make_pkg( # 11. geminux-config cstage = os.path.join(work_dir, "geminux-config") copy_tree_dedup("/geminux/overlay/rootfs", cstage, dedup=True) +wp_src = "/geminux/artwork/wallpapers" +if os.path.isdir(wp_src): + wp_dst = os.path.join(cstage, "usr", "share", "geminux", "wallpapers") + os.makedirs(wp_dst, exist_ok=True) + os.chmod(wp_dst, 0o755) + for fn in sorted(os.listdir(wp_src)): + sp = os.path.join(wp_src, fn) + if os.path.isfile(sp) and not os.path.islink(sp): + dp = os.path.join(wp_dst, fn) + shutil.copy2(sp, dp) + os.chmod(dp, 0o644) for rel in ("etc/os-release", "usr/lib/os-release", "etc/issue", "etc/motd"): p = os.path.join(cstage, rel) if os.path.isfile(p): diff --git a/scripts/test-theme-dunst-sync.py b/scripts/test-theme-dunst-sync.py index 0585b7c..1b88e9c 100755 --- a/scripts/test-theme-dunst-sync.py +++ b/scripts/test-theme-dunst-sync.py @@ -283,6 +283,14 @@ def main(): assert os.path.isfile(os.path.join(xth_home, ".themes/Geminux-Custom_Test/gtk-3.0/gtk.css")) wp_hdr = os.path.join(BASE_DIR, "src", "geminux-apps", "geminux-wallpaper.h") + skel_wp_conf = os.path.join(BASE_DIR, "overlay", "rootfs", "etc", "skel", ".config", "geminux", "wallpaper.conf") + assert os.path.isfile(skel_wp_conf), f"Missing default skel wallpaper config: {skel_wp_conf}" + for wp_png in ("geminux-dark.png", "geminux-light.png"): + wp_png_path = os.path.join(BASE_DIR, "artwork", "wallpapers", wp_png) + assert os.path.isfile(wp_png_path), f"Missing bundled wallpaper: {wp_png_path}" + with open(wp_png_path, "rb") as pf: + assert pf.read(8) == b"\x89PNG\r\n\x1a\n", f"Invalid PNG header in {wp_png_path}" + wp_c = os.path.join(tmp, "test_wp.c") wp_bin = os.path.join(tmp, "test_wp") wp_dir = os.path.join(tmp, "wp_cfg_dir") @@ -327,6 +335,10 @@ def main(): ' geminux_wp_calc_placement(800, 600, 1600, 1200, GEMINUX_WP_STRETCH, &px, &py, &pw, &ph);\n' ' assert(fabs(px) < 0.01 && fabs(py) < 0.01 && fabs(pw - 1600.0) < 0.01 && fabs(ph - 1200.0) < 0.01);\n' ' geminux_wp_cfg_t cfg, loaded;\n' + f' assert(geminux_wp_cfg_load("{skel_wp_conf}", &loaded));\n' + ' assert(loaded.type == GEMINUX_WP_IMAGE && loaded.mode == GEMINUX_WP_FILL);\n' + ' assert(strcmp(loaded.path, "/usr/share/geminux/wallpapers/geminux-dark.png") == 0);\n' + ' assert(loaded.use_theme_bg);\n' f' assert(!geminux_wp_cfg_load("{wp_conf}", &loaded));\n' ' geminux_wp_cfg_init(&cfg);\n' ' cfg.type = GEMINUX_WP_IMAGE;\n' @@ -355,6 +367,7 @@ def main(): wp_help = subprocess.run([wp_script, "--help"], capture_output=True, text=True, check=True) assert "--restore" in wp_help.stdout and "--apply-wallpaper" not in wp_help.stdout for srel, needle in ( + ("overlay/rootfs/usr/bin/geminux-session", "/etc/skel/.config/geminux/wallpaper.conf"), ("overlay/rootfs/usr/bin/geminux-session", "geminux-apply-wallpaper --restore"), ("overlay/rootfs/usr/bin/geminux-apply-theme", "geminux-apply-wallpaper --restore"), ("overlay/rootfs/usr/bin/geminux-launcher", "geminux-themes --wallpaper"), diff --git a/src/geminux-apps/geminux-themes.c b/src/geminux-apps/geminux-themes.c index 8163035..7598a44 100644 --- a/src/geminux-apps/geminux-themes.c +++ b/src/geminux-apps/geminux-themes.c @@ -215,6 +215,13 @@ static void wp_conf_path(char *out, size_t sz) { } } +static bool wp_load_user_or_default_cfg(geminux_wp_cfg_t *cfg) { + char cpath[560]; + wp_conf_path(cpath, sizeof(cpath)); + if (geminux_wp_cfg_load(cpath, cfg)) return true; + return geminux_wp_cfg_load("/etc/skel/.config/geminux/wallpaper.conf", cfg); +} + static void set_focus_input(themes_state_t *st, int hit_id, char *buf, size_t cap) { st->focus_id = hit_id; st->focus_buf = buf; @@ -851,9 +858,7 @@ static void wp_select_first_image_if_dir(themes_state_t *st) { static void wp_init_state(themes_state_t *st) { st->wp_initialized = true; - char cpath[560]; - wp_conf_path(cpath, sizeof(cpath)); - geminux_wp_cfg_load(cpath, &st->wp_cfg); + wp_load_user_or_default_cfg(&st->wp_cfg); wp_sync_rgb_from_cfg(st); snprintf(st->wp_path_input, sizeof(st->wp_path_input), "%.*s", (int)(sizeof(st->wp_path_input) - 1), st->wp_cfg.path); @@ -1407,25 +1412,36 @@ static void draw_wallpaper_view(themes_state_t *st, cairo_t *cr, int w, int h) { int left_rem_h = (y + body_h) - ly; if (st->wp_cfg.type == GEMINUX_WP_IMAGE) { int in_h = 52; - int gap = 10; - int all_w = 110; - int qbw = (left_w - all_w - gap * 4) / 4; + int gap = 8; + int all_w = 96; + int avail_w = left_w - all_w - gap * 5; const char *home = getenv("HOME"); const char *hdir = (home && home[0]) ? home : "/"; char pics_dir[560]; snprintf(pics_dir, sizeof(pics_dir), "%s/Pictures", strcmp(hdir, "/") == 0 ? "" : hdir); - bool q_active[4] = { + char sys_dir[128]; + if (!wp_find_system_dir(sys_dir, sizeof(sys_dir))) { + snprintf(sys_dir, sizeof(sys_dir), "/usr/share/geminux/wallpapers"); + } + bool q_active[5] = { + strcmp(st->wp_dir, sys_dir) == 0, strcmp(st->wp_dir, hdir) == 0, strcmp(st->wp_dir, pics_dir) == 0, strcmp(st->wp_dir, "/media/sdcard") == 0, strcmp(st->wp_dir, "/") == 0, }; - const char *qnames[4] = {"Home", "Pictures", "SD Card", "Root /"}; - for (int i = 0; i < 4; i++) { - gemui_draw_button(st->app, cr, (gemui_rect_t){pad + i * (qbw + gap), ly, qbw, in_h}, + const char *qnames[5] = {"Stock", "Home", "Pictures", "SD Card", "/"}; + const int qweights[5] = {18, 16, 22, 20, 10}; + int cur_x = pad; + int used_w = 0; + for (int i = 0; i < 5; i++) { + int bw = (i < 4) ? (avail_w * qweights[i]) / 86 : (avail_w - used_w); + gemui_draw_button(st->app, cr, (gemui_rect_t){cur_x, ly, bw, in_h}, qnames[i], HIT_WP_QUICK_DIR, i, false, q_active[i], false); + cur_x += bw + gap; + used_w += bw; } - gemui_draw_button(st->app, cr, (gemui_rect_t){pad + 4 * (qbw + gap), ly, left_w - 4 * (qbw + gap), in_h}, + gemui_draw_button(st->app, cr, (gemui_rect_t){cur_x, ly, (pad + left_w) - cur_x, in_h}, "All", HIT_WP_TOGGLE_ALL, 0, false, st->wp_show_all, false); ly += in_h + 12; @@ -2135,11 +2151,15 @@ static void on_ptr(gemui_app_t *app, int type, int x, int y, unsigned int btn, v const char *home = getenv("HOME"); const char *h = (home && home[0]) ? home : "/"; char target[640] = ""; - if (hit->val == 1) { - snprintf(target, sizeof(target), "%s/Pictures", strcmp(h, "/") == 0 ? "" : h); + if (hit->val == 0) { + if (!wp_find_system_dir(target, sizeof(target))) snprintf(target, sizeof(target), "%s", h); + } else if (hit->val == 1) { + snprintf(target, sizeof(target), "%s", h); } else if (hit->val == 2) { - snprintf(target, sizeof(target), "/media/sdcard"); + snprintf(target, sizeof(target), "%s/Pictures", strcmp(h, "/") == 0 ? "" : h); } else if (hit->val == 3) { + snprintf(target, sizeof(target), "/media/sdcard"); + } else if (hit->val == 4) { snprintf(target, sizeof(target), "/"); } else { snprintf(target, sizeof(target), "%s", h); @@ -2224,10 +2244,8 @@ static void print_wallpaper_usage(FILE *out) { } static int cli_restore_wallpaper(void) { - char cpath[560]; - wp_conf_path(cpath, sizeof(cpath)); geminux_wp_cfg_t cfg; - if (!geminux_wp_cfg_load(cpath, &cfg)) { + if (!wp_load_user_or_default_cfg(&cfg)) { return 0; } if (cfg.type == GEMINUX_WP_IMAGE && !cfg.path[0]) {