update recipes
[scm/bb/meta-tizen.git] / meta-tizen-adaptation / meta / recipes-core / dbus / dbus / dbus.sh
1 # if DBUS session address is not set, try to set it, by getting the DBUS_SESSIONS_BUS_ADDRESS variable
2 # from the first systemd process running for the current user.
3 # This typically allows a 'su - <user>' command to have the right DBUS address.
4
5 if [[ -z "$DBUS_SESSION_BUS_ADDRESS" ]]; then
6    systemd_pid=$(pgrep -U $UID systemd | head -1)
7    if [[ -n "$systemd_pid" ]]; then
8       val=$(sed  '/\<DBUS_SESSION_BUS_ADDRESS=/!d ; s/.*\<DBUS_SESSION_BUS_ADDRESS=\([^[:cntrl:]]*\).*/\1/' /proc/${systemd_pid}/environ)
9       [[ -n "$val" ]] && export DBUS_SESSION_BUS_ADDRESS=$val
10    fi
11 fi
12