From eae1105ab911f91665edeb9447701a723918dc5d Mon Sep 17 00:00:00 2001 From: LordMZTE Date: Wed, 8 May 2024 21:05:14 +0200 Subject: [PATCH] Use nsxiv --- cgassets/nix/nsxiv-config.patch.cgt | 83 +++++++++++++++++++++++++++++ lib/common-nix/default.nix | 2 + nix/mzte-nix.nix | 5 +- 3 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 cgassets/nix/nsxiv-config.patch.cgt diff --git a/cgassets/nix/nsxiv-config.patch.cgt b/cgassets/nix/nsxiv-config.patch.cgt new file mode 100644 index 0000000..c7ce5a7 --- /dev/null +++ b/cgassets/nix/nsxiv-config.patch.cgt @@ -0,0 +1,83 @@ + +diff --git a/config.def.h b/config.def.h +index 7fbfb17..12b6cbc 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -7,13 +7,13 @@ static const int WIN_HEIGHT = 600; + /* colors and font can be overwritten via X resource properties. + * See nsxiv(1), X(7) section Resources and xrdb(1) for more information. + * X resource value (NULL == default) */ +-static const char *WIN_BG[] = { "Nsxiv.window.background", "white" }; +-static const char *WIN_FG[] = { "Nsxiv.window.foreground", "black" }; +-static const char *MARK_FG[] = { "Nsxiv.mark.foreground", NULL }; ++static const char *WIN_BG[] = { "Nsxiv.window.background", "#<% opt.catppuccin.base %>" }; ++static const char *WIN_FG[] = { "Nsxiv.window.foreground", "#<% opt.catppuccin.text %>" }; ++static const char *MARK_FG[] = { "Nsxiv.mark.foreground", "#<% opt.catppuccin.lavender %>" }; + #if HAVE_LIBFONTS +-static const char *BAR_BG[] = { "Nsxiv.bar.background", NULL }; ++static const char *BAR_BG[] = { "Nsxiv.bar.background", "#<% opt.catppuccin.surface0 %>" }; + static const char *BAR_FG[] = { "Nsxiv.bar.foreground", NULL }; +-static const char *BAR_FONT[] = { "Nsxiv.bar.font", "monospace-8" }; ++static const char *BAR_FONT[] = { "Nsxiv.bar.font", "<% opt.font %>-8" }; + + /* if true, statusbar appears on top of the window */ + static const bool TOP_STATUSBAR = false; +@@ -68,7 +68,7 @@ static const bool ANTI_ALIAS = true; + /* if true, use a checkerboard background for alpha layer, + * toggled with 'A' key binding (overwritten via `--alpha-layer` option) + */ +-static const bool ALPHA_LAYER = false; ++static const bool ALPHA_LAYER = true; + + #endif + #ifdef INCLUDE_THUMBS_CONFIG +diff --git a/nsxiv.h b/nsxiv.h +index 3ffc113..a0a39f4 100644 +--- a/nsxiv.h ++++ b/nsxiv.h +@@ -402,6 +402,7 @@ struct win { + XColor win_bg; + XColor win_fg; + XColor mrk_fg; ++ XColor frame_fg; + #if HAVE_LIBFONTS + XftColor bar_bg; + XftColor bar_fg; +diff --git a/thumbs.c b/thumbs.c +index c7b9dc6..65a9b1d 100644 +--- a/thumbs.c ++++ b/thumbs.c +@@ -488,7 +488,7 @@ void tns_highlight(tns_t *tns, int n, bool hl) + if (n >= 0 && n < *tns->cnt && tns->thumbs[n].im != NULL) { + win_t *win = tns->win; + thumb_t *t = &tns->thumbs[n]; +- unsigned long col = hl ? win->win_fg.pixel : win->win_bg.pixel; ++ unsigned long col = hl ? win->frame_fg.pixel : win->win_bg.pixel; + int oxy = (tns->bw + 1) / 2 + 1, owh = tns->bw + 2; + + win_draw_rect(win, t->x - oxy, t->y - oxy, t->w + owh, t->h + owh, +diff --git a/window.c b/window.c +index 387d789..55cc12b 100644 +--- a/window.c ++++ b/window.c +@@ -112,7 +112,7 @@ static const char *win_res(XrmDatabase db, const char *name, const char *def) + void win_init(win_t *win) + { + win_env_t *e; +- const char *win_bg, *win_fg, *mrk_fg; ++ const char *win_bg, *win_fg, *mrk_fg, *frame_fg; + char *res_man; + XrmDatabase db; + #if HAVE_LIBFONTS +@@ -144,9 +144,11 @@ void win_init(win_t *win) + win_bg = win_res(db, WIN_BG[0], WIN_BG[1] ? WIN_BG[1] : "white"); + win_fg = win_res(db, WIN_FG[0], WIN_FG[1] ? WIN_FG[1] : "black"); + mrk_fg = win_res(db, MARK_FG[0], MARK_FG[1] ? MARK_FG[1] : win_fg); ++ frame_fg = win_res(db, "Nsxiv.window.frame_foreground", "#<% opt.catppuccin.red %>"); + win_alloc_color(e, win_bg, &win->win_bg); + win_alloc_color(e, win_fg, &win->win_fg); + win_alloc_color(e, mrk_fg, &win->mrk_fg); ++ win_alloc_color(e, frame_fg, &win->frame_fg); + + #if HAVE_LIBFONTS + bar_bg = win_res(db, BAR_BG[0], BAR_BG[1] ? BAR_BG[1] : win_bg); diff --git a/lib/common-nix/default.nix b/lib/common-nix/default.nix index 53d4b87..57f73e1 100644 --- a/lib/common-nix/default.nix +++ b/lib/common-nix/default.nix @@ -5,4 +5,6 @@ path = "${builtins.getEnv "HOME"}/.config/mzte_localconf/opts.nix"; in lib.optional (builtins.pathExists path) (import path); + + confgenFile = path: /. + (builtins.getEnv "HOME") + "/confgenfs/${path}"; } diff --git a/nix/mzte-nix.nix b/nix/mzte-nix.nix index 62d6950..fe9d3bd 100644 --- a/nix/mzte-nix.nix +++ b/nix/mzte-nix.nix @@ -1,4 +1,4 @@ -{ lib, pkgs, config, ... }: +{ common, lib, pkgs, config, ... }: let flakePkg = ref: (builtins.getFlake ref).packages.${pkgs.system}.default; in @@ -8,6 +8,9 @@ in config.mzte-nix-packages = [ pkgs.nix-output-monitor pkgs.nix-du + (pkgs.nsxiv.overrideAttrs { + patches = [ (common.confgenFile "cgassets/nix/nsxiv-config.patch") ]; + }) (flakePkg "github:nix-community/zon2nix") ];