#!/bin/bash # Build a candidate "daily use" package list from two independent signals. # # Shell history alone is blind to anything started from the desktop menu, and a # .desktop file alone says nothing about whether the thing is ever opened. Taken # together they cover both halves: CLI tools by how often they were actually # run, GUI applications by the fact that they were explicitly installed and ship # a menu entry. # # Everything here is a candidate, not a decision. The point is to replace # guessing about 512 packages with a list short enough to read. set -u OUT=/home/templis/.claude/jobs/e44cbeae/tmp EXPLICIT=$(mktemp) pacman -Qqe | sort -u > "$EXPLICIT" # One pass over the file lists instead of one pacman -Qo per command: -Qo forks # a lookup every time and takes minutes for 40 commands. MAP="$OUT/file2pkg.txt" pacman -Ql $(cat "$EXPLICIT") 2>/dev/null | awk '$2 ~ /\/(bin|sbin)\/[^\/]+$/ {n=split($2,a,"/"); print a[n], $1}' | sort -u > "$MAP" # --- Signal 1: commands actually run, mapped to their package ------------- : > "$OUT/cli_pkgs.txt" while read -r count cmd; do [ "${count:-0}" -lt 5 ] && continue pkg=$(awk -v c="$cmd" '$1 == c {print $2; exit}' "$MAP") [ -n "$pkg" ] && printf '%s\t%s\t%s\n' "$count" "$pkg" "$cmd" done < /tmp/claude-1000/cmdfreq.txt | sort -rn -k1 > "$OUT/cli_pkgs.txt" # --- Signal 2: explicitly installed packages that ship a menu entry ------- : > "$OUT/gui_pkgs.txt" pacman -Qlq $(cat "$EXPLICIT") 2>/dev/null | grep -E '/usr/share/applications/[^/]+\.desktop$' > "$OUT/desktop_files.txt" while read -r pkg; do if pacman -Qlq "$pkg" 2>/dev/null | grep -qE '/usr/share/applications/[^/]+\.desktop$'; then echo "$pkg" fi done < "$EXPLICIT" > "$OUT/gui_pkgs.txt" echo "CLI-Pakete aus History : $(awk '{print $2}' "$OUT/cli_pkgs.txt" | sort -u | wc -l)" echo "GUI-Pakete mit Menue : $(wc -l < "$OUT/gui_pkgs.txt")" rm -f "$EXPLICIT"