Get back a package that automatic orphan removal deleted
The Omarchy claim is verified: bin/omarchy-update-orphan-pkgs collects pacman -Qtdq and loops sudo pacman -Rs --noconfirm "$pkg" over each, unattended, exactly as described. But the central safety recommendation is wrong: it says to 'prefer -Rn over -Rns so optional deps of surviving packages are spared'. -n is --nosave, which has nothing to do with dependencies. It *deletes* config backups instead of leaving .pacsave files, so the suggested flag is strictly more destructive than plain -R. The safety comes entirely from dropping -s (no recursion). Also pacman -D --asexplicit $(pacman -Qtdq) errors out when there are no orphans.
Blindly running pacman -Qdtq | pacman -Rns - can cascade: removing one orphan orphans its dependencies, and -s follows the chain. On a system where install reasons were never curated this can strip out drivers, firmware, or the display stack. Always read the list before confirming.
Symptom
After an update (notably omarchy-update, which removes orphans automatically), a program you use is gone: an optional dependency, a font, a codec, or a package you originally installed as a dependency of something you later removed. pacman -Q thepackage says it is not installed.
Cause
pacman -Qtdq lists packages installed as dependencies that nothing currently requires. Piping that into pacman -Rns also removes optional dependencies of packages that are staying, and anything you installed with -S --asdeps or that was pulled in as a makedepend. Omarchy's omarchy-update-orphan-pkgs runs sudo pacman -Rs --noconfirm over every orphan on each update.
Fix
Reinstall what you lost and mark it explicit so it is never treated as an orphan again:
sudo pacman -S thepackage
sudo pacman -D --asexplicit thepackage
Find what was removed from the log:
grep "\[ALPM\] removed" /var/log/pacman.log | tail -40
Audit before any future orphan sweep. Review the list, then remove only those packages. Dropping -s is what stops the recursion into optional dependencies of surviving packages. Do **not** add -n: that is --nosave, which deletes your config backups instead of leaving .pacsave files, and has nothing to do with dependency handling.
pacman -Qtdq # review this list first
pacman -Qtdq | sudo pacman -R - # no -s recursion, keeps .pacsave backups
Protect anything you care about up front (guarded so it does not error when nothing is orphaned):
orphans=$(pacman -Qtdq) && [ -n "$orphans" ] && sudo pacman -D --asexplicit $orphans
On Omarchy, if you do not want unattended orphan removal, run the update steps individually instead of omarchy-update:
omarchy-update-keyring
omarchy-update-system-pkgs
omarchy-update-aur-pkgs
Verify
pacman -Qi thepackage | grep 'Install Reason' reports "Explicitly installed", and it survives the next update.