From 042d05bc03d7d4b3f70beb0f9ba21e0962f1f3e3 Mon Sep 17 00:00:00 2001 From: andrey_varnavskiy Date: Tue, 4 Mar 2025 09:28:40 +0500 Subject: [PATCH] books selector script --- home-manager/modules/hyprland/binds.nix | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/home-manager/modules/hyprland/binds.nix b/home-manager/modules/hyprland/binds.nix index 25cf044..707629f 100644 --- a/home-manager/modules/hyprland/binds.nix +++ b/home-manager/modules/hyprland/binds.nix @@ -1,4 +1,22 @@ -{ +{ pkgs, ... }: +let + booksDir = "$HOME/Downloads/books"; + booksScript = pkgs.writeScriptBin "open_books" '' + #!/bin/sh + + BOOKS_DIR="${booksDir}" + + BOOK=$(find "$BOOKS_DIR" -type f \( -iname "*.pdf" -o -iname "*.epub" -o -iname "*.djvu" \) | wofi --dmenu --prompt "Select a book" --width 1200 --height 400) + + if [[ -n "$BOOK" ]]; then + zathura "$BOOK" & + else + echo "No book selected." + fi + ''; +in { + home.packages = [ booksScript ]; + wayland.windowManager.hyprland.settings = { bind = [ "$mainMod SHIFT, Return, exec, $terminal" @@ -17,6 +35,7 @@ "$mainMod, P, exec, hyprpicker -an" "$mainMod, N, exec, swaync-client -t" ", Print, exec, grimblast --notify --freeze copysave area" + "$mainMod, W, exec, ${booksScript}/bin/open_books" # Moving focus "$mainMod, left, movefocus, l"