Как запретить Cygwin XWin Server автоматически запускать xterm?

9149
me_and

Всякий раз, когда я запускаю X-сервер Cygwin с помощью ссылки «XWin Server» в моем меню «Пуск» или при запуске startxwinиз оболочки Cygwin, автоматически появляется окно xterm, которое мне ни нужно, ни нужно.

Как мне избежать этого?

(Вопрос вдохновлен этот комментарий по Стейн Vanpoucke над на переполнение стека)

12

4 ответа на вопрос

17
me_and

ОБНОВЛЕНИЕ : Этот ответ устарел. Для получения актуального ответа см . Ответ пользователя 551570 ниже .

От man startxwin:

Если в командной строке не указана конкретная клиентская программа, startxwinв домашнем каталоге пользователя будет найден файл, который будет .startxwinrcзапускаться как сценарий оболочки для запуска клиентских программ. Если такого файла не существует, startxwinпо умолчанию будет использоваться следующее:

xterm -geometry +1+1 -n login -display :0 

Таким образом, чтобы избежать запуска какой-либо программы при запуске X-сервера, вам нужен пустой .startxwinrcфайл. Просто запустите следующую команду Cygwin:

touch ~/.startxwinrc 
Это решение было хорошо долгое время, но теперь с последним обновлением его нет. Использование пустого `.startxwinrc` приводит к немедленному исчезновению X-сервера. :-( Notinlist 9 лет назад 1
@ Notinlist Так оно и есть. Это немного грустно. Я постараюсь исследовать и найти новое решение; кажется, что система сейчас несколько сложнее, и я не могу понять, как она должна работать ... me_and 9 лет назад 1
5
user551570

It seems that startxwin's behavior has changed since @me_and originally answered the question, so simply creating an empty .startxwinrc in your home directory won't work anymore.

I found an answer here. In essence when the last command in .startxwinrc exits, the server will exit. If you want to prevent that, you can put this as the last line in your .startxwinrc:

sleep inf 

This won't start any client programs, but will also prevent .startxwinrc from exiting.

По какой-то причине это не работает для меня. Мне пришлось ввести: `exec sleep infinity`, как показано здесь: http://x.cygwin.com/docs/faq/cygwin-x-faq.html#q-startxwinrc-exit enricoferrero 8 лет назад 1
3
Ethan T

As of November 2014, the latest versions of startxwin use xinit to start the Cygwin/X server, which is actually called XWin.exe. The process goes something like this:

  1. You call startxwin
  2. startxwin creates a new .Xauthority file and one called .serverauth.1234 (where 1234 changes each time you start X)
  3. startxwin sets up some client and server parameters
  4. startxwin calls xinit with the client and server parameters, including some optional shell scripts and a reference to the auth file.
  5. xinit starts the X server, running some of the rc scripts
  6. xinit starts the client (usually xterm) or client rc script. We want to avoid this
  7. When you close the client or the client rc script finishes, xinit shuts down the X server. If we avoid step 6, we also need to avoid this

It is possible to run XWin.exe directly from within a Bash login shell, without the surrounding tasks that startxwin and xinit perform. The main advantage of this is that it behaves like we want: the X server starts and remains running. Unfortunately, since there is no .Xauthority file passed during startup, your X server would permit any local process to connect to it, which is insecure.

Fortunately it's xinit that does most of the stuff we don't want. There's a quick hack that bypasses xinit but keeps the remaining elements of startxwin that are related to the server itself.

TL;DR: In startxwin, there's a line near the bottom that reads:

eval xinit \"$client\" $clientargs -- \"$server\" $display $serverargs 

Change that line to:

eval \"$server\" $display $serverargs 

From now on, the startxwin script will call XWin.exe directly, rather than calling xinit. Obviously this will disable any client rc scripts, but we didn't want those in the first place. It also means that X will continue running without needing a client process to keep it alive (i.e. keep xinit from killing it).

0
SilversleevesX

Я сделал привычку запускать Cygwin X с помощью startxwin (.exe). Мой файл .startxwinrc выглядит следующим образом:

X :0 -rootless mrxvt -geometry +1+1 -n login -display :0 -tt ImTabbed 

Пока это работает. Единственная ошибка, которую я получаю, касается отображения, все еще «открытого» другим X-процессом. Эта ошибка указывает определенный файл, который X-сервер генерирует по умолчанию для каждого сеанса. Люди Cygwin знают, что он не удаляется после завершения сеанса.

Поэтому я написал псевдоним, чтобы "вылечить", что:

alias freex='rm /tmp/.X0-lock' 

Я помещаю ту же самую строку - часть между кавычками, во всяком случае - в мои файлы .bashrc и .bash_profile на случай, если я забуду сделать это сам.

НТН.

BZT

Это не совсем ответ на этот вопрос; с перепиской это могло бы быть, но я думаю, что это будет лучше подходить как отдельный вопрос и ответ (как я сделал здесь) об обработке ошибки, которую вы видите. Затем вы можете дать ссылку на этот вопрос в комментариях к этому. me_and 11 лет назад 0