diff options
| -rw-r--r-- | modules/desktop/i3/keybindings.nix | 4 | ||||
| -rw-r--r-- | modules/scripts/default.nix | 82 | ||||
| -rw-r--r-- | modules/scripts/fzf-launcher.sh | 24 | ||||
| -rw-r--r-- | modules/tools/default.nix | 1 | ||||
| -rw-r--r-- | modules/tools/rofi/default.nix | 85 | ||||
| -rw-r--r-- | users/arpit.nix | 1 |
6 files changed, 59 insertions, 138 deletions
diff --git a/modules/desktop/i3/keybindings.nix b/modules/desktop/i3/keybindings.nix index 6933979..cb8fd32 100644 --- a/modules/desktop/i3/keybindings.nix +++ b/modules/desktop/i3/keybindings.nix @@ -10,7 +10,9 @@ let in { # --- General Applications --- - "${mod}+r" = lib.mkIf config.tools.rofi.enable "exec ${lib.getExe pkgs.rofi} -show drun"; + "${mod}+r" = + lib.mkIf (config.tools.fzf.enable && config.tools.kitty.enable) + "exec ${lib.getExe pkgs.kitty} --class floating-termial -e ${lib.getExe config.scripts.fzf-launcher}"; "${mod}+t" = lib.mkIf config.tools.kitty.enable "exec ${lib.getExe pkgs.kitty}"; "${mod}+f" = lib.mkIf config.tools.kitty.enable "exec ${lib.getExe pkgs.kitty} --title 'File Manager' --class floating-termial -e nnn"; diff --git a/modules/scripts/default.nix b/modules/scripts/default.nix index 5242280..95d9298 100644 --- a/modules/scripts/default.nix +++ b/modules/scripts/default.nix @@ -4,19 +4,13 @@ pkgs, ... }: - let - # name: Script name - # path: Path to script file - # env: (Optional) Attribute set of environment variables { KEY = "VALUE"; } + shell = + if config.tools.zsh.enable then (lib.getExe config.programs.zsh.package) else "/usr/bin/env sh"; + mkScript = name: path: env: let - # Generate the shell shebang based on your config - shell = - if config.tools.zsh.enable then (lib.getExe config.programs.zsh.package) else "/usr/bin/env sh"; - - # Convert the 'env' attribute set into a string of "export KEY='VALUE'" lines envVars = lib.concatStringsSep "\n" (lib.mapAttrsToList (n: v: "${n}=\"${toString v}\"") env); in pkgs.writeTextFile { @@ -29,28 +23,26 @@ let ${builtins.readFile path} ''; }; -in -{ - config = { - home.packages = [ - # Always included (pass empty set {} if no env vars needed) - (mkScript "deep-clean" ./deep-clean.sh { }) - # Conditional scripts - (lib.mkIf config.tools.fzf.enable ( - mkScript "fzf-launcher" ./fzf-launcher.sh { - FZF = lib.getExe pkgs.fzf; - } - )) + scripts = { + deep-clean = mkScript "deep-clean" ./deep-clean.sh { }; + + fzf-launcher = lib.mkIf config.tools.fzf.enable ( + mkScript "fzf-launcher" ./fzf-launcher.sh { + FZF = lib.getExe pkgs.fzf; + SETSID = "${pkgs.util-linux}/bin/setsid"; + } + ); - (lib.mkIf (config.tools.ffmpeg.enable && config.tools.slop.enable) ( - mkScript "screen-recording" ./screen-recording.sh { - FFMPEG = lib.getExe pkgs.ffmpeg-full; - SLOP = lib.getExe pkgs.slop; - } - )) + screen-recording = lib.mkIf (config.tools.ffmpeg.enable && config.tools.slop.enable) ( + mkScript "screen-recording" ./screen-recording.sh { + FFMPEG = lib.getExe pkgs.ffmpeg-full; + SLOP = lib.getExe pkgs.slop; + } + ); - (lib.mkIf + system-monitor = + lib.mkIf ( config.tools.bottom.enable && config.tools.nvtop.enable @@ -64,16 +56,30 @@ in TMUX = lib.getExe pkgs.tmux; KITTY = lib.getExe pkgs.kitty; } - ) - ) + ); + + vpn-connect = lib.mkIf (config.tools.openvpn.enable && config.tools.fzf.enable) ( + mkScript "vpn-connect" ./vpn-connect.sh { + FZF = lib.getExe pkgs.fzf; + OPENVPN = lib.getExe pkgs.openvpn; + SYSTEMD_RESOLVED = "${pkgs.openvpn}/libexec/update-systemd-resolved"; + } + ); + }; +in +{ + options.scripts = lib.mapAttrs ( + name: _: + lib.mkOption { + type = lib.types.nullOr lib.types.package; + default = null; + description = "Derivation for the ${name} script, or null if disabled."; + } + ) scripts; + + config = { + scripts = scripts; - (lib.mkIf (config.tools.openvpn.enable && config.tools.fzf.enable) ( - mkScript "vpn-connect" ./vpn-connect.sh { - FZF = lib.getExe pkgs.fzf; - OPENVPN = lib.getExe pkgs.openvpn; - SYSTEMD_RESOLVED = "${pkgs.openvpn}/libexec/update-systemd-resolved"; - } - )) - ]; + home.packages = lib.filter (x: x != null) (lib.mapAttrsToList (_: v: lib.mkIf true v) scripts); }; } diff --git a/modules/scripts/fzf-launcher.sh b/modules/scripts/fzf-launcher.sh index 592dd1e..79853f1 100644 --- a/modules/scripts/fzf-launcher.sh +++ b/modules/scripts/fzf-launcher.sh @@ -8,19 +8,15 @@ entries="" for dir in "${DIRS[@]}"; do [[ -d "$dir" ]] || continue + for f in "$dir"/*.desktop; do [[ -f "$f" ]] || continue grep -q "^NoDisplay=true" "$f" && continue - grep -q "^Hidden=true" "$f" && continue - - # only keep Type=Application entries + grep -q "^Hidden=true" "$f" && continue grep -q "^Type=Application" "$f" || continue + grep -q "^Terminal=true" "$f" && continue - # skip terminal-only apps (no GUI window) - grep -q "^Terminal=true" "$f" && continue - - # skip entries that are purely settings/mime handlers/background services categories=$(grep -m1 "^Categories=" "$f" | cut -d= -f2-) if [[ -n "$categories" ]]; then echo "$categories" | grep -qE "(Settings|System|Screensaver|DesktopSettings|PackageManager)" && continue @@ -31,21 +27,25 @@ for dir in "${DIRS[@]}"; do [[ -z "$name" || -z "$exec" ]] && continue - exec=$(echo "$exec" | sed 's/ %[fFuUickdDnNvm]//g') + # Remove field codes properly + exec=$(echo "$exec" | sed -E 's/ ?%[a-zA-Z]//g') entries+="$name"$'\t'"$exec"$'\n' done done -chosen=$(printf '%s' "$entries" | sort -f -t$'\t' -k1,1 | "$FZF" \ +entries=$(printf '%s' "$entries" | sort -fu -t$'\t' -k1,1) + +chosen=$(printf '%s' "$entries" | "$FZF" \ --prompt='Launch: ' \ --layout=reverse \ --info=inline \ - --with-nth=1 \ - --delimiter=$'\t') + --delimiter=$'\t' \ + --with-nth=1) [[ -z "$chosen" ]] && exit 0 exec_cmd=$(printf '%s' "$chosen" | cut -d$'\t' -f2) -setsid bash -c "$exec_cmd" &>/dev/null & + +eval "$exec_cmd" &>/dev/null & disown diff --git a/modules/tools/default.nix b/modules/tools/default.nix index b21dbc2..82659cc 100644 --- a/modules/tools/default.nix +++ b/modules/tools/default.nix @@ -29,7 +29,6 @@ ./pamixer ./playerctl ./qemu - ./rofi ./slop ./starship ./systemctl-tui diff --git a/modules/tools/rofi/default.nix b/modules/tools/rofi/default.nix deleted file mode 100644 index 525387f..0000000 --- a/modules/tools/rofi/default.nix +++ /dev/null @@ -1,85 +0,0 @@ -{ lib, config, ... }: - -# Rofi - Window switcher, application launcher, and dmenu replacement -{ - options.tools.rofi = { - enable = lib.mkEnableOption "Enables rofi."; - }; - - config = lib.mkIf config.tools.rofi.enable { - programs.rofi = { - enable = true; - font = "${config.fonts.normal} ${toString config.fonts.size}"; - theme = - with config.scheme.withHashtag; - let - inherit (config.lib.formats.rasi) mkLiteral; - in - { - "*" = { - border = 1; - margin = 0; - padding = 0; - spacing = 0; - - bg = mkLiteral base00; - bg-alt = mkLiteral base01; - fg = mkLiteral base07; - fg-alt = mkLiteral base03; - background-color = mkLiteral "@bg"; - text-color = mkLiteral "@fg"; - }; - - window = { - border-color = mkLiteral base03; - }; - - mainbox = { - children = map mkLiteral [ - "inputbar" - "listview" - ]; - }; - - inputbar = { - background-color = mkLiteral "@bg-alt"; - children = map mkLiteral [ - "prompt" - "entry" - ]; - }; - - entry = { - background-color = mkLiteral "inherit"; - padding = mkLiteral "12px 3px"; - }; - - prompt = { - background-color = mkLiteral "inherit"; - padding = mkLiteral "12px"; - }; - - listview = { - lines = 8; - }; - - element = { - children = map mkLiteral [ "element-text" ]; - }; - - element-icon = { - padding = mkLiteral "10px 10px"; - }; - - element-text = { - padding = mkLiteral "10px 10px"; - text-color = mkLiteral "@fg-alt"; - }; - - "element-text selected" = { - text-color = mkLiteral "@fg"; - }; - }; - }; - }; -} diff --git a/users/arpit.nix b/users/arpit.nix index a94e99e..f446edd 100644 --- a/users/arpit.nix +++ b/users/arpit.nix @@ -39,7 +39,6 @@ tools.pamixer.enable = true; tools.playerctl.enable = true; tools.qemu.enable = true; - tools.rofi.enable = true; tools.slop.enable = true; tools.starship.enable = true; tools.systemctl-tui.enable = true; |
