diff options
| author | Arpit Chakladar <arpitchakladar+git@gmail.com> | 2026-07-18 14:55:21 +0530 |
|---|---|---|
| committer | Arpit Chakladar <arpitchakladar+git@gmail.com> | 2026-07-18 14:55:21 +0530 |
| commit | 03bd9b6ad5335aff65d9cb6fb1d117b5cb4b7919 (patch) | |
| tree | 04780c0d23aac335fe60320c181bd3ac6850d5d3 /modules/scripts/fzf-launcher/script.sh | |
| parent | bde84587b2a408970086f4c708ac9a629abfa554 (diff) | |
| download | home-manager-config-03bd9b6ad5335aff65d9cb6fb1d117b5cb4b7919.tar.gz home-manager-config-03bd9b6ad5335aff65d9cb6fb1d117b5cb4b7919.zip | |
refactor(scripts): split monolithic module into per-script submodules
Extract shared `mkScript` and `mkScriptModule` helpers into `lib.nix`
Split each script into `modules/scripts/<name>/` with its own
`default.nix`, `script.sh`, and `assertions.nix`
Remove `conditions` parameter from `mkScriptModule`; move condition
assertions into per-script `assertions.nix` files with inline checks
and error messages
Simplify `mkScriptModule` to return `{ options, moduleConfig }` instead
of a module function, taking `config` as a direct parameter
Add `description` field to `mkScript` that inserts the description as
a `# <text>` comment between the shebang and env vars
Thread `description` through `mkScriptModule` to each `default.nix`
Move top comment lines from each `script.sh` into the `description`
field and remove from sources to avoid duplication
Remove old flat `.sh` files from `modules/scripts/` root
Diffstat (limited to 'modules/scripts/fzf-launcher/script.sh')
| -rw-r--r-- | modules/scripts/fzf-launcher/script.sh | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/modules/scripts/fzf-launcher/script.sh b/modules/scripts/fzf-launcher/script.sh new file mode 100644 index 0000000..2fce83a --- /dev/null +++ b/modules/scripts/fzf-launcher/script.sh @@ -0,0 +1,48 @@ +DIRS=( + /run/current-system/sw/share/applications + "$HOME/.nix-profile/share/applications" + "$HOME/.local/share/applications" +) + +shopt -s nullglob + +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 + grep -q "^Type=Application" "$f" || continue + grep -q "^Terminal=true" "$f" && continue + + categories=$(grep -m1 "^Categories=" "$f" | cut -d= -f2-) + if [[ -n "$categories" ]]; then + echo "$categories" | grep -qE "(Settings|Screensaver|DesktopSettings)" && continue + fi + + 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 + + entries+="$name"$'\t'"$f"$'\n' + done +done + +entries=$(printf '%s' "$entries" | sort -fu -t$'\t' -k1,1) + +chosen=$(printf '%s' "$entries" | fzf \ + --prompt='Launch: ' \ + --layout=reverse \ + --info=inline \ + --delimiter=$'\t' \ + --with-nth=1) + +[[ -z "$chosen" ]] && exit 0 + +desktop_file=$(printf '%s' "$chosen" | cut -d$'\t' -f2-) + +setsid -f dex "$desktop_file" </dev/null >/dev/null 2>&1 |
