Added by John Christopher almost 11 years ago
Hello,
I want to poll the state of audacious in my acpi /etc/acpi/sleep.sh script so I can pause it when going to suspend mode.
This works:~ $ audtool playback-status
# returns the actual state of audacious
This works:~ # sudo -u $USER bash -c 'whoami'
# returns $USER
but those don't:~ # sudo -u $USER bash -c 'audtool playback-status'
# always returns 'stopped'~ # su -c 'audtool playback-status' jeankri
# always returns 'stopped'
I can't tell if I am missing something with sudo/su or with audpool.
audtool uses D-Bus, so you need $DBUS_SESSION_BUS_ADDRESS set. Here is a script that worked for me:
#!/bin/sh pid=`pidof audacious` user=`ps -p $pid -o user=` export `strings /proc/$pid/environ | grep DBUS_SESSION_BUS_ADDRESS` sudo -E -u $user audtool "$@"