patch nsxiv

This commit is contained in:
caandt 2025-01-01 01:04:23 -05:00
parent 333fef2297
commit 9f260c9a73
7 changed files with 82 additions and 9 deletions

15
overlays/default.nix Normal file
View file

@ -0,0 +1,15 @@
{pkgs, ...}: {
nixpkgs.overlays = [
(self: super: {
nsxiv = super.nsxiv.overrideAttrs (old: {
buildInputs = old.buildInputs ++ [pkgs.xorg.libXcursor];
env.NIX_LDFLAGS = "-lXcursor";
patches = [./nsxiv.diff];
});
maim = super.maim.overrideAttrs (old: {
buildInputs = old.buildInputs ++ [pkgs.xorg.libXcursor];
env.NIX_LDFLAGS = "-lXcursor";
});
})
];
}

61
overlays/nsxiv.diff Normal file
View file

@ -0,0 +1,61 @@
--- a/config.def.h
+++ b/config.def.h
@@ -191,9 +191,9 @@
static const button_t buttons_img[] = {
/* modifiers button function argument */
{ 0, 1, i_cursor_navigate, None },
- { ControlMask, 1, i_drag, DRAG_RELATIVE },
{ 0, 2, i_drag, DRAG_ABSOLUTE },
- { 0, 3, g_switch_mode, None },
+ { 0, 3, i_drag, DRAG_RELATIVE },
+ { ControlMask, 3, g_switch_mode, None },
{ 0, 4, g_zoom, +1 },
{ 0, 5, g_zoom, -1 },
};
--- a/window.c
+++ b/window.c
@@ -31,6 +31,7 @@
#include <X11/Xatom.h>
#include <X11/Xresource.h>
#include <X11/cursorfont.h>
+#include <X11/Xcursor/Xcursor.h>
#if HAVE_LIBFONTS
#include "utf8.h"
@@ -53,15 +54,18 @@
static GC gc;
static int barheight;
static struct {
- int name;
+ union {
+ char *name;
+ int num;
+ };
Cursor icon;
} cursors[CURSOR_COUNT] = {
- { XC_left_ptr },
+ { "left_ptr" },
{ XC_dotbox },
- { XC_fleur },
+ { "dnd-move" },
- { XC_watch },
+ { "wait" },
- { XC_sb_left_arrow },
+ { "left-arrow" },
- { XC_sb_right_arrow }
+ { "right-arrow" }
};
#if HAVE_LIBFONTS
@@ -272,7 +276,10 @@
for (i = 0; i < (int)ARRLEN(cursors); i++) {
if (i != CURSOR_NONE)
- cursors[i].icon = XCreateFontCursor(e->dpy, cursors[i].name);
+ if (cursors[i].num < 0x100)
+ cursors[i].icon = XCreateFontCursor(e->dpy, cursors[i].num);
+ else
+ cursors[i].icon = XcursorLibraryLoadCursor(e->dpy, cursors[i].name);
}
if (XAllocNamedColor(e->dpy, e->cmap, "black", &col, &col) == 0)
error(EXIT_FAILURE, 0, "Error allocating color 'black'");

View file

@ -9,6 +9,7 @@
./plasma.nix
./security.nix
./virt.nix
../overlays
];
options.u = {
has = {

View file

@ -5,8 +5,8 @@
}: let
deps = {
bell = [pkgs.pipewire pkgs.libnotify];
#nsxiv-rifle = [pkgs.nsxiv];
#screenshot = [pkgs.maim pkgs.xclip];
nsxiv-rifle = [pkgs.nsxiv];
screenshot = [pkgs.maim pkgs.xclip];
};
ln = config.u.lib.ln "${config.u.confPath}/user/bin";
in {

View file

@ -15,6 +15,7 @@
./share
./theme.nix
./xdg.nix
../overlays
];
home.homeDirectory = lib.mkDefault "/home/${config.home.username}";
home.stateVersion = "24.05";

View file

@ -71,11 +71,6 @@
ln = base: x: config.lib.file.mkOutOfStoreSymlink "${base}/${x}";
lnh = ln "${config.home.homeDirectory}";
lnn = ln "${config.u.confPath}";
fixXcursor = pkg:
pkg.overrideAttrs {
buildInputs = pkg.buildInputs ++ [pkgs.xorg.libXcursor];
env.NIX_LDFLAGS = "-lXcursor";
};
localHome = pkg: name: bin:
pkgs.symlinkJoin {
name = name;

View file

@ -33,10 +33,10 @@
(config.u.lib.localHome pkgs.firefox-bin "firefox" "bin/firefox")
alacritty
mpv
(config.u.lib.fixXcursor nsxiv)
nsxiv
rofi
sct
(config.u.lib.fixXcursor maim)
maim
xclip
copyq
picom