You are not logged in.

#1 2015-08-30 17:17:03

ondoho
Member
Registered: 2013-04-30
Posts: 692
Website

execute command after using pacman

i miss this functionality with pacman:
a command to automatically execute after every invocation (presumably installation or removal of software).
now i wrote myself a little wrapper script and would like to submit it to archforum's scrutiny.

an added challenge: the command differs depending on the window manager.
as a normal user, i set the command, but the wrapper has to find it even as superuser.

here's what i came up with:
/usr/local/bin/pacman:

#!/bin/bash

source /home/<user>/.config/menu_updater >/dev/null 2>&1
MENU_UPDATER=${MENU_UPDATER-true}
menu_updater="$(which $MENU_UPDATER)"

/usr/bin/pacman "$@"
returnvalue=$?

sudo -u <user> "$menu_updater" >/dev/null 2>&1 &

exit $returnvalue

(which pacman shows /usr/local/bin/pacman now)

this is preceded by a few lines in ~/.xinitrc:

case "$WM" in
	fluxbox)
		export MENU_UPDATER="fluxbox-generate_menu"
		echo "$MENU_UPDATER=" > $HOME/.config/menu_updater
		exec fluxbox
		;;
	openbox)
		. ~/.fehbg
		fbpanel &
		export MENU_UPDATER="true"
		echo "$MENU_UPDATER=" > $HOME/.config/menu_updater
		exec openbox
		;;
esac

it seems to be working fine, but what do you think?
maybe it's flawed, waiting for a disaster to happen?
maybe there's an easier/better/safer solution?

Last edited by ondoho (2015-08-30 17:18:16)

Offline

#2 2015-08-31 00:10:18

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,587

Re: execute command after using pacman

The easier/better/safer solution is in the pipeline. The next big update to pacman should include hook support.

Online

#3 2015-08-31 19:20:25

pypi
Wiki Maintainer
Registered: 2014-04-22
Posts: 250

Re: execute command after using pacman

Scimmia wrote:

The easier/better/safer solution is in the pipeline. The next big update to pacman should include hook support.

Although I wouldn't be hanging out for it myself - hooks have been "in the pipeline" for quite a while!

See https://bugs.archlinux.org/task/2985, https://wiki.archlinux.org/index.php/Us … cman_Hooks. Perhaps consider voting for the bug if you think it would be helpful.

Offline

#4 2015-08-31 20:35:23

ondoho
Member
Registered: 2013-04-30
Posts: 692
Website

Re: execute command after using pacman

10 years, wow.
i added my vote.

...

the wrapper seems to be working ok.
there's some problems with the menu_updater: sometimes the fluxbox menus come out corrupted, not usre if there's multiple instances of the menu_updater running.
but pacman itself (and yaourt) seem to be fine with this.

Offline

#5 2015-09-01 02:58:17

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,587

Re: execute command after using pacman

pypi wrote:
Scimmia wrote:

The easier/better/safer solution is in the pipeline. The next big update to pacman should include hook support.

Although I wouldn't be hanging out for it myself - hooks have been "in the pipeline" for quite a while!

Ah, but Allan has said it is in the roadmap for 4.3, and there is serious progress: https://lists.archlinux.org/pipermail/p … 20201.html

Online

#6 2015-09-01 19:35:05

pypi
Wiki Maintainer
Registered: 2014-04-22
Posts: 250

Re: execute command after using pacman

Wonderful! Note that the wiki still doesn't list a development branch.
Hopefully it makes it in this time big_smile

Offline

Board footer

Powered by FluxBB