Skip to content

Instantly share code, notes, and snippets.

@aericson
Created January 30, 2015 00:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aericson/e18c6e83a0c4a4b32d3f to your computer and use it in GitHub Desktop.
Save aericson/e18c6e83a0c4a4b32d3f to your computer and use it in GitHub Desktop.
noxaarchup.sh
#!/usr/bin/sh
# based on script from https://aur.archlinux.org/packages/batterylife
call_aarchup(){
dbus=$(grep -z DBUS_SESSION_BUS_ADDRESS $1 | sed 's/DBUS_SESSION_BUS_ADDRESS=//')
user=$(grep -m 1 -z USER $1 | sed 's/USER=//')
dply=$(grep -z DISPLAY $1 | sed 's/DISPLAY=//')
sudo -u $user sh -c "DBUS_SESSION_BUS_ADDRESS=\"$dbus\" DISPLAY=\"$dply\" /usr/bin/aarchup"
}
wrapper(){
called=false
for p in $(pgrep gconf-helper); do
call_aarchup /proc/$p/environ
called=true
done
if [ $called = false ]; then
call_aarchup /proc/self/environ
fi
}
wrapper || exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment