public inbox for cygwin-xfree@sourceware.org
help / color / mirror / Atom feed
From: Linda Walsh <cygwin@tlinx.org>
To: cygwin-xfree@cygwin.com
Subject: Re: remote xterm's can't open display after upgrade
Date: Sun, 14 Dec 2014 22:43:00 -0000 [thread overview]
Message-ID: <548E127D.6020705@tlinx.org> (raw)
In-Reply-To: <loom.20141212T201843-432@post.gmane.org>
JimE wrote:
>
> Hi Don,
> I'm in the same boat. I just upgraded cygwin and now I can't get remote xterms to
> display on the local machine.
----
Question -- Is your local machine on a closed net?
I.e. My windows machine is on a local subnet (example: 192.168.x.y)
that isn't
(usually) exposed to the internet.
1st thing to note, is that my win X server starts automatically
when I log into windows (well it usually does unless some "upgrade"[sic]
makes something incompat), BUT, less likely to have problems, as
I start the X-server via my *own* script in my homedir's "bin" dir.
I.e. the shortcut on my QuickLaunch Bar (yeah, running W7 and still
using that...)... has
Target: C:\bin\bash.exe -c '"%USERPROFILE%/bin/startxwin.sh"'
Startin: %HOMEDRIVE%%HOMEPATH%
---
my startxwin.sh is mostly free of non-cygwin deps, except
for a tray-message util, "notify" which lets me put up messages
if the server is already running and such.
----
I'll leave in the comments (mostly NOTES to self or
OLD code...)... but if you know shell script, shouldn't be
hard to modify to your use case.
Some things (like a "mount -c /") at the beginning
of the script have been added over the years to
increase robustness.
This script hasn't been "cleaned" for looking good
or best coding style, but given how often I need to
maintain or change it, I haven't been motivated.
It has disabled code that tried to start dbus, but
it didn't work reliably, so it's commented out.
Parts were rewritten to try to minimize use of non-shell,
external commands (minimize deps, efficiency).
Note 1: If you want to use this in an unsecure network,
then you need to start this through an "ssh" command to
the remote machine and not reset the DISPLAY...
Note 2: one thing this script does that the cygwin
script does not do -- it tries to read your display's
"DPI" and set the corresponding option in the X-display.
---------------------extra config file: (optional)
~/.mind/Xserver-dflt-overrrides----
+ac
---------------------bash script: startxwin.sh
#!/bin/bash
# (c) LA Walsh 2004-2014, licenced under GPLv2 and/or to nice people
#export DISPLAY=:0
#export XAPPLRESDIR=/usr/X11R6/lib/X11/app-defaults
#export XCMSDB=/usr/X11R6/lib/X11/Xcms.txt
#export XKEYSYMDB=/usr/X11R6/lib/X11/XKeysymDB
#export XNLSPATH=/usr/X11R6/lib/X11/locale
#unexport XAPPLRESDIR XCMSDB XKEYSYMDB XNLSPATH
# see cygwin Xwin for more option examples
# relevant ops:
# -multiwindow = use windows manage; not w/(-rootless|-fullscreen)
# -clipboard = use built-in version (integrated w/windows)
# -unixkill = Enable Ctrl-Alt-BS as X-server shutdown cmnd
# -nowinkill = Disable Alt+F4 as a server shutdown key combination.
# -trayicon = (default) windows tray icon enabled
mount -c /
export PATH=/bin:$(/bin/cygpath "$USERPROFILE")/bin:$PATH #ensure our
bin is 1st
shopt -s expand_aliases extglob
alias notify=$(type -P notifu)
alias int=declare\ -i
alias sub=function
alias xset=$(type -P xset);
alias array=declare\ -a
alias my=declare
export DISPLAY="${DISPLAY:-":0"}"
sub xup {
local stat
read -t .1 stat <<<$(xset q >&/dev/null; echo $?) &&
return $stat
((-1))
}
sub Xwin_pids {
( cd /proc &&
for p in +([0-9])/ ;do
p2=${p%/}
prg=$(<${p2}/exename)
if [[ $prg =~ .*XWin ]]; then
printf "%d:%s\n" "$p2" "$prg"
fi
done
)
}
#sub Xwin_pid { echo $(/bin/ps -s|/bin/awk -- '/\?.*XWin/{print $1}') ; }
sub Xwin_pid {
array Xprgs
readarray Xprgs< <(Xwin_pids)
if ((!${#Xprgs[@]}));then
echo 0
return 1
fi
my x=${Xprgs[0]}
my pid=${x%%:**} prg=${x##*:}
array out=( "$pid" "$prg")
printf "%s " "${out[@]}"
printf "\n"
return 0
}
sub Xwin_running {
int pd; my pg
read pd pg < <(Xwin_pid)
return $(((!pd)))
}
export -f Xwin_pids Xwin_pid
#sub Xwin_pid { echo $(/bin/ps -s|/bin/awk -- '/\?.*XWin/{print $1}') ; }
#export -f Xwin_pid
#sub Xwin_running { [[ $(Xwin_pid) ]] ; }
#export TERM=15 KILL=9
sub tidy_old_Xwin {
local -a sigs=(TERM TERM KILL) # try 2 TERMs then KILL upto maxsigs
int pd; my pg
int maxsigs=3 lastsig=${#sigs[*]}
while ((1)); do
read pd pg < <(Xwin_pid)
((pd)) || break
#int i=--maxsigs>lastsig ? lastsig:maxsigs
kill -${sigs[--maxsigs>lastsig ? lastsig:maxsigs]} $pd
((maxsigs)) || break
sleep 1
done
rm -fr /tmp/.X11-unix
}
sub get_dpi {
dpi=$(regtool -d get '/HKLM/Software/Microsoft/Windows
NT/CurrentVersion/FontDPI/LogPixels')
# check for insane values
((dpi<50||dpi>>400)) && dpi=96
echo "$dpi"
}
sub get_fontpath {
local
fontpath="/usr/share/TTF,built-ins,/usr/share/fonts/misc,/usr/share/fonts/100dpi"
echo -n "$fontpath"
}
sub start_XWin {
local
fontpath="/usr/share/fonts/TTF,built-ins,/usr/share/fonts/misc,/usr/share/fonts/100dpi"
int dpi=$(get_dpi)
cmd="/bin/run /bin/XWin ${dpi:+-dpi $dpi}
-nomultimonitors -clipboard -ac -unixkill -nowinkill -wgl
-bs -fp "$fontpath" -multiwindow"
echo cmd="$cmd"
$cmd
}
declare -a default_switches=(-dpi -clipboard -unixkill -nowinkill -bs
-ac -fp -multiwindow -wgl)
readarray -t args< <(
a="$default_switches[@]"; IFS=$'\n'; echo "${a[*]#?}"|sort -k1.2 )
sub read_users_mind { #(reads file in lieu of HW support for actual)
if [[ -O ~/.mind && -O ~/.mind/Xserver-dflt-overrides ]]; then
readarray -t overrides < <( -x
<~/.mind/Xserver-dflt-overrides perl -wnE '
chomp; s/\s*(?:#.*)?$//; s/^\s*// s/\s\s+/\s/ ; $_ || next;
print $_."\n" ')
fi
typeset -a switches
}
sub start_dbus {
/bin/run /bin/dbus-launch --exit_with_session ~/.Xsession
}
sub _in {
local x=${1:?};shift
for ((;$#>0;)); do [[ $x == $1 ]] && return 0;shift; done
return 1
}
int tries=3
if Xwin_running && xup; then
notify /t info /m "Xserver already running and ready" /d 5000
else
echo Cannot contact X Server
tidy_old_Xwin
while ((1)); do
start_XWin $(read_users_mind)
sleep 1
for ((i=0;i<5;++i)); do
xup && break 2
sleep 1
done
if ((--tries<=0)); then
m="\aEXITING: Timeout Waiting for Xserver Startup!!"
echo "$m"
notify /t error /m "$m"
exit 1;
fi
done
#start_dbus || { m="\aError Starting Dbus"; echo "$m"; notify /t error
/m "$m"; }
fi
# vim: ts=2:sw=2
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ: http://x.cygwin.com/docs/faq/
prev parent reply other threads:[~2014-12-14 22:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-11 18:31 Don Webster
2014-12-11 19:14 ` Jon TURNEY
2014-12-11 21:16 ` Don Webster
2014-12-12 22:03 ` J. Offerman
2014-12-12 19:55 ` JimE
2014-12-14 22:43 ` Linda Walsh [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=548E127D.6020705@tlinx.org \
--to=cygwin@tlinx.org \
--cc=cygwin-xfree@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).