Skip to content

Instantly share code, notes, and snippets.

@s7dhansh s7dhansh/ed.sh Secret
Created May 1, 2011

Embed
What would you like to do?
Tackle glib-gio errors while firing an app from command line. Usage: ed.sh <command>
#!/bin/bash
exportDbus () {
# Get the pid of nautilus
nautilus_pid=$(pgrep -u $LOGNAME -n nautilus)
# If nautilus isn't running, just exit silently
if [ -z "$nautilus_pid" ]; then
exit 0
fi
# Grab the DBUS_SESSION_BUS_ADDRESS variable from nautilus's environment
eval $(tr '\0' '\n' < /proc/$nautilus_pid/environ | grep '^DBUS_SESSION_BUS_ADDRESS=')
# Check that we actually found it
if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then
echo "Failed to find bus address" >&2
exit 1
fi
# export it so that child processes will inherit it
export DBUS_SESSION_BUS_ADDRESS
}
exportDbus
$@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.