You are not logged in.
I've been trying to make a hook to remove orphaned packages after any pacman upgrade, install, or removal and while the triggers work correctly, I'm having issues with my actions. When the hook is fired when it executes "/usr/bin/pacman -R $(pacman -Qqtd)", I get "/usr/bin/pacman: invalid option -- ')'" and my only solution that I know that would work is executing yay -Yc instead because I have yay installed, but I'd rather have pacman do the work here because I find the "don't run yay as sudo" output annoying (although it shouldn't cause any issues because it's just orphaned package removal... I think). Any ideas? I've tried getting it to run in bash and that hasn't helped either.
Last edited by Retr0r0cket (2022-03-15 18:15:10)
Offline
Post your hook.
But I'd guess that it's because your command has spaces in it and you haven't escaped it properly...
https://man.archlinux.org/man/alpm-hooks.5
Offline
The Exec line is not a shell and I generally doubt you should manipulate the pacman database while pacman is running/a transaction happening. Make a wrapper script that runs the command afterwards instead.
The literal answer to your question is
/usr/bin/bash -c "pacman -R $(pacman -Qqtd)"Offline
Here's the hook for reference. Ty @Slithery
[Trigger]
Operation = Upgrade
Operation = Install
Operation = Remove
Type = Package
Target = *
[Action]
Description = Removing orphaned packages...
When = PostTransaction
Exec = /usr/bin/pacman -R $(pacman -Qqtd)
Also @V1del works like a charm now ty!
Last edited by Retr0r0cket (2022-03-15 18:59:43)
Offline
no, at you to create bash(or other) script
hook call this script with
Exec = /etc/pacman.d/scripts/rm_orphans.shnote
Operation = Install
useful ? no : you use yay and yay can remove build deps
----------
best is to display only orphans (and if you want, if list is not empty, display also command for remove)
Last edited by papajoke (2022-03-16 02:03:44)
LTS - Fish - Kde - intel M100 - 16Go RAM - ssd
Offline