Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DBUS_VARS_FILE="$HOME/.dbus_vars" # Where file with variables is stored
- # This function launches dbus and saves environment variables
- launch_dbus() {
- OLDUMASK=$(umask) # Save umask
- umask 0077 # Set secure umask
- if dbus-launch --auto-syntax > "$DBUS_VARS_FILE"; # Launch DBus and save its environment variables
- then
- . "$DBUS_VARS_FILE" # Load environment variables
- else
- # Error
- echo Failed to launch DBus
- fi
- umask $OLDUMASK # Restore umask
- }
- if [ -f "$DBUS_VARS_FILE" ];
- then
- . "$DBUS_VARS_FILE" # Load environment variables
- if ps ax | grep -q '^ '"$DBUS_SESSION_BUS_PID"; # Check whether DBus is running
- then
- echo -n # DBus is running, so do nothing
- else
- launch_dbus # DBus is not running (old file was loaded)
- fi
- else
- launch_dbus
- fi
Advertisement
Add Comment
Please, Sign In to add comment