From bde84587b2a408970086f4c708ac9a629abfa554 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar Date: Sat, 18 Jul 2026 14:27:58 +0530 Subject: feat: switch launcher to dex, add vi-mode and kitty nav, enable ouch unfree Rewrite fzf-launcher to use dex via setsid instead of parsing Exec= lines Add vi-mode (bindkey -v, KEYTIMEOUT=1) to zsh Add Ctrl+click link handling and Ctrl+Shift+h/j/k/l window nav to kitty Switch i3 terminal key from $mod+t to $mod+Return Enable unRAR support in ouch (override enableUnfree) Fix epub cover extraction (decompress full archive, use find) Remove neomutt dd/gT keybindings Fix missing $TITLE quoting in neomutt-sync Add findutils and dex to script deps --- modules/communication/neomutt/keybindings.nix | 20 ++---------------- modules/desktop/i3/keybindings.nix | 2 +- modules/file-management/ouch/default.nix | 9 ++++++++- modules/scripts/default.nix | 2 ++ modules/scripts/file-preview.sh | 6 ++++-- modules/scripts/fzf-launcher.sh | 29 +++++++-------------------- modules/scripts/neomutt-sync.sh | 4 ++-- modules/terminal/kitty/default.nix | 11 ++++++++++ modules/terminal/zsh/default.nix | 4 ++++ 9 files changed, 41 insertions(+), 46 deletions(-) diff --git a/modules/communication/neomutt/keybindings.nix b/modules/communication/neomutt/keybindings.nix index 6b9cdb4..b84386c 100644 --- a/modules/communication/neomutt/keybindings.nix +++ b/modules/communication/neomutt/keybindings.nix @@ -225,17 +225,7 @@ action = "search-opposite"; } - # --- delete / undelete (vim: dd delete line, u undo) --- - { - map = [ "index" ]; - key = "d"; - action = "noop"; - } - { - map = [ "index" ]; - key = "dd"; - action = "delete-message"; - } + # --- undelete --- { # capital D deletes the whole thread, mirroring the v/V # (single vs. whole-thread) convention used below for tagging @@ -287,18 +277,12 @@ action = "tag-thread"; } - # --- mailbox switching (vim: gt/gT next/previous tab) --- + # --- mailbox switching --- { map = [ "index" ]; key = "gt"; action = "next-unread-mailbox"; } - { - map = [ "index" ]; - key = "gT"; - action = "previous-unread-mailbox"; - } - # --- filter/limit (vim: gf to 'find'/'filter') --- # gF is the "clear filter" counterpart, defined as a macro # (see macros.nix) since resetting the limit needs a fixed diff --git a/modules/desktop/i3/keybindings.nix b/modules/desktop/i3/keybindings.nix index 220fb86..1392426 100644 --- a/modules/desktop/i3/keybindings.nix +++ b/modules/desktop/i3/keybindings.nix @@ -11,7 +11,7 @@ in "${mod}+r" = lib.mkIf (config.terminal.fzf.enable && config.terminal.kitty.enable) "exec ${lib.getExe config.terminal.kitty.package} --class application-launcher -e ${lib.getExe config.scripts.fzf-launcher.package}"; - "${mod}+t" = + "${mod}+Return" = lib.mkIf config.terminal.kitty.enable "exec ${lib.getExe config.terminal.kitty.package}"; "${mod}+f" = lib.mkIf (config.terminal.kitty.enable && config.file-management.lf.enable) diff --git a/modules/file-management/ouch/default.nix b/modules/file-management/ouch/default.nix index 40f5101..01a865a 100644 --- a/modules/file-management/ouch/default.nix +++ b/modules/file-management/ouch/default.nix @@ -8,7 +8,14 @@ { options.file-management.ouch = { enable = lib.mkEnableOption "Enables ouch."; - package = lib.mkPackageOption pkgs "ouch" { }; + package = lib.mkOption { + type = lib.types.package; + default = pkgs.ouch.override { + enableUnfree = true; + }; + defaultText = lib.literalExpression "pkgs.ouch.override { enableUnfree = true; }"; + description = "The Ouch package to use, with unRAR support enabled."; + }; }; config = lib.mkIf config.file-management.ouch.enable { diff --git a/modules/scripts/default.nix b/modules/scripts/default.nix index a2d9e1a..789c32d 100644 --- a/modules/scripts/default.nix +++ b/modules/scripts/default.nix @@ -65,6 +65,7 @@ let config.file-management.ouch.package pkgs.coreutils pkgs.file + pkgs.findutils pkgs.fontconfig pkgs.librsvg pkgs.antiword @@ -107,6 +108,7 @@ let path = ./fzf-launcher.sh; deps = [ config.terminal.fzf.package + pkgs.dex pkgs.util-linux ]; conditions = [ diff --git a/modules/scripts/file-preview.sh b/modules/scripts/file-preview.sh index 047252d..7712754 100644 --- a/modules/scripts/file-preview.sh +++ b/modules/scripts/file-preview.sh @@ -93,8 +93,10 @@ case "$MIMETYPE" in application/epub+zip|application/x-mobipocket-ebook) TMP_IMG="$TMP_DIR/epub-${INODE}.png" if [ ! -f "$TMP_IMG" ]; then - ouch decompress "$FILE_PATH" --limit "*/cover*.jpg" --dir "$TMP_DIR" >/dev/null 2>&1 - mv "$TMP_DIR"/cover*.jpg "$TMP_IMG" 2>/dev/null + EPUB_DIR="$TMP_DIR/epub-${INODE}" + ouch decompress --yes --dir "$EPUB_DIR" "$FILE_PATH" >/dev/null 2>&1 + COVER=$(find "$EPUB_DIR" -type f \( -iname 'cover*.jpg' -o -iname 'cover*.jpeg' -o -iname 'cover*.png' \) -print -quit) + [ -n "$COVER" ] && cp "$COVER" "$TMP_IMG" fi [ -s "$TMP_IMG" ] && render_image "$TMP_IMG" ;; diff --git a/modules/scripts/fzf-launcher.sh b/modules/scripts/fzf-launcher.sh index 5ae3d95..0858078 100644 --- a/modules/scripts/fzf-launcher.sh +++ b/modules/scripts/fzf-launcher.sh @@ -1,55 +1,41 @@ # Fzf-launcher - FZF-based application launcher (scans .desktop files) + DIRS=( /run/current-system/sw/share/applications "$HOME/.nix-profile/share/applications" "$HOME/.local/share/applications" ) -entries="" +shopt -s nullglob +entries="" for dir in "${DIRS[@]}"; do [[ -d "$dir" ]] || continue - - shopt -s nullglob for f in "$dir"/*.desktop; do [[ -f "$f" ]] || continue - # Skip hidden entries grep -q "^NoDisplay=true" "$f" && continue grep -q "^Hidden=true" "$f" && continue - - # Only GUI apps grep -q "^Type=Application" "$f" || continue grep -q "^Terminal=true" "$f" && continue - # Skip ONLY actual junk categories (not System!) categories=$(grep -m1 "^Categories=" "$f" | cut -d= -f2-) if [[ -n "$categories" ]]; then echo "$categories" | grep -qE "(Settings|Screensaver|DesktopSettings)" && continue fi - # Get name (handle localized fallback) name=$(grep -m1 "^Name=" "$f" | cut -d= -f2-) if [[ -z "$name" ]]; then name=$(grep -m1 -E "^Name\[.*\]=" "$f" | cut -d= -f2-) fi + [[ -z "$name" ]] && continue - # Get exec - exec=$(grep -m1 "^Exec=" "$f" | cut -d= -f2-) - - [[ -z "$name" || -z "$exec" ]] && continue - - # Remove field codes like %U %F etc. - exec=$(echo "$exec" | sed -E 's/ ?%[a-zA-Z]//g') - - entries+="$name"$'\t'"$exec"$'\n' + entries+="$name"$'\t'"$f"$'\n' done done -# Deduplicate + sort entries=$(printf '%s' "$entries" | sort -fu -t$'\t' -k1,1) -# FZF selection chosen=$(printf '%s' "$entries" | fzf \ --prompt='Launch: ' \ --layout=reverse \ @@ -59,7 +45,6 @@ chosen=$(printf '%s' "$entries" | fzf \ [[ -z "$chosen" ]] && exit 0 -exec_cmd=$(printf '%s' "$chosen" | cut -d$'\t' -f2) +desktop_file=$(printf '%s' "$chosen" | cut -d$'\t' -f2-) -# Launch safely -eval "$exec_cmd" &>/dev/null & +setsid -f dex "$desktop_file" /dev/null 2>&1 diff --git a/modules/scripts/neomutt-sync.sh b/modules/scripts/neomutt-sync.sh index 1adbc7f..e5aae34 100644 --- a/modules/scripts/neomutt-sync.sh +++ b/modules/scripts/neomutt-sync.sh @@ -52,12 +52,12 @@ EOF # --- PHASE 2: notmuch --- printf "XXX\n100\nIndexing new mail with notmuch...\nXXX\n" notmuch new > "$NOTMUCH_LOG" 2>&1 -) | dialog --title $TITLE --gauge "Initializing..." 8 80 0 +) | dialog --title "$TITLE" --gauge "Initializing..." 8 80 0 # 3. Format the captured notmuch output into a single clean line CLEAN_OUT=$(tr '\n' ' ' < "$NOTMUCH_LOG" | sed 's/ */ /g') # 4. Display final results and wait for user input (Enter/Esc) to dismiss -dialog --title $TITLE --msgbox "Done!\n$CLEAN_OUT" 8 80 +dialog --title "$TITLE" --msgbox "Done!\n$CLEAN_OUT" 8 80 clear diff --git a/modules/terminal/kitty/default.nix b/modules/terminal/kitty/default.nix index 2d5faf0..5df4bca 100644 --- a/modules/terminal/kitty/default.nix +++ b/modules/terminal/kitty/default.nix @@ -19,6 +19,17 @@ programs.kitty = { enable = true; package = config.terminal.kitty.package; + extraConfig = '' + # Keep normal clicks for selection and prompt placement; Ctrl+click opens links. + mouse_map left click ungrabbed mouse_handle_click selection prompt + mouse_map ctrl+left click grabbed,ungrabbed mouse_handle_click link + + # Vim-style navigation between Kitty windows in the current tab. + map ctrl+shift+h neighboring_window left + map ctrl+shift+j neighboring_window bottom + map ctrl+shift+k neighboring_window top + map ctrl+shift+l neighboring_window right + ''; settings = with config.scheme.withHashtag; { window_padding_width = 10; font_size = config.fonts.size; diff --git a/modules/terminal/zsh/default.nix b/modules/terminal/zsh/default.nix index 95a44ec..bd0fee6 100644 --- a/modules/terminal/zsh/default.nix +++ b/modules/terminal/zsh/default.nix @@ -25,6 +25,10 @@ initContent = '' setopt PROMPT_SUBST + # Vi insert/command modes for command-line editing. Escape enters normal mode. + bindkey -v + KEYTIMEOUT=1 + autoload -U colors && colors export GPG_TTY="$(tty)" -- cgit v1.2.3