summaryrefslogtreecommitdiff
path: root/ar/.local/bin/tmuxdbussync
blob: d6da8725257cda4674f32f821096be04e7c0eb0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/sh

fcitx5_pid=$(pgrep -f fcitx5 | head -n1)

if [ -z "$fcitx5_pid" ]; then
  echo "echo 'No terminal process found matching: fcitx5' >&2"
  exit 1
fi

fcitx5_dbus=$(tr '\0' '\n' </proc/"$fcitx5_pid"/environ | grep DBUS_SESSION_BUS_ADDRESS)
fcitx5_dbus="${fcitx5_dbus#DBUS_SESSION_BUS_ADDRESS=}"

if [ "$DBUS_SESSION_BUS_ADDRESS" != "$fcitx5_dbus" ]; then
  echo "export DBUS_SESSION_BUS_ADDRESS=$fcitx5_dbus"
fi