Last active
March 10, 2025 14:52
-
-
Save re-xyr/efede2d1c36543260192e4e8b17a2fc5 to your computer and use it in GitHub Desktop.
pacman-detect-orphans
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Trigger] | |
Operation = Install | |
Operation = Upgrade | |
Operation = Remove | |
Type = Package | |
Target = * | |
[Action] | |
Description = Detecting orphaned packages... | |
When = PostTransaction | |
Exec = /usr/local/bin/pacman-detect-orphans |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
orphans=$(pacman -Qtd) | |
if [[ -z $orphans ]]; then | |
echo "==> no orphan packages found" | |
else | |
lines=$(echo "$orphans" | wc -l) | |
echo -ne "\033[1m==> $lines orphan package(s) found:\033[0m " | |
echo "$orphans" | while read line; do | |
IFS=' ' read -r -a array <<< "$line" | |
echo -ne "${array[0]}\033[38;5;243m-${array[1]}\033[0m " | |
done | |
echo | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment