From 0d3d654659e18912f635d51e4d2c8ce67d7c2303 Mon Sep 17 00:00:00 2001 From: smayzy Date: Sun, 6 Jul 2025 19:07:27 +0200 Subject: [PATCH] lf toogle --- hosts/common/home.nix | 2 + modules/home-manager/lf/lf.nix | 147 ++++++++++++++++++--------------- 2 files changed, 81 insertions(+), 68 deletions(-) diff --git a/hosts/common/home.nix b/hosts/common/home.nix index 1246677..1493931 100644 --- a/hosts/common/home.nix +++ b/hosts/common/home.nix @@ -9,6 +9,8 @@ smayzy.webapps.enable = true; + smayzy.lf.enable = true; + home.username = "smayzy"; home.homeDirectory = "/home/smayzy"; home.stateVersion = "25.05"; diff --git a/modules/home-manager/lf/lf.nix b/modules/home-manager/lf/lf.nix index 92d8a8a..723ec3a 100644 --- a/modules/home-manager/lf/lf.nix +++ b/modules/home-manager/lf/lf.nix @@ -1,75 +1,86 @@ -{ pkgs, config, ... }: - +{ pkgs, lib, config, ... }: +let + inherit (lib) mkIf mkOption types; +in { - xdg.configFile."lf/icons".source = ./icons; + options.smayzy.lf.enable = mkOption { + type = types.bool; + default = false; + description = "set to true if you want to use a nvidia GC"; + }; + - programs.lf = { - enable = true; - commands = { - dragon-out = ''%${pkgs.xdragon}/bin/xdragon -a -x "$fx"''; - editor-open = ''$$EDITOR $f''; - mkdir = '' - ''${{ - printf "Directory Name: " - read DIR - mkdir $DIR - }} - ''; - }; - - keybindings = { - - "\\\"" = ""; - o = ""; - c = "mkdir"; - "." = "set hidden!"; - "`" = "mark-load"; - "\\'" = "mark-load"; - "" = "open"; - - do = "dragon-out"; - - "g~" = "cd"; - gh = "cd"; - "g/" = "/"; - - ee = "editor-open"; - V = ''$${pkgs.bat}/bin/bat --paging=always --theme=gruvbox "$f"''; - - }; - - settings = { - preview = true; - hidden = true; - drawbox = true; - icons = true; - ignorecase = true; - }; - - extraConfig = - let - previewer = - pkgs.writeShellScriptBin "pv.sh" '' - file=$1 - w=$2 - h=$3 - x=$4 - y=$5 + config = mkIf config.smayzy.lf.enable { + xdg.configFile."lf/icons".source = ./icons; + + programs.lf = { + enable = true; + commands = { + dragon-out = ''%${pkgs.xdragon}/bin/xdragon -a -x "$fx"''; + editor-open = ''$$EDITOR $f''; + mkdir = '' + ''${{ + printf "Directory Name: " + read DIR + mkdir $DIR + }} + ''; + }; + + keybindings = { + + "\\\"" = ""; + o = ""; + c = "mkdir"; + "." = "set hidden!"; + "`" = "mark-load"; + "\\'" = "mark-load"; + "" = "open"; - if [[ "$( ${pkgs.file}/bin/file -Lb --mime-type "$file")" =~ ^image ]]; then - ${pkgs.kitty}/bin/kitty +kitten icat --silent --stdin no --transfer-mode file --place "''${w}x''${h}@''${x}x''${y}" "$file" < /dev/null > /dev/tty - exit 1 - fi + do = "dragon-out"; - ${pkgs.pistol}/bin/pistol "$file" + "g~" = "cd"; + gh = "cd"; + "g/" = "/"; + + ee = "editor-open"; + V = ''$${pkgs.bat}/bin/bat --paging=always --theme=gruvbox "$f"''; + + }; + + settings = { + preview = true; + hidden = true; + drawbox = true; + icons = true; + ignorecase = true; + }; + + extraConfig = + let + previewer = + pkgs.writeShellScriptBin "pv.sh" '' + file=$1 + w=$2 + h=$3 + x=$4 + y=$5 + + if [[ "$( ${pkgs.file}/bin/file -Lb --mime-type "$file")" =~ ^image ]]; then + ${pkgs.kitty}/bin/kitty +kitten icat --silent --stdin no --transfer-mode file --place "''${w}x''${h}@''${x}x''${y}" "$file" < /dev/null > /dev/tty + exit 1 + fi + + ${pkgs.pistol}/bin/pistol "$file" + ''; + cleaner = pkgs.writeShellScriptBin "clean.sh" '' + ${pkgs.kitty}/bin/kitty +kitten icat --clear --stdin no --silent --transfer-mode file < /dev/null > /dev/tty + ''; + in + '' + set cleaner ${cleaner}/bin/clean.sh + set previewer ${previewer}/bin/pv.sh ''; - cleaner = pkgs.writeShellScriptBin "clean.sh" '' - ${pkgs.kitty}/bin/kitty +kitten icat --clear --stdin no --silent --transfer-mode file < /dev/null > /dev/tty - ''; - in - '' - set cleaner ${cleaner}/bin/clean.sh - set previewer ${previewer}/bin/pv.sh - ''; + }; }; }