dot
vizie's NixOS desktop: Hyprland, CachyOS kernel and gaming tweaks
| 1 | #!/usr/bin/env bash |
| 2 | # Opens fuzzel with the apps in ./favorites at the top of its list. Hyprland's |
| 3 | # mod + Return runs this (modules/home/desktop.nix). |
| 4 | # |
| 5 | # Fuzzel can't pin apps; it sorts by how often each one was launched, counted in |
| 6 | # its cache ($XDG_CACHE_HOME/fuzzel, lines of "name.desktop|count"). So before |
| 7 | # every start this sets the favourites' counts far above anything normal use |
| 8 | # reaches, highest first, and leaves every other app's count as it is. |
| 9 | |
| 10 | dir="$(dirname "$(readlink -f "$0")")" |
| 11 | cache="${XDG_CACHE_HOME:-$HOME/.cache}/fuzzel" |
| 12 | touch "$cache" |
| 13 | |
| 14 | awk -F'|' -v OFS='|' ' |
| 15 | FNR == NR { |
| 16 | sub(/#.*/, ""); gsub(/[ \t]/, "") |
| 17 | if ($0 != "" && !($0 in fav)) { fav[$0] = 1000000 - n++; order[n] = $0 } |
| 18 | next |
| 19 | } |
| 20 | !($1 in fav) && $0 != "" { print } |
| 21 | END { for (i = 1; i <= n; i++) print order[i], fav[order[i]] } |
| 22 | ' "$dir/favorites" "$cache" > "$cache.tmp" && mv "$cache.tmp" "$cache" |
| 23 | |
| 24 | exec fuzzel "$@" |