On Thu, Feb 16, 2012 at 21:25, cpforum <cpfo...@orange.fr> wrote: > Hi > > When system admin su to root and launch X 11 utilities (for exemple > system-config-printer) or java application (for exemple OpenOffice ./setup) > they get something like that : > > # xterm > xterm Xt error: Can't open display: %s > xterm: DISPLAY is not set > > or less friendly > > # system-config-printer > /usr/lib/python2.6/vendor-packages/gtk-2.0/gtk/__init__.py:57: GtkWarning: > could not open display > warnings.warn(str(e), _gtk.Warning) > /usr/lib/system-config-printer/system-config-printer.py:100: GtkWarning: file > gdkcursor-x11.c: line 262: assertion `GDK_IS_DISPLAY (display)' failed > busy_cursor = gtk.gdk.Cursor(gtk.gdk.WATCH) > Traceback (most recent call last): > File "/usr/lib/system-config-printer/system-config-printer.py", line 100, in > busy_cursor = gtk.gdk.Cursor(gtk.gdk.WATCH) > RuntimeError: could not create GdkCursor object > > One way to export DISPLAY to root (or others users) is to declare the > following function inside the user .profile
you could also do "ssh -X root@localhost" - it's a bit more to type though ;-) cheers Michael > > unset su > function su > { > if (( $# > 2 )) || [[ -z $DISPLAY ]] > then > print "Running /usr/bin/su" > /usr/bin/su $@ > else > print "Running su exporting DISPLAY to root" > XDISPLAY="$(uname -n)/unix:${DISPLAY#*:}" > /usr/bin/su - ${2-root} -c "DISPLAY=${DISPLAY} ${SHELL} -c \ > \"(/usr/bin/xauth -f $XAUTHORITY nextract - ${XDISPLAY} | \ > /usr/bin/xauth nmerge - ; ${SHELL})\"" > fi > } > > The problem with this method is that you have to add theses line for every > host (this method is not portable and a bit different with Solaris 10 and > works only with bash and ksh). > > So improvement to put a code doing the job inside su.c (with or without an -X > option) makes Openindiana more friendly for system admin. > > > > _______________________________________________ > OpenIndiana-discuss mailing list > OpenIndiana-discuss@openindiana.org > http://openindiana.org/mailman/listinfo/openindiana-discuss -- Michael Schuster http://recursiveramblings.wordpress.com/ _______________________________________________ OpenIndiana-discuss mailing list OpenIndiana-discuss@openindiana.org http://openindiana.org/mailman/listinfo/openindiana-discuss