Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » VBS starting script for latest silly Xwin (cygwin)

This thread is locked; no one can reply to it. rss feed Print
VBS starting script for latest silly Xwin (cygwin)
GullRaDriel
Member #3,861
September 2003
avatar

Hi there.

I just though I had to share that basic script I made.

As you may or not be aware, latest cygwin installs are pestifered and scripts starting Xwin server always leave a blank windows in the taskbar.

Xterm shortcut may not work anymore with dual card settings.

Warning, I'm no big VBS user so that script code may not be the best.

So, here is the vbs:

#SelectExpand
1' Stupid Cygwin Xserver launcher 2' by Castagnier Mickal 3' 17/02/2014 4 5Dim cygwin_primary 6Dim cygwin_secondary 7Set objShell = CreateObject("WScript.Shell") 8 9' Path for x64 or x86 in order of preference 10cygwin_primary = "C:\cygwin\bin\run.exe" 11cygwin_secondary = "C:\cygwin64\bin\run.exe" 12 13' 14' cygwin run version check 15' 16Dim cygrunner 17cygrunner = "NO_CYGWIN_RUN_EXECUTABLE" 18Set fso = CreateObject("Scripting.FileSystemObject") 19 20If( fso.FileExists( cygwin_secondary ) )Then 21 cygrunner = cygwin_secondary 22End If 23 24 25If( fso.FileExists( cygwin_primary ) )Then 26 cygrunner = cygwin_primary 27End If 28 29' Error check and display 30If( StrComp( cygrunner ,"NO_CYGWIN_RUN_EXECUTABLE" ) = 0 )Then 31 MsgBox "NO_CYGWIN_RUN_EXECUTABLE in "& cygwin_primary & " or " & cygwin_secondary 32 Wscript.quit 1 33End If 34 35'Start Xwin with cygrunner 36objShell.Run( cygrunner & " /usr/bin/bash.exe -l -c /usr/bin/startxwin" ) , 0 37Wscript.quit 0

I named it startx.vbs and put it in cygwin-X directory in the start menu.

For fixing the Xterm shortcut, I had to change the DISPLAY to :0 instead of 127.0.0.1:0
I may also have added 'export DISPLAY=IP:0' to my bach profile.

And if Xwin does not keep launched, it's because of an empty startxwinrc or an exiting startxwinrc.

Here is mine:
cat .startxwinrc
#!/bin/sh
xrdb -merge ~/.Xresources
export DISPLAY=:0
sleep infinity

Xressource is used to customize the terminal. Hence the call to xrdb inside the startx script.

My Xressource, if ever needed by anyone:

cat .Xresources
Xft*antialias: true
Xft*autohint: true
XTerm*background: black
XTerm*foreground: grey
XTerm*cursorColor: grey
XTerm.vt100.geometry: 79x25
XTerm*scrollBar: true
XTerm*rightScrollBar: true
XTerm*saveLines: 10000
XTerm*faceName: BitStream Vera Sans Mono
XTerm*faceSize: 12
XTerm*toolBar: off

Hope it helps !

Cheers !

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

bamccaig
Member #7,536
July 2006
avatar

It is 2015. I know, I know, I did it too. Imagine my surprise when I arrived in to work today (Tuesday) after the holiday yesterday and realized a SQL SELECT that I had on screen from Friday that wasn't working was asking for ... WHERE ... BETWEEN ... using February 2014 to fetch logs for recently added functionality... :-[ Damn year changes.

As a reluctant ASP/VBScript (not necessarily the same as WScripting...) programmer I'd suggest getting rid of the NO_CYGWIN_RUN_EXECUTABLE string and comparison and just check if cygrunner is Null. It should be something like IsNull(cygrunner) if the dialects are compatible. Saves you a bit of complexity. Otherwise, it's fine, as we all know nobody uses VBS by choice...

Consider putting it into a GitHub repository so both you'll remember it and other people can maybe find it... I have cmd-su that was once useful for me to launch things from a command prompt as Administrative user in Windows 7 (which IIRC prompts using UAC automatically).

Edit: s/Nothing/Null/ ... Nothing is a special kind of null for objects, but that has to be Set explicitly... By default I think the value should be Null... (It has thankfully been a while...).

GullRaDriel
Member #3,861
September 2003
avatar

My, I didn't even noticed that I dated it badly.
I'm fixing that in my local version, as well as the string thing.
Thanks Bam !

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Go to: