Skip to content

Commit 44d5ce9

Browse files
author
Thomas Venries
committed
src: Fix the try to share the same display bus
1 parent f7837fc commit 44d5ce9

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/batify.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,25 @@ export DISPLAY="0:0"
2525

2626
for pid in $(pgrep -u $USER dbus-daemon); do
2727
env="/proc/${pid}/environ"
28-
dbus=$(grep -z DBUS_SESSION_BUS_ADDRESS $env | cut -d ':' -f 2 | tr -d '\0')
29-
if [ -n "${dbus##^unix:*}" ]; then
28+
dbus=$(grep -z DBUS_SESSION_BUS_ADDRESS $env | tr -d '\0' | \
29+
sed 's/DBUS_SESSION_BUS_ADDRESS=//g')
30+
if [ -n $dbus ]; then
3031
break
3132
fi
3233
done
3334

3435
if [ -z "$dbus" ]; then
3536
echo "No dbus-daemon process found."
36-
exit 1
37+
env=$(find "${HOME}/.dbus/session-bus/" -maxdepth 1 -type f)
38+
if [ -f "${env}" ]; then
39+
dbus=$(grep ^DBUS_SESSION_BUS_ADDRESS $env | sed 's/DBUS_SESSION_BUS_ADDRESS=//g')
40+
else
41+
echo "No session address file found in ${HOME}/.dbus/session-bus"
42+
exit 1
43+
fi
3744
fi
3845

39-
export DBUS_SESSION_BUS_ADDRESS="unix:${dbus}"
46+
export DBUS_SESSION_BUS_ADDRESS=$dbus
4047

4148
_udev_params=( "$@" )
4249
_bat_name="${_udev_params[0]}"

0 commit comments

Comments
 (0)