From 5a05bf120ac79af9576f4af5c311c3e051fc43be Mon Sep 17 00:00:00 2001 From: tim Date: Mon, 15 Jun 2015 02:03:20 +0200 Subject: [PATCH] dbus requirement for lock_screen --- get_dbus_session | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 get_dbus_session diff --git a/get_dbus_session b/get_dbus_session new file mode 100755 index 0000000..853acf8 --- /dev/null +++ b/get_dbus_session @@ -0,0 +1,30 @@ +#!/bin/bash + +# Remember to run this script using the command "source ./filename.sh" + +# Search these processes for the session variable (they are run as the +# current user and have the DBUS session variable set) +compatiblePrograms=( nautilus kdeinit kded4 pulseaudio trackerd ) + +# Attempt to get a program pid +for index in ${compatiblePrograms[@]}; do + PID=$(pidof -s ${index}) + if [[ "${PID}" != "" ]]; then + break + fi +done +if [[ "${PID}" == "" ]]; then + echo "Could not detect active login session" + return 1 +fi + +QUERY_ENVIRON="$(tr '\0' '\n' < /proc/${PID}/environ | grep "DBUS_SESSION_BUS_ADDRESS" | cut -d "=" -f 2-)" +if [[ "${QUERY_ENVIRON}" != "" ]]; then + export DBUS_SESSION_BUS_ADDRESS="${QUERY_ENVIRON}" + #echo "Connected to dbus session: ${DBUS_SESSION_BUS_ADDRESS}" +else + echo "Could not find dbus session ID in user environment." + return 1 +fi + +return 0