I made an "autoremove" hook that removes packages no more necessary, but since it is executed when pacman is in use:
(1/3) autoremove.hook
error: failed to init transaction (unable to lock database)
error: could not lock database: File exists
if you're sure a package manager is not already
running, you can remove /var/lib/pacman/db.lck
error: command failed to execute correctly
I saw the command on some wiki:
pacman -Qtdq | pacman -Rns -
I think that would be nice to have an option in the pacman config to do this automatically.
Won't simply running pacman -Rns on the target package also remove the leftovers, at least majority of the time?
I wouldn't recommend deleting the lock file when another hook may take place after yours, executing concurrently and corrupting the db like that.
I didn't think about that, I don't know pacman so well yet.
It seems fine thanks.