Open sunjoong opened 7 years ago
awesome, maybe we should use github wiki with links in README?
@mpkh - good. sure.
Two days aga, I had modified runemacs.exe originally from emacs package. With that and ~/.bash_profile trick, I could run emacs by mouse, so good. But, what if other program like xterm?
I wrote a vbscript code for more general purpose.
It check and run VcXsrv Windows X Server and set DISPLAY environment variable, so ~/.bash_profile trick does not be needed.
Make a shortcut of this code with attribute target like this;
XRun.vbs emacs
XRun.vbs is this code and emacs is for running. If you want to run xterm, do like this;
XRun.vbs xterm
Code of XRun.vbs is;
Option Explicit
Dim Object
Dim Args
Dim i
Const VcXsrv = "C:\Program Files\VcXsrv\vcxsrv.exe"
Args = ":0 -multiwindow -clipboard -wgl"
Set Object = GetObject ("winmgmts:")
for each i in Object.InstancesOf ("Win32_Process")
if StrComp (i.ExecutablePath, VcXsrv, 1) = 0 then
Args = ""
exit for
end if
next
Set i = Nothing
Set Object = Nothing
Set Object = CreateObject ("Shell.Application")
if StrComp (Args, "") then
Object.ShellExecute VcXsrv, Args, "", "open", 0
end if
Args = "~ -c 'export DISPLAY=:0;"
for i = 0 to WScript.Arguments.Count -1
Args = Args & " " & WScript.Arguments (i)
next
Args = Args & "'&"
Object.ShellExecute "bash.exe", Args, "", "open", 0
Set Object = Nothing
WScript.Quit
Today, I found it cannot launch browse-url-edge elisp function with above XRun.vbs code. I modified runemacs.c again not to need ~/.bash_profile trick. New runemacs.exe check and launch VcXsrv Windows X Server, and then launch emacs
with DISPLAY=:0
by itself.
New source code is runemacsWSL.zip, and new pre-compiled binary is runemacs.zip.
USE flags for emacs
Emacs works well unless using gtk3 and dbus. I have no idea why gtk3 making problem but it is. So, it's my woking USE flags;
bash.exe shortcut
There is a shortcut of bash.exe named "Bash on Ubuntu on Windows" in your Start Menu like "C:\Users\sunjoong\AppData\Roaming\Microsoft\Windows\Start Menu\Programs" directory. You know, sunjoong is my user name, so do with your username in your case. Change the shortcut name to "Bash on Gentoo on Windows" for looking good.
The target attribute of that shortcut isC:\Windows\System32\bash.exe \~Append "-l" option like this;C:\Windows\System32\bash.exe \~ -lThen, \~/.bash_profile file will work.UPDATE: I heard bash.exe will launch bash login shell starting 16184, https://github.com/Microsoft/BashOnWindows/issues/2067#issuecomment-299619151 ; so you might not need to append
-l
option after then.\~/.bash_profileThis is my \~/.bash_profile;SUNJOONG-DESKTOP \~ # cat \~/.bash_profile# This file is sourced by bash for login shells. The following line# runs your .bashrc and is recommended by the bash info pages.if [[ -f \~/.bashrc ]] ; then. \~/.bashrcfi/mnt/c/Windows/System32/tasklist.exe /fi 'imagename eq vcxsrv.exe' \2> /dev/null \| grep 'No tasks are running' > /dev/nullif [ $? -eq 0 ]; then/mnt/c/Program\ Files/VcXsrv/vcxsrv.exe \:0 -multiwindow -clipboard -wgl &> /dev/null &disownfiexport DISPLAY=:0SUNJOONG-DESKTOP \~ #I had installed VcXsrv Windows X Server.My \~/.bash_profile check whether X server be running and run X server if not running.runemacs.exeI'm using a modified runnig emacs wrapper. This is a source - runemacsWSL.zip.This is a compiled binary - runemacs.zip. It acts like "bash.exe -l -c emacs".So, I can run emacs by mouse double-clicking with this wrapper and \~/.bash_profile.UPDATE: https://github.com/Cynede/gentoo-wsl/issues/3#issuecomment-296996400UPDATE: https://github.com/Cynede/gentoo-wsl/issues/3#issuecomment-299623300Microsoft Edge as emacs browse-url-browser-function
This is a part of my emacs init file;
You could notice browse-url-edge function and browse-url-browser-function . That makes set external web brower to Microsoft Edge. The inhibit-startup-screen and default-directory make emacs looking other windows program. You know, sunjoong is my user name, so do with your username in your case.