3 # source up this script to setup new DISPLAY
4 # environent in the current session
6 _xdpy_attach_find_display
()
8 declare -A confirm_xdpy_pid
11 for signal
in INT QUIT TERM
13 trap "kill -SIG$signal -- \${!confirm_xdpy_pid[@]} 2>/dev/null" $signal
15 trap "kill -SIGINT -- \${!confirm_xdpy_pid[@]} 2>/dev/null" EXIT
19 echo "Found Display - $dpy" >&2
20 DISPLAY
=$dpy zenity
--question --text="Is this the right Display?\n$dpy" </dev
/null
>/dev
/null
2>&1 &
21 confirm_xdpy_pid
[$
!]=$dpy
26 echo "Waiting for user to response ..." >&2
28 while [ ${#confirm_xdpy_pid[@]} -gt 0 ]
30 for check_pid
in "${!confirm_xdpy_pid[@]}"
32 if ! kill -0 "$check_pid" 2>/dev
/null
34 local dpy
=${confirm_xdpy_pid[$check_pid]}
35 unset confirm_xdpy_pid
[$check_pid]
45 # Ctrl-C is most likely got by sleep, if so, exit from the loop.
50 kill -SIGINT -- ${!confirm_xdpy_pid[@]} 2>/dev
/null
51 unset confirm_xdpy_pid
56 if _xdpy_attach_is_shell_source
64 _xdpy_attach_is_shell_source
()
66 [ "$0" != "$BASH_SOURCE" ]
69 _xdpy_attach_screen_setenv
()
73 echo "Setting Gnu/Screen env $1" >&2
74 screen
-S "$STY" -X setenv
"$1" "$2"
79 echo "current DISPLAY=$DISPLAY" >&2
80 dpy
=`_xdpy_attach_find_display`
83 echo "Setting DISPLAY to '$dpy'" >&2
84 _xdpy_attach_apply DISPLAY
"$dpy"
86 _xdpy_attach_screen_setenv DISPLAY
"$dpy"
88 dbus
=`DISPLAY="$dpy" xprop -root DBUS_SESSION_BUS_ADDRESS | cut -s -f2- -d= | cut -f2 -d'"'`
92 echo "Setting DBUS_SESSION_BUS_ADDRESS to '$dbus'" >&2
93 _xdpy_attach_apply DBUS_SESSION_BUS_ADDRESS
"$dbus"
95 _xdpy_attach_screen_setenv DBUS_SESSION_BUS_ADDRESS
"$dbus"
100 env DISPLAY
="$dpy" ${dbus:+DBUS_SESSION_BUS_ADDRESS="$dbus"} "$@"