mirror of
https://github.com/cascadium/wsl-windows-toolbar-launcher.git
synced 2026-04-26 13:05:53 +03:00
[GH-ISSUE #18] I can run Linux GUI applications via terminal, but can't run via wsl-windows-toolbar. #17
Labels
No labels
duplicate
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/wsl-windows-toolbar-launcher#17
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @haosmos on GitHub (Aug 21, 2020).
Original GitHub issue: https://github.com/cascadium/wsl-windows-toolbar-launcher/issues/18
My environment:
Windows 10
OS version: 2004
OS build: 20190.1000 (insider preview "dev")
WSL: Ubuntu-20.04.1
Linux kernel: 4.19.121
X-server: VcXsrv
Ubuntu desktop environment: KDE plasma
Can you tell me, please, why Linux applications don't run via wsl-toolbar, but they run through a terminal?
For reasons I don't understand, I can't run Linux GUI applications with the DISPLAY variable defined in the recommended way:
export DISPLAY=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'):0.0.Instead of this command, I use the IPv4 address: 192.168.0.107 as the value of the DISPLAY variable.
I found this value of the DISPLAY variable by a random choice method and the applications started to run.
In my .zshrc file I put the following lines of code — as recommended in the already closed question: https://github.com/cascadium/wsl-windows-toolbar-launcher/issues/4:
Still, applications are not launched via wsl-toolbar.
I can run Linux GUI applications through the terminal, but can't via wsl-windows-toolbar.
Tell me, please, what other information do I need to give you so that you can determine what I did wrong?
@fquinner commented on GitHub (Aug 22, 2020):
Hi there! The script uses bash by default so you can either put the variable in your bash profile or else use an alternative
-Jtemplate which uses zsh instead (the one that the script uses is https://github.com/cascadium/wsl-windows-toolbar-launcher/blob/master/wsl-windows-toolbar-template.sh.j2 so you can copy and hack that for zsh shebang).If the DISPLAY variable doesn't work with the recommended command there is probably a firewall rule preventing it. These installers on windows tend to sneak in a block rule for "public" networks which (idiotically) the wsl network falls under. This block rule will take precedence over any allow rule you may have created. There's some info on the README for the sort of things to check for there.
I tend to prefer not to use public or private "real" IPs at all since that opens up your x11 port to anyone else who happens to be on your network, but that's a matter of personal preference.
@haosmos commented on GitHub (Aug 22, 2020):
Hi, @fquinner! Thank you for your recommendations!
— sorry, I didn't quite understand you — you recommend placing this code:
in my ".bash_profile" file? Or in my ".bashrc" file?
— I would gladly try to do what you recommend, only I do not understand what you are talking about at all))😜 This is because I am not good at linux)).
If it's not difficult for you, please explain in more detail)
— I wouldn't want to use public or private "real" Is too, but I don't know how to do it))
But that's another question))
@fquinner commented on GitHub (Aug 22, 2020):
Hehe sorry when I saw zsh I assumed you were a pro with Linux since most default shells are bash. It depends on your distros setup but usually its .bashrc. When you open a new terminal in wsl and you run
echo $SHELL, what does it say?@haosmos commented on GitHub (Aug 22, 2020):
@haosmos commented on GitHub (Aug 22, 2020):
— I tried to put the code:
in .bashrc file.
But it didn't help either 😪
@fquinner commented on GitHub (Aug 23, 2020):
You could try adding:
To your
.bash_profileas well.I'm afk at the moment but when I get to a machine I can try and get the wsl command to help you troubleshoot exactly what's happening here - I wouldn't be sure off the top of my head.
@fquinner commented on GitHub (Aug 24, 2020):
If you run:
from a windows command prompt, then:
That should let you know whether or not
$DISPLAYgets set correctly for your bash environment (and if your .bashrc etc files get parsed) to help you figure out what's going on here.@haosmos commented on GitHub (Aug 24, 2020):
@fquinner, thank you!
When I executed the command:
From the windows command line, there was a welcome message from wsl, in other words, this command switched me to wsl.
And I had already executed the command from wsl:
echo $DISPLAYgives the following result:
192.168.0.107:0.0This happens if I specify it in my .zshrc file as a form:
export DISPLAY=192.168.0.107:0.0If I comment this command and specify the value of the variable $DISPLAY in the form:
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0The result will be this: the same welcome message from wsl will be output and I will also be switched to wsl from CMD (windows).
And the command echo $DISPLAY
gives the following result:
172.30.160.1:0.0This value coincides with the value of the wsl address (Ethernet vEthernet (WSL)) which shows PowerShell by the ipconfig command.
Interestingly, after that I can run a Linux GUI application through a terminal, but still not through a wsl-toolbar.
If I move this code:
from .zshrc to .bashrc (I disable this code in .zshrc with the comment "#"), I can still run Linux GUI applications.
But when I execute the command that you suggested:
wsl.exe -d Ubuntu-20.04 --exec bash -lI am again switched from cmd (windows) to wsl, but after that the value of $DISPLAY probably changes or I lose the ability to contact it or something else happens and I can no longer run Linux applications.
But when I activate the code again
in .zshrc and execute the command
wsl.exe -d Ubuntu-20.04 --exec bash -lthen I am switched from cmd (windows) to wsl again and the value of $DISPLAY again matches the value of Ethernet vEthernet (WSL) and I can run GUI Linux applications again.
I recorded a video showing all these steps: https://yadi.sk/i/haXrQJ1wMp4sKQ.
I don't know, maybe the reason is that I am trying to configure systemd in parallel. The first time I run wsl - systemd is activated (and I can run snapd and snap packages), but for some reason, it disables commands like "code" or "explorer.exe .
I've published a question in the corresponding topic and it's probably not related to my current wsl-toolbar problem. But who knows, maybe it has something to do with it. Because after running the command.
wsl.exe -d Ubuntu-20.04 --exec bash -lsystemd is activated and commands such as "code" or "explorer.exe ." are disabled. Here is a link to a short video (2m 30sec) of my problem with systemd https://yadi.sk/i/gRPIMDwaDqt6uw.
Oh my God, what a huge post and so many questions from me, sorry, please).
@fquinner commented on GitHub (Aug 24, 2020):
Hi @haosmos, Looking at the video, i see this in your
.bashrc:Which will get bash to run zsh again etc - you should take everything from line 10-15 inclusive in
.bashrcout because that won't help your case.I think the best .bashrc you could have at the moment is one which has some debug statements inside like:
That way you can be confident that the right file is getting sourced.
That
wsl.exe -d Ubuntu-20.04 --exec bash -lcommand is key because that is pretty much what the toolbar does - that's a standard login shell for a fresh bash session. If DISPLAY is not set in that environment (as it didn't seem to be in your video), it won't work, so best bet is to troubleshoot that as above first.@haosmos commented on GitHub (Aug 24, 2020):
I'm not sure I understood you correctly, but this is what I did:
I put this code:
in the .bashrc file and commented ("#") on these lines in the .bashrc file:
As I understood it, to disable switching to the zch shell.
After that I executed the command from CMD:
wsl.exe -d Ubuntu-20.04 --exec bash -lThe value of $DISPLAY was printed the same as that shown by powershell - 172.23.48.1:0.0.
Linux applications run from a terminal but not from wsl-toolbar.
And for some reason shell switched back to zch:
😞😕
@fquinner commented on GitHub (Aug 25, 2020):
Hmm there must be something on down which is switching you back to .bashrc. My point was more when you run this command, does "Yes I am getting parsed :)" get printed to make sure you're getting that far.
Maybe we should just embrace it and lean into zsh (which is what i meant originally but I'm at a computer now :))
--rc-file ~/.zshrcto your toolbar launcher script command (though that launches within bash so could cause issues, but is the least invasive option)--jinja-template-shell /path/to/template.j2wheretemplate.j2is a file with these contents:@haosmos commented on GitHub (Aug 26, 2020):
Thank you, @fquinner!
Excuse me, but I'm not sure what exactly I need to do: do I need to put this code in my .zshrc file, or do I need to execute this code in a terminal?
@fquinner commented on GitHub (Aug 26, 2020):
It's a case of either doing point 1. or point 2.
Point 1 on its own may work (simply passing
--rc-file ~/.zshrcto the wsl toolbar launcher script)If not, you can try point 2 which involves creating a file accessible from wsl with the contents listed above and passing the path to that file into the script as a command line argument to the wsl toolbar launcher script
--jinja-template-shell /path/to/template.j2@haosmos commented on GitHub (Aug 26, 2020):
— When I execute this code in a terminal (wsl), I get an error:
Or did I misunderstand you and need to do something else in Point 1?
@fquinner commented on GitHub (Aug 26, 2020):
Its an argument to the script which generates the menu. E.g.
wsl-windows-toolbar --rc-file ~/.zshrc@haosmos commented on GitHub (Aug 26, 2020):
— After executing the command, the following result was displayed in the console:
Is it good or bad? 🤔
@fquinner commented on GitHub (Aug 26, 2020):
Hit enter and let fly
@haosmos commented on GitHub (Aug 26, 2020):
I pressed "Enter" and the process of creating the menu began.
I created a new menu and ... applications from wsl-toolbar do not run again with the VcXsrv server running 😭
@haosmos commented on GitHub (Aug 26, 2020):
Something strange: I can run the ranger and htop applications via the wsl-toolbar - but no other applications.
https://yadi.sk/i/94ML6-YkfWd9dw
@fquinner commented on GitHub (Aug 26, 2020):
Yeah that's expected they run in a terminal so they don't use X11. Guess its time to run the script again with option number 2...
@haosmos commented on GitHub (Aug 26, 2020):
— I cannot find this file: I am using fzf to search and it cannot find this file.
Maybe the reason is that when installing wsl-toolbar, the following message was displayed:
🤔
@fquinner commented on GitHub (Aug 26, 2020):
You need to create it as I mentioned above with those contents and pass it to the script on the command line
@haosmos commented on GitHub (Aug 26, 2020):
— If the shell shows that the command cannot be executed, then I need to download this utility - https://pypi.org/project/j2cli/?
@fquinner commented on GitHub (Aug 26, 2020):
You haven't passed it to the script... its wsl-windows-toolbar with that argument after. The script will parse the template you don't need j2cli.
@haosmos commented on GitHub (Aug 26, 2020):
— I did:
wsl-windows-toolbar -J /home/haosmos/template.j2After that, the menu creation process was started again and after creating the toolbar, the applications are not started again.
There is probably something wrong with the wsl, which prevents your script from being installed and working properly.
I think it's better if I stop torturing you with my dilettantish questions. Please forgive me for taking up a lot of your time.
Thank you for your help, anyway!