-
-
Save s7dhansh/a664a61a49296da16e47 to your computer and use it in GitHub Desktop.
Tackle glib-gio errors while firing an app from command line. Usage: ed.sh <command>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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