bin bash function getenv local pid local ename cat proc pid environ se

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash
function getenv {
local pid=$1
local ename=$2
cat /proc/$pid/environ | sed 's,\x00,\n,g' | grep ^$ename | sed "s,^${ename}=,,"
}
for pid in $(ps -o user,pid -C xfce4-session | awk "\$1 == \"$USER\" { print \$2};"); do
env \
DBUS_SESSION_BUS_ADDRESS=$(getenv $pid DBUS_STARTER_ADDRESS) \
DISPLAY=$(getenv $pid DISPLAY) \
notify-send "$@"
done
# vim:set tabstop=4 softtabstop=4 shiftwidth=4:
# vim:set foldmethod=marker foldlevel=32 foldmarker={,}: