Giter VIP home page Giter VIP logo

wsl-windows-toolbar-launcher's Introduction

WSL Windows Toolbar Launcher

For Windows 11 Users, you probably don't need / want this project

Unfortunately (or fortunately depending on your opinion - keep reading...) this script is of questionable value in Windows 11 since they neutered the taskbar (generally). I did test when the windows 10 insiders build had full wslg support and everything worked fine, but the windows 11 taskbar is now unrecognizable from that build and there is currently no way to add the toolbar in the way which this project expects.

However as of Windows 11, this script is not actually required. If you run powertoys, you can enable Powertoys Run and use alt+space. Your GUI apps from your WSL installs will have shortcuts there with your distribution name in brackets as you launch them and you won't need to go looking for them in the traditional tree-based structure. Thanks to the new Windows 11 WSLG support, it should "just work" without any display magic or third party X11 servers.

Note you may wait for the Windows indexer to refresh after you install a new app, but it will get there eventually automatically.

For Windows 10 Users

This script will create a Windows toolbar launcher for an underlying WSL install which can be used to fire up linux native applications directly from Windows via the standard Windows toolbar, like this:

Demo

It's particularly cool because WSL 2 is coming which is unlocking unprecedented performance and compatibility improvements, so this will literally bring the full suite of Linux GUI applications directly to Windows UI.

Prerequisites

The script expects to be run within the WSL execution environment with:

  • A complete WSL install ready with bash, python3 and python3-pip installed.
  • An X11 Server running on your windows host (e.g. X410, Xming etc). This server must be reachable from your WSL env (test with something like wsl.exe -- source ~/.bashrc ; xterm). If this fails, check your DISPLAY variable (more details in troubleshooting).
  • A freedesktop menu installed (e.g. gnome-menus or a full desktop environment).

And optionally (but recommended):

  • An installation of cairosvg if works on your distro (pip3 install cairosvg). This will allow you to convert .svg based icons.
  • Imagemagick installed (sudo apt install imagemagick / dnf install imagemagick etc). This will allow you to have an additional opportunity to convert appropriate icon files if other methods fail.

Installing and Running

To install:

pip3 install wsl-windows-toolbar

To run:

wsl-windows-toolbar

After installation, right click on your toolbar, go to Toolbars -> New toolbar... and select %USERPROFILE%\.config\wsl-windows-toolbar-launcher\menus\WSL as the target folder (unless you selected an alternative directory).

Note there are many options available with --help if you'd prefer to use alternative locations.

Updating

If new software has been installed in the WSL environment, simply run the script again from the WSL environment to pick the new GUIs up.

Notable changes:

  • Change in 0.3: Command is now wsl-windows-toolbar without the trailing .py.

Advanced Usage / Options

$ python wsl-windows-toolbar.py  --help
Usage: wsl_windows_toolbar.py [OPTIONS]

Options:
  -i, --install-directory PATH    Install the launchers here [default:
                                  /c/Users/$USER/.config/wsl-windows-toolbar-
                                  launcher/metadata]
  -m, --metadata-directory PATH   Install any metadata here [default:
                                  /c/Users/$USER/.config/wsl-windows-toolbar-
                                  launcher/metadata]
  -d, --distribution TEXT         WSL Distro to generate shortcuts for
                                  [default: $WSL_DISTRO_NAME]
  -u, --user TEXT                 WSL Distro's user to launch programs as
                                  [default: $USER]
  -y, --confirm-yes               Assume the answer to all confirmation
                                  prompts is 'yes'  [default: False]
  -f, --menu-file FILENAME        The *.menu menu file to parse  [default:
                                  /etc/xdg/menus/gnome-applications.menu]
  -w, --wsl-executable TEXT       Path to the WSL executable relative to the
                                  windows installation  [default:
                                  C:\Windows\System32\wsl.exe]
  -n, --target-name TEXT          Name to give to the created installation
                                  (will be displayed in toolbar menu)
                                  [default: WSL]
  -t, --preferred-theme TEXT      Preferred menu theme to use  [default:
                                  Adwaita]
  -T, --alternative-theme TEXT    Alternative menu themes to consider (pass
                                  multiple times)  [default: Papirus,
                                  Humanity, elementary-xfce]
  -j, --jinja-template-batch FILENAME
                                  Optional Jinja template to use instead of
                                  the inbuilt default (advanced users only)
  -J, --jinja-template-shell FILENAME
                                  Optional Jinja template to use instead of
                                  the inbuilt default (advanced users only)
  -r, --rc-file FILENAME          Optional rc file to source prior to
                                  launching the command instead of ~/.bashrc
  -D, --launch-directory DIRECTORY
                                  Optional default linux path to open
                                  applications relative to (defaults to ~)
  --help                          Show this message and exit.

Advanced Launcher Behaviour

The launcher process is fairly broken down to separate responsibilities and allow customizations at several layers. It looks like this:

lnk -> vbscript (sometimes) -> bat -> wsl bash -> app

The .lnk is the shortcut with the icon etc. The vbscript exists only to launch the batch file without a terminal window appearing. The batch file bootstraps the wsl bash script using wsl.exe which in turn (finally) launches the app. It may seem convoluted but I have found this is the easiest way to break it down to allow flexibility and ease of maintenance at each layer.

Note the vbscript is only called if run_in_terminal is set to false (as it tends to be for most applications). The templates which define the batch and bash files are used may be overridden by -j and -J respectively, though you shouldn't usually need to override this behaviour.

The default templates used are wsl-windows-toolbar-template.bat.j2 and wsl-windows-toolbar-template.sh.j2. The following possible variables passed through from the script:

  • distribution: The distribution selected in the script
  • user: The user selected in the script
  • command: The individual command for each launcher entry in WSL environment (e.g. xterm)
  • wsl: The wsl executable discovered
  • rcfile: The rc file (e.g. .bashrc) to source prior to launch selected in the script
  • launch_script: The path of the linux launcher script
  • exec_dir: The directory in which this command will be run (linux path)
  • run_in_terminal: Boolean specifying whether or not this app expects to run in a terminal

Troubleshooting

No applications launching

If no applications are launching at all, it's most likely an issue with either:

  • DISPLAY not being set correctly
  • DISPLAY being set fine, but its destination is not accessible from the WSL environment
  • The X11 server isn't set up to allow access from external hosts (how to configure this will depend on your X11 server so please refer to their documentation)

Note that for this section, you can check which version of WSL you're using with:

wsl.exe -l --verbose

Check WSL1 $DISPLAY variable

If you're running WSL1, the DISPLAY variable for WSL1 should simply be localhost:0.0 if this is the default distribution.

Check WSL2 $DISPLAY variable

Unfortunately for WSL2, it's a little more complicated for now, though I think they're planning on fixing this. You'll need something like this to extract the correct host:

export DISPLAY=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'):0.0

Firewall Rules

Then you need to worry about the firewall. WSL comes up as a public network, but I wouldn't recommend allowing all public network traffic to access your X server. So instead, you can go ahead and select defaults when this sort of prompt comes up:

Security Alert

Now, irritatingly this will actively add a block rule (rather than simply not add an allow rule) for public networks which you will need to disable for the next step by going into Windows Defender Firewall -> Inbound Rules and disabling this block rule for TCP on the Public Network.

If you don't do the above step, the Block rule will take precedence over the Allow allow rule and you won't get through.

Now, right click on Inbound Rules and select New Rule..., select TCP port 6000 (most likely, but verify with display number / X11 server documentation before continuing) and select defaults. This will open up your public network for this port... which is also not what you want. What you want is to only allow traffic from the WSL subnet. So refresh the list, scroll to your recently created name, right click and go to properties. Now under Scope, go to Remote IP address, Select These IP addresses and add in 172.16.0.0/12 to limit the subnets which can access this port to the WSL subnet. It should look something like this:

WSL Subnet Firewall Rule

Alternatively you could just disable the entire firewall for WSL, but that adds a firewall warning that constantly irritates me:

powershell.exe -Command "Set-NetFirewallProfile -DisabledInterfaceAliases \"vEthernet (WSL)\""

Application X not working

Does the application use dbus? If so, it's recommended to put something like this in your .bashrc to satisfy the many applications which depend on dbus to function:

dbus_status=$(service dbus status)
if [[ $dbus_status = *"is not running"* ]]; then
  sudo service dbus --full-restart
fi

Also check that the .bashrc tweaks are added before any nastiness like this in your .bashrc which would prevent DISPLAY from being set:

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

You can do similar with docker or any other service which you will need access to, but won't necessarily already be running in a vanilla WSL installation.

To debug further, you can run the shortcut directly from the command line from a cmd shell:

wsl.exe -d <your-wsl-distro> -u <your-wsl-user> -- source ~/.bashrc ; env; xterm

Replacing xterm with whatever command you're trying to launch. Note the env command will print out all environment variables set before running xterm in this example, so this should help you double check if DISPLAY is really set correctly.

Raising Issues

Issues may be raised in github issues. Before raising an issue though:

  • Verify that you have an X Server running on windows 10. Popular options include X410 or Xming.
  • Verify that you can actually launch X applications from a WSL terminal (e.g. try running xterm).

If an issue is to be required, please prepare the log output from the command and details on your execution environment. Ideally try and find the .desktop file relating to the failing software as well.

wsl-windows-toolbar-launcher's People

Contributors

bachittle avatar dependabot[bot] avatar fquinner avatar jericson avatar judylovesruby avatar lanouettea avatar suikwasha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wsl-windows-toolbar-launcher's Issues

wsl-windows-toolbar failed to open

Using WSL 1, I tried to run it, but it returns an error:
(base) lemma@DESKTOP-FNQPG1F:~$ wsl-windows-toolbar
2020-07-19 18:46:28,090[WARNING]: Could not find imagemagick - some xpm icons may not convert correctly
Usage: wsl-windows-toolbar [OPTIONS]
Try "wsl-windows-toolbar --help" for help.

Error: Invalid value for "--menu-file" / "-f": Could not open file: /etc/xdg/menus/gnome-applications.menu: No such file or directory

Can't run

altantsooj@Altantsooj:~/.local/bin$ wsl-windows-toolbar
Traceback (most recent call last):
File "/home/altantsooj/.local/bin/wsl-windows-toolbar", line 5, in
from wsl_windows_toolbar.wsl_windows_toolbar import cli
File "/home/altantsooj/.local/lib/python3.10/site-packages/wsl_windows_toolbar/wsl_windows_toolbar.py", line 16, in
from click._compat import raw_input
ImportError: cannot import name 'raw_input' from 'click._compat' (/home/altantsooj/.local/lib/python3.10/site-packages/click/_compat.py)

Some windows executables missing makes failures not graceful

The script installs just fine, but if i try to run it with Python 3.8.3 x64 for Windows, I get this odd error:

C:>wsl-windows-toolbar
Traceback (most recent call last):
File "C:\Python38-x64\lib\runpy.py", line 194, in _run_module_as_main
return run_code(code, main_globals, None,
File "C:\Python38-x64\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Python38-x64\Scripts\wsl-windows-toolbar.exe_main
.py", line 4, in
File "C:\Python38-x64\lib\site-packages\wsl_windows_toolbar\wsl_windows_toolbar.py", line 8, in
import magic
File "C:\Python38-x64\lib\site-packages\magic.py", line 179, in
libmagic = ctypes.CDLL(dll)
File "C:\Python38-x64\lib\ctypes_init
.py", line 373, in init
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application

wsl-windows-toolbar doesn't want to run anymore...

whenever i try running wsl-windows-toolbar as a user from within WSL2 bash prompt, it just sits there for a few seconds, then spits out this odd error:

user@XOTICPC:~$ wsl-windows-toolbar
Traceback (most recent call last):
File "/home/user/.local/bin/wsl-windows-toolbar", line 5, in
from wsl_windows_toolbar.wsl_windows_toolbar import cli
File "/home/user/.local/lib/python3.8/site-packages/wsl_windows_toolbar/wsl_windows_toolbar.py", line 26, in
WINDOWS_USERPROFILE = subprocess.check_output(
File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/usr/lib/python3.8/subprocess.py", line 512, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['cmd.exe', '/C', 'echo', '%USERPROFILE%']' returned non-zero exit status 1.

I have no idea what would cause that. It used to happen on occasion, but rebooting my machine would usually fix it... what can I do to fix this odd behavior?

is it because my windows user profile has a space in it? (C:\Users\User Name\ instead of C:\Users\UserName, for example)...

cannot import name 'raw_input' from 'click._compat'

I am getting this error on a fresh archlinux WSL2 install.

Traceback (most recent call last):
  File "/home/goztrk/.local/bin/wsl-windows-toolbar", line 5, in <module>
    from wsl_windows_toolbar.wsl_windows_toolbar import cli
  File "/home/goztrk/.local/lib/python3.10/site-packages/wsl_windows_toolbar/wsl_windows_toolbar.py", line 16, in <module>
    from click._compat import raw_input
ImportError: cannot import name 'raw_input' from 'click._compat' (/home/goztrk/.local/lib/python3.10/site-packages/click/_compat.py)

Jinja2 error when launching wsl-windows-toolbar

I followed the instructions in the readme and ended up having an the same issue with raw_input encountered on #37 .

After applying his fix, I'm getting to the confirmation, then when I press enter, I obtain the following stack:

Press <enter> to continue or ctrl+c to abort. [y/N]:
Traceback (most recent call last):
  File "/home/andre/tools/wsl-windows-toolbar-launcher/wsl_windows_toolbar.py", line 546, in <module>
    cli()
  File "/home/andre/tools/wsl-windows-toolbar-launcher/venv/lib/python3.9/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/home/andre/tools/wsl-windows-toolbar-launcher/venv/lib/python3.9/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/home/andre/tools/wsl-windows-toolbar-launcher/venv/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/andre/tools/wsl-windows-toolbar-launcher/venv/lib/python3.9/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/home/andre/tools/wsl-windows-toolbar-launcher/wsl_windows_toolbar.py", line 313, in cli
    env = Environment(loader=PackageLoader('wsl_windows_toolbar', package_path=''))
  File "/home/andre/tools/wsl-windows-toolbar-launcher/venv/lib/python3.9/site-packages/jinja2/loaders.py", line 309, in __init__
    raise ValueError(
ValueError: The 'wsl_windows_toolbar' package was not installed in a way that PackageLoader understands.

Any clues?

NotImplementedError: Can't perform this operation for unregistered loader type

Hi,

I'm receiving the following error after following the installation instructions and trying to run "wsl-windows-toolbar". Once I'm presented with the default selections and am given the option to hit enter or ctrl+c I go ahead and hit enter and see the following:

2020-05-13 22:27:47,095[INFO]: distribution = Ubuntu
2020-05-13 22:27:47,096[INFO]: user = matt
2020-05-13 22:27:47,096[INFO]: confirm_yes = False
2020-05-13 22:27:47,096[INFO]: menu_file = /etc/xdg/menus/gnome-applications.menu
2020-05-13 22:27:47,096[INFO]: wsl_executable = C:\Windows\System32\wsl.exe
2020-05-13 22:27:47,096[INFO]: target_name = WSL
2020-05-13 22:27:47,097[INFO]: preferred_theme = Adwaita
2020-05-13 22:27:47,097[INFO]: alternative_theme = ('Papirus', 'Humanity', 'elementary-xfce')
2020-05-13 22:27:47,097[INFO]: jinja_template_batch = None
2020-05-13 22:27:47,097[INFO]: jinja_template_shell = None
2020-05-13 22:27:47,098[INFO]: rc_file = /home/matt/.bashrc
2020-05-13 22:27:47,098[INFO]: has_imagemagick = True
2020-05-13 22:27:47,098[INFO]: has_cairosvg = True
2020-05-13 22:27:47,137[INFO]: install_directory = /mnt/c/Users/mattc/.config/wsl-windows-toolbar-launcher/menus/WSL
2020-05-13 22:27:47,138[INFO]: metadata_directory = /mnt/c/Users/mattc/.config/wsl-windows-toolbar-launcher/metadata/WSL
2020-05-13 22:27:47,138[INFO]: For full list of options available, call script again with --help
2020-05-13 22:27:47,139[INFO]: This script will write to the above locations if it can, but giving final chance to chicken out.
Press <enter> to continue or ctrl+c to abort.
Traceback (most recent call last):
  File "/home/matt/.local/bin/wsl-windows-toolbar", line 11, in <module>
    load_entry_point('wsl-windows-toolbar==0.5.1', 'console_scripts', 'wsl-windows-toolbar')()
  File "/home/matt/.local/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/matt/.local/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/matt/.local/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/matt/.local/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/matt/.local/lib/python3.6/site-packages/wsl_windows_toolbar/wsl_windows_toolbar.py", line 250, in cli
    batch_template = env.get_template("wsl-windows-toolbar-template.bat.j2")
  File "/home/matt/.local/lib/python3.6/site-packages/jinja2/environment.py", line 883, in get_template
    return self._load_template(name, self.make_globals(globals))
  File "/home/matt/.local/lib/python3.6/site-packages/jinja2/environment.py", line 857, in _load_template
    template = self.loader.load(self, name, globals)
  File "/home/matt/.local/lib/python3.6/site-packages/jinja2/loaders.py", line 115, in load
    source, filename, uptodate = self.get_source(environment, name)
  File "/home/matt/.local/lib/python3.6/site-packages/jinja2/loaders.py", line 248, in get_source
    if not self.provider.has_resource(p):
  File "/home/matt/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1406, in has_resource
    return self._has(self._fn(self.module_path, resource_name))
  File "/home/matt/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1475, in _has
    "Can't perform this operation for unregistered loader type"
NotImplementedError: Can't perform this operation for unregistered loader type

I'm using WSL1 with Ubuntu (18.04) as my distro, and I'm able to open XTerm from inside WSL as per the check in the README.

Deadlock when using Imagemagick trying to convert some svg icons

sursm@LAPTOP-H4P3RT95:~$ wsl-windows-toolbar
2020-10-30 19:05:10,145[WARNING]: Could not find cairosvg - will not be able to convert svg
2020-10-30 19:05:10,361[INFO]: distribution = Ubuntu-20.04
2020-10-30 19:05:10,362[INFO]: user = sursm
2020-10-30 19:05:10,362[INFO]: confirm_yes = False
2020-10-30 19:05:10,362[INFO]: menu_file = /etc/xdg/menus/gnome-applications.menu
2020-10-30 19:05:10,363[INFO]: wsl_executable = C:\Windows\System32\wsl.exe
2020-10-30 19:05:10,363[INFO]: target_name = WSL
2020-10-30 19:05:10,363[INFO]: preferred_theme = Adwaita
2020-10-30 19:05:10,364[INFO]: alternative_theme = ('Papirus', 'Humanity', 'elementary-xfce')
2020-10-30 19:05:10,364[INFO]: jinja_template_batch = None
2020-10-30 19:05:10,364[INFO]: jinja_template_shell = None
2020-10-30 19:05:10,365[INFO]: rc_file = /home/sursm/.bashrc
2020-10-30 19:05:10,365[INFO]: has_imagemagick = True
2020-10-30 19:05:10,365[INFO]: has_cairosvg = False
2020-10-30 19:05:10,366[INFO]: launch_directory = /home/sursm
2020-10-30 19:05:10,465[INFO]: install_directory = /mnt/c/Users/sursm/.config/wsl-windows-toolbar-launcher/menus/WSL
2020-10-30 19:05:10,466[INFO]: metadata_directory = /mnt/c/Users/sursm/.config/wsl-windows-toolbar-launcher/metadata/WSL2020-10-30 19:05:10,466[INFO]: For full list of options available, call script again with --help
2020-10-30 19:05:10,467[INFO]: This script will write to the above locations if it can, but giving final chance to chicken out.
Press to continue or ctrl+c to abort.
2020-10-30 19:05:14,626[INFO]: Creating menu item for: Accessories/About Xfce
2020-10-30 19:05:16,747[INFO]: Creating menu item for: Accessories/Application Finder
2020-10-30 19:05:17,425[INFO]: Creating menu item for: Accessories/Byobu Terminal
2020-10-30 19:05:18,641[INFO]: Creating menu item for: Accessories/DB Browser for SQLite
2020-10-30 19:05:19,435[INFO]: Creating menu item for: Accessories/File Manager
2020-10-30 19:05:20,351[INFO]: Creating menu item for: Accessories/Run Program...
2020-10-30 19:05:21,357[INFO]: Creating menu item for: Accessories/TeXInfo
2020-10-30 19:05:22,490[INFO]: Creating menu item for: Accessories/Terminal Emulator
2020-10-30 19:05:23,322[INFO]: Creating menu item for: Accessories/Vim
2020-10-30 19:05:24,537[INFO]: Creating menu item for: Accessories/Visual Studio Code
2020-10-30 19:05:25,486[INFO]: Creating menu item for: Graphics/ImageMagick (color depth=q16)
2020-10-30 19:05:26,160[INFO]: Creating menu item for: Internet/FileZilla
2020-10-30 19:05:27,191[INFO]: Creating menu item for: Internet/Mail Reader
2020-10-30 19:05:28,083[INFO]: Creating menu item for: Internet/Web Browser
2020-10-30 19:05:28,848[INFO]: Creating menu item for: Programming/Android Studio

more 3/4 hours nothing happens

I ran by enabling debug logs here is what

.config\wsl-windows-toolbar-launcher\menus\WSL\Internet\FileZilla.lnk");$s.TargetPath = "wscript";$s.Arguments = ""C:\Users\sursm\.config\wsl-windows-toolbar-launcher\metadata\WSL\silent-launcher.vbs" "C:\Users\sursm\.config\wsl-windows-toolbar-launcher\metadata\WSL\Internet\FileZilla.bat"";$s.Description = "Download and upload files via FTP, FTPS and SFTP";$s.WorkingDirectory = "%USERPROFILE%";$s.IconLocation = "C:\Users\sursm.config\wsl-windows-toolbar-launcher\metadata\WSL\Internet\FileZilla.ico";$s.Save()'
2020-10-30 19:08:48,241[DEBUG]: Created C:\Users\sursm.config\wsl-windows-toolbar-launcher\menus\WSL\Internet\FileZilla.lnk
2020-10-30 19:08:48,241[INFO]: Creating menu item for: Internet/Mail Reader
2020-10-30 19:08:48,257[DEBUG]: Will create shortcut file: /mnt/c/Users/sursm/.config/wsl-windows-toolbar-launcher/menus/WSL/Internet/Mail Reader.lnk
2020-10-30 19:08:48,257[DEBUG]: Creating icon files for: emblem-mail, /mnt/c/Users/sursm/.config/wsl-windows-toolbar-launcher/metadata/WSL/Internet/Mail Reader [Adwaita]
2020-10-30 19:08:48,302[DEBUG]: STREAM b'IHDR' 16 13
2020-10-30 19:08:48,303[DEBUG]: STREAM b'IDAT' 41 1886
2020-10-30 19:08:48,319[DEBUG]: Successfully created /mnt/c/Users/sursm/.config/wsl-windows-toolbar-launcher/metadata/WSL/Internet/Mail Reader.ico
2020-10-30 19:08:48,373[DEBUG]: Powershell command to create shortcut: powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -Command '$ws = New-Object -ComObject WScript.Shell; $s = $ws.CreateShortcut("C:\Users\sursm.config\wsl-windows-toolbar-launcher\menus\WSL\Internet\Mail Reader.lnk");$s.TargetPath = "wscript";$s.Arguments = ""C:\Users\sursm\.config\wsl-windows-toolbar-launcher\metadata\WSL\silent-launcher.vbs" "C:\Users\sursm\.config\wsl-windows-toolbar-launcher\metadata\WSL\Internet\Mail Reader.bat"";$s.Description = "Read your email";$s.WorkingDirectory = "%USERPROFILE%";$s.IconLocation = "C:\Users\sursm.config\wsl-windows-toolbar-launcher\metadata\WSL\Internet\Mail Reader.ico";$s.Save()'
2020-10-30 19:08:48,785[DEBUG]: Created C:\Users\sursm.config\wsl-windows-toolbar-launcher\menus\WSL\Internet\Mail Reader.lnk
2020-10-30 19:08:48,785[INFO]: Creating menu item for: Internet/Web Browser
2020-10-30 19:08:48,800[DEBUG]: Will create shortcut file: /mnt/c/Users/sursm/.config/wsl-windows-toolbar-launcher/menus/WSL/Internet/Web Browser.lnk
2020-10-30 19:08:48,800[DEBUG]: Creating icon files for: web-browser, /mnt/c/Users/sursm/.config/wsl-windows-toolbar-launcher/metadata/WSL/Internet/Web Browser [Adwaita]
2020-10-30 19:08:48,869[DEBUG]: Checking with theme: Papirus
2020-10-30 19:08:48,887[DEBUG]: Checking with theme: Humanity
2020-10-30 19:08:48,905[DEBUG]: Found icon path: web-browser for theme Humanity
2020-10-30 19:08:48,905[DEBUG]: Checking with theme: Papirus
2020-10-30 19:08:48,906[DEBUG]: Checking with theme: Humanity
2020-10-30 19:08:48,913[DEBUG]: Found icon path: web-browser for theme Humanity
2020-10-30 19:08:48,915[DEBUG]: Could not convert using python methods - falling back on imagemagick
2020-10-30 19:08:49,122[DEBUG]: Converted /usr/share/icons/Humanity/apps/48/web-browser.svg to /mnt/c/Users/sursm/.config/wsl-windows-toolbar-launcher/metadata/WSL/Internet/Web Browser.png using imagemagick
2020-10-30 19:08:49,134[DEBUG]: STREAM b'IHDR' 16 13
2020-10-30 19:08:49,134[DEBUG]: STREAM b'gAMA' 41 4
2020-10-30 19:08:49,135[DEBUG]: STREAM b'cHRM' 57 32
2020-10-30 19:08:49,135[DEBUG]: STREAM b'bKGD' 101 6
2020-10-30 19:08:49,135[DEBUG]: b'bKGD' 101 6 (unknown)
2020-10-30 19:08:49,135[DEBUG]: STREAM b'IDAT' 119 9917
2020-10-30 19:08:49,139[DEBUG]: STREAM b'tEXt' 10048 37
2020-10-30 19:08:49,139[DEBUG]: STREAM b'tEXt' 10097 37
2020-10-30 19:08:49,139[DEBUG]: STREAM b'tEXt' 10146 62
2020-10-30 19:08:49,196[DEBUG]: Successfully created /mnt/c/Users/sursm/.config/wsl-windows-toolbar-launcher/metadata/WSL/Internet/Web Browser.ico
2020-10-30 19:08:49,326[DEBUG]: Powershell command to create shortcut: powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -Command '$ws = New-Object -ComObject WScript.Shell; $s = $ws.CreateShortcut("C:\Users\sursm.config\wsl-windows-toolbar-launcher\menus\WSL\Internet\Web Browser.lnk");$s.TargetPath = "wscript";$s.Arguments = ""C:\Users\sursm\.config\wsl-windows-toolbar-launcher\metadata\WSL\silent-launcher.vbs" "C:\Users\sursm\.config\wsl-windows-toolbar-launcher\metadata\WSL\Internet\Web Browser.bat"";$s.Description = "Browse the web";$s.WorkingDirectory = "%USERPROFILE%";$s.IconLocation = "C:\Users\sursm.config\wsl-windows-toolbar-launcher\metadata\WSL\Internet\Web Browser.ico";$s.Save()'
2020-10-30 19:08:49,983[DEBUG]: Created C:\Users\sursm.config\wsl-windows-toolbar-launcher\menus\WSL\Internet\Web Browser.lnk
2020-10-30 19:08:49,984[INFO]: Creating menu item for: Programming/Android Studio
2020-10-30 19:08:50,010[DEBUG]: Will create shortcut file: /mnt/c/Users/sursm/.config/wsl-windows-toolbar-launcher/menus/WSL/Programming/Android Studio.lnk
2020-10-30 19:08:50,010[DEBUG]: Creating icon files for: androidstudio, /mnt/c/Users/sursm/.config/wsl-windows-toolbar-launcher/metadata/WSL/Programming/Android Studio [Adwaita]
2020-10-30 19:08:50,054[DEBUG]: Could not convert using python methods - falling back on imagemagick

Add option to add to start menu too

The toolbar is nice the way it is, and I personally wouldn't use the start menu... but putting programs there means they get indexed by launchers like powertoys like real programs.

I foresee a shortcut named "Appname (WSL)" or similar in case the same app is installed on windows.

Batch files don't generate

As it says

the command ran fine, but the metadata folder is empty, and of course none of the shortcuts do anything.

No errors, just no functionality

Launching / Installing script in windows environment should not be possible

//libmagic is missing//

Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Users\phmec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\Scripts\wsl-windows-toolbar.exe_main
.py", line 4, in
File "C:\Users\phmec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\wsl_windows_toolbar\wsl_windows_toolbar.py", line 8, in
import magic
File "C:\Users\phmec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\magic.py", line 201, in
raise ImportError('failed to find libmagic. Check your installation')
ImportError: failed to find libmagic. Check your installation

C:\Users\phmec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\Scripts>

Set start in for generated shortcuts

When I start a terminal I am dropped into /mnt/c/WINDOWS/system32. This happens because Windows will default Start in to be whatever the path is for the program being launched so on my system C:\WINDOWS\system32\wscript.exe. WSL when launched will try to preserve your working directory.

It seems to me that is very unlikely people will want/need a default working directory in the system32 folder.

Unable to open applications from toolbar

Hi,

I recently installed the toolbar successfully, and am running Xming with the default setup on Windows 10 19.09. I'm running Ubuntu 18.04 on WSL1 as well, and I've installed Gnome via sudo apt install ubuntu-desktop.

When I first installed the toolbar I was able to open the Files application (Nautilus) without any trouble, but then found that nothing happened trying to open some others such as Firefox, Transmission etc. After some clicking around I think LibreOffice Draw opened for me as well but now today nothing is opening.

I went through the steps that you've recommended. I've got DISPLAY set to localhost:0.0, have disabled the public blocks on XMing in the firewall and have added a rule for TCP port 6000 in from the WSL subnet.

When I run the following commands they successfully open each application every time, they just don't open from the toolbar:

wsl.exe -d Ubuntu -u mattc -- source ~/.bashrc ; env; firefox
wsl.exe -d Ubuntu -u mattc -- source ~/.bashrc ; env; xterm
wsl.exe -d Ubuntu -u mattc -- source ~/.bashrc ; env; nautilus

Obviously happy to provide more information - just let me know which logs you want and where I can find them and I'll happy provide them.

Failed to start

Hi! Im having a problem starting wsl-windows-toolbar.
It gives me this error: The powershell.exe application must be in the current user's executable $PATH.
Do you know what can i do?

Cannot launch through task menu

I was able to launch gui within WSL shell, but cannot launch it through the task menu,
e.g., i found the shortcut in the menu a .lnk file with target

C:\WINDOWS\system32\wscript.exe C:\Users\username.config\wsl-windows-toolbar-launcher\metadata\WSL\silent-launcher.vbs "C:\Windows\System32\wsl.exe -d Ubuntu -u username -- source ~/.bashrc ; xfce4-about"
when i click it (or run in cmd.exe), nothing happens, but if i enter wsl bash and run xfce4-about, it works.

Issue with Firewall Rules method & README suggestion

Thanks @fquinner for your X-server Firewall instructions. They've been really helpful in setting up a local X-server for WSL2 - I found your Github from here

  1. I unfortunately couldn't get your Firewall Rules method to work. My workaround was to enable Public access for VcXsrv in Windows Defender Firewall -> Advanced Settings -> Inbound Rules. Just disabling the Block rule also works.

image

  1. Would you please be able to add that TCP port 6000 represents VcXsrv and can be verified by entering netstat -ab in an elevated command prompt?

"Now, right click on Inbound Rules and select New Rule..., select TCP port 6000 (most likely) and select defaults. This will open up your public network for this port... which is also not what you want. What you want is to only allow traffic from the WSL subnet. So refresh the list, scroll to your recently created name, right click and go to properties. Now under Scope, go to Remote IP address, Select These IP addresses and add in 172.16.0.0/12 to limit the subnets which can access this port to the WSL subnet. It should look something like"

I didn't know what TCP port 6000 referred to (and so wasn't 100% whether or not it would be the same on my computer) and found out thanks to this howtogeek guide. Entering netstat -ab in an elevated command prompt shows all of the ports associated with each app. By doing this I realised that port 6000 represents VcXsrv.

Not being able to access X server without mods

All applications except the terminal applications were not able to access the X server (VcXsrv):

I have to add the following code to the .bat files before calling the wsl.exe in order to make them work:

for /f "tokens=3 delims=: " %%i in ('netsh interface ip show config name^="Wireless" ^| findstr "IP Address" ^| findstr [0-9]') do set DISPLAY=%%i:0.0

set WSLENV=DISPLAY/u

I can run Linux GUI applications via terminal, but can't run via wsl-windows-toolbar.

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: #4:

export DISPLAY=192.168.0.107:0.0
# If not running interactively, don't do anything (wsl-launcher)
[ -z "$PS1" ] && return

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?

Unable to launch Intellij from WSL

This is slightly outside the scope of this tool, which seems to be working as intended, but you show yourself opening CLion running WSL on the README so I thought I'd ask anyways.

I've installed Intellij manually to /opt as described by this section. Running wsl-windows-toolbar-launcher, a shortcut to Intellij is not created. I made my own, to point to idea.sh, but it is not able to start.

How did you get CLion working so flawlessly?

Error when starting wsl-windows-toolbar -> TypeError: not enough arguments for format string

When I try to start wsl-windows-toolbar i have the following error:

Traceback (most recent call last):
File "/home/vampik/.local/bin/wsl-windows-toolbar", line 7, in
from wsl_windows_toolbar.wsl_windows_toolbar import cli
File "/home/vampik/.local/lib/python3.6/site-packages/wsl_windows_toolbar/wsl_windows_toolbar.py", line 26, in
uname().system,
TypeError: not enough arguments for format string

Also there is no folder:
%USERPROFILE%.config\wsl-windows-toolbar-launcher\menus\WSL

Imagemagick should be an optional dependency (currently mandatory)

I encountered an error when attempting to install this software to windows.

The python application seems to have installed fine from the Ubuntu repos.
my process to install on Ubuntu 20.04 using the WSL2 vm was
pip3 install wsl-windows-toolbar

I get this error, maybe having to do with windows permissions? The windows toolbar doesn't appear in my C:\User\Username.config folder

wilson@DESKTOP-EASON6P:~$ wsl-windows-toolbar
2020-09-10 15:29:40,101[WARNING]: Could not find cairosvg - will not be able to convert svg
2020-09-10 15:29:40,132[WARNING]: Could not find imagemagick - some xpm icons may not convert correctly
2020-09-10 15:29:40,139[INFO]: distribution = Ubuntu-20.04
2020-09-10 15:29:40,140[INFO]: user = wilson
2020-09-10 15:29:40,140[INFO]: confirm_yes = False
2020-09-10 15:29:40,140[INFO]: menu_file = /etc/xdg/menus/gnome-applications.menu
2020-09-10 15:29:40,140[INFO]: wsl_executable = C:\Windows\System32\wsl.exe
2020-09-10 15:29:40,140[INFO]: target_name = WSL
2020-09-10 15:29:40,140[INFO]: preferred_theme = Adwaita
2020-09-10 15:29:40,140[INFO]: alternative_theme = ('Papirus', 'Humanity', 'elementary-xfce')
2020-09-10 15:29:40,141[INFO]: jinja_template_batch = None
2020-09-10 15:29:40,141[INFO]: jinja_template_shell = None
2020-09-10 15:29:40,141[INFO]: rc_file = /home/wilson/.bashrc
2020-09-10 15:29:40,141[INFO]: has_imagemagick = False
2020-09-10 15:29:40,141[INFO]: has_cairosvg = False
2020-09-10 15:29:40,141[INFO]: launch_directory = /home/wilson
2020-09-10 15:29:40,212[ERROR]: The convert application must be in the current user's executable path.

any help to get this running would be much appreciated.

Failing

Hello, this used to work before,

but it does not work on my current machine.

it creates folders in the .config folder on windows side, but crashes out.

here is the error:

user@Win10-Ryzen:~$ wsl-windows-toolbar -f /etc/xdg/menus/xfce-applications.menu
2020-10-08 11:32:20,544[INFO]: distribution = Ubuntu
2020-10-08 11:32:20,545[INFO]: user = user
2020-10-08 11:32:20,545[INFO]: confirm_yes = False
2020-10-08 11:32:20,545[INFO]: menu_file = /etc/xdg/menus/xfce-applications.menu
2020-10-08 11:32:20,545[INFO]: wsl_executable = C:\Windows\System32\wsl.exe
2020-10-08 11:32:20,545[INFO]: target_name = WSL
2020-10-08 11:32:20,545[INFO]: preferred_theme = Adwaita
2020-10-08 11:32:20,545[INFO]: alternative_theme = ('Papirus', 'Humanity', 'elementary-xfce')
2020-10-08 11:32:20,545[INFO]: jinja_template_batch = None
2020-10-08 11:32:20,545[INFO]: jinja_template_shell = None
2020-10-08 11:32:20,545[INFO]: rc_file = /home/user/.bashrc
2020-10-08 11:32:20,545[INFO]: has_imagemagick = True
2020-10-08 11:32:20,545[INFO]: has_cairosvg = True
2020-10-08 11:32:20,545[INFO]: launch_directory = /home/user
2020-10-08 11:32:20,560[INFO]: install_directory = /mnt/c/Users/User/.config/wsl-windows-toolbar-launcher/menus/WSL
2020-10-08 11:32:20,561[INFO]: metadata_directory = /mnt/c/Users/User/.config/wsl-windows-toolbar-launcher/metadata/WSL
2020-10-08 11:32:20,561[INFO]: For full list of options available, call script again with --help
2020-10-08 11:32:20,561[INFO]: This script will write to the above locations if it can, but giving final chance to chicken out.
Press <enter> to continue or ctrl+c to abort.
Traceback (most recent call last):
  File "/home/user/.local/bin/wsl-windows-toolbar", line 8, in <module>
    sys.exit(cli())
  File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/user/.local/lib/python3.8/site-packages/wsl_windows_toolbar/wsl_windows_toolbar.py", line 237, in cli
    menu = xdg.Menu.parse(menu_file.name)
  File "/home/user/.local/lib/python3.8/site-packages/xdg/Menu.py", line 1128, in parse
    return XMLMenuBuilder(debug).parse(filename)
  File "/home/user/.local/lib/python3.8/site-packages/xdg/Menu.py", line 632, in parse
    menu = self.parse_menu(tree.getroot(), filename)
  File "/home/user/.local/lib/python3.8/site-packages/xdg/Menu.py", line 650, in parse_menu
    self.parse_node(node, filename, menu)
  File "/home/user/.local/lib/python3.8/site-packages/xdg/Menu.py", line 659, in parse_node
    menu = self.parse_menu(child, filename)
  File "/home/user/.local/lib/python3.8/site-packages/xdg/Menu.py", line 650, in parse_menu
    self.parse_node(node, filename, menu)
  File "/home/user/.local/lib/python3.8/site-packages/xdg/Menu.py", line 682, in parse_node
    parent.Rules.append(self.parse_rule(child))
  File "/home/user/.local/lib/python3.8/site-packages/xdg/Menu.py", line 759, in parse_rule
    return Rule(type, tree)
  File "/home/user/.local/lib/python3.8/site-packages/xdg/Menu.py", line 421, in __init__
    self.code = compile(self.expression, '<compiled-menu-rule>', 'eval')
ValueError: Name node can't be used with 'True' constant
user@Win10-Ryzen:~$

Can you advise?

Add optional prefix like "WSL" to shortcuts

This would be useful for the likes of launchers where (for example) there may be both a windows and Linux version of the same app (e.g. vscode, pycharm etc) and you want to know which one you're launching.

error when launching

see the error bellow. whats missing?
My installation is OK. I can launch full gnome with VcXsrv

wsl-windows-toolbar
Traceback (most recent call last):
File "c:\users\sugho\appdata\local\programs\python\python38\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\sugho\appdata\local\programs\python\python38\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Users\sugho\AppData\Local\Programs\Python\Python38\Scripts\wsl-windows-toolbar.exe_main
.py", line 4, in
File "c:\users\sugho\appdata\local\programs\python\python38\lib\site-packages\wsl_windows_toolbar\wsl_windows_toolbar.py", line 19, in
with open("/proc/mounts") as mount_fh:
FileNotFoundError: [Errno 2] No such file or directory: '/proc/mounts'

Error on running script "You cannot call a method on a null-valued expression."

Running on windows 10; WSL2

nauta@OW-168-wsl:/mnt/c/Users/uuu/wsl-windows-toolbar-launcher$ python3 wsl_windows_toolbar.py
2022-10-13 11:17:18,461[INFO]: distribution = 'Ubuntu-20.04'
2022-10-13 11:17:18,461[INFO]: user = 'nauta'
2022-10-13 11:17:18,461[INFO]: confirm_yes = False
2022-10-13 11:17:18,461[INFO]: menu_file = '/etc/xdg/menus/gnome-applications.menu'
2022-10-13 11:17:18,461[INFO]: wsl_executable = 'C:\Windows\System32\wsl.exe'
2022-10-13 11:17:18,461[INFO]: target_name = 'WSL'
2022-10-13 11:17:18,461[INFO]: preferred_theme = 'Adwaita'
2022-10-13 11:17:18,461[INFO]: alternative_theme = '('Papirus', 'Humanity', 'elementary-xfce')'
2022-10-13 11:17:18,461[INFO]: jinja_template_batch = 'None'
2022-10-13 11:17:18,461[INFO]: jinja_template_shell = 'None'
2022-10-13 11:17:18,462[INFO]: rc_file = '/home/nauta/.bashrc'
2022-10-13 11:17:18,462[INFO]: has_imagemagick = True
2022-10-13 11:17:18,462[INFO]: has_cairosvg = True
2022-10-13 11:17:18,462[INFO]: launch_directory = '/home/nauta'
2022-10-13 11:17:18,462[INFO]: batch_encoding = 'None'
2022-10-13 11:17:18,462[INFO]: use_batch_newline_crlf = False
2022-10-13 11:17:18,462[INFO]: shortcut_suffix = ' (WSL)'
2022-10-13 11:17:18,462[INFO]: install_directory = '/mnt/c/Users/uuu/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/WSL Windows Toolbar/WSL'
2022-10-13 11:17:18,462[INFO]: metadata_directory = '/mnt/c/Users/uuu/.config/wsl-windows-toolbar-launcher/metadata/WSL'
2022-10-13 11:17:18,462[INFO]: For full list of options available, call script again with --help
2022-10-13 11:17:18,462[INFO]: This script will write to the above locations if it can, but giving final chance to chicken out.
Press <enter> to continue or ctrl+c to abort. [y/N]: y
2022-10-13 11:17:27,492[INFO]: Creating menu item for: Accessories/Byobu Terminal
= : The term '=' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spell
ing of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ = New-Object -ComObject WScript.Shell
+ ~
    + CategoryInfo          : ObjectNotFound: (=:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

You cannot call a method on a null-valued expression.
At line:1 char:127
+ ... ript.Shell; $s = $ws.CreateShortcut("C:\Users\uuu\AppData\Roaming\M ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

The property 'TargetPath' cannot be found on this object. Verify that the property exists and can be set.
At line:1 char:284
+ ... (WSL).lnk");$s.TargetPath = "C:\Users\uuu\.config\wsl-windows-toolb ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

The property 'Arguments' cannot be found on this object. Verify that the property exists and can be set.
At line:1 char:398
+ ... etadata\WSL\Accessories\Byobu Terminal.bat";$s.Arguments = "";$s.Desc ...
+                                                 ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

The property 'Description' cannot be found on this object. Verify that the property exists and can be set.
At line:1 char:416
+ ... uments = "";$s.Description = "Advanced Command Line and Text Window M ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

The property 'WorkingDirectory' cannot be found on this object. Verify that the property exists and can be set.
At line:1 char:481
+ ... nd Text Window Manager";$s.WorkingDirectory = "%USERPROFILE%";$s.Icon ...
+                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

The property 'IconLocation' cannot be found on this object. Verify that the property exists and can be set.
At line:1 char:519
+ ... ERPROFILE%";$s.IconLocation = "C:\Users\uuu\.config\wsl-windows-too ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

You cannot call a method on a null-valued expression.
At line:1 char:635
+ ... olbar-launcher\metadata\WSL\Accessories\Byobu Terminal.ico";$s.Save()
+                                                                 ~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

2022-10-13 11:17:30,925[INFO]: Creating menu item for: Accessories/Files
= : The term '=' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spell
ing of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ = New-Object -ComObject WScript.Shell
+ ~
    + CategoryInfo          : ObjectNotFound: (=:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

You cannot call a method on a null-valued expression.
At line:1 char:127
+ ... ript.Shell; $s = $ws.CreateShortcut("C:\Users\uuu\AppData\Roaming\M ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

The property 'TargetPath' cannot be found on this object. Verify that the property exists and can be set.
At line:1 char:275
+ ... r\WSL\Accessories\Files (WSL).lnk");$s.TargetPath = "wscript";$s.Argu ...
+                                         ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

The property 'Arguments' cannot be found on this object. Verify that the property exists and can be set.
At line:1 char:301
+ ... = "wscript";$s.Arguments = "`"C:\Users\uuu\.config\wsl-windows-tool ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

The property 'Description' cannot be found on this object. Verify that the property exists and can be set.
At line:1 char:498
+ ... ies\Files.bat`"";$s.Description = "Access and organize files";$s.Work ...
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

The property 'WorkingDirectory' cannot be found on this object. Verify that the property exists and can be set.
At line:1 char:543
+ ... ess and organize files";$s.WorkingDirectory = "%USERPROFILE%";$s.Icon ...
+                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

The property 'IconLocation' cannot be found on this object. Verify that the property exists and can be set.
At line:1 char:581
+ ... ERPROFILE%";$s.IconLocation = "C:\Users\uuu\.config\wsl-windows-too ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

You cannot call a method on a null-valued expression.
At line:1 char:688
+ ... indows-toolbar-launcher\metadata\WSL\Accessories\Files.ico";$s.Save()
+                                                                 ~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

raw_input error

this is what I get when running the wsl-windows-toolbar script:
image

[Suggestion] Add a disclaimer about firewall debugging in the README.md

Greetings.

I found out this repo while trying to configure a x11 server with wsl2. From my research, this repo is one of the main sources that people are currently pointing to when trying to help others.

That said, I had a problem discovering which port I needed to add in the firewall rule ,I created the rule for port 6000, but after enabling firewall logs, I discovered that the server was running in 6001.

I also had a problem with the DISPLAY variable, my x server was running on :1.0 instead of :0.0.

I think that a mini-guide of how to enable firewall logs and a disclaimer to check the x server connection url would be very helpful to people coming to this repository with this kind of problem, so before I open a PR, I wanted to know if this kind of information is in the scope of this repo.

[support] Not able to run Jetbrains Toolbox

Hi,

First wanted to thank you for this nice piece of software :)

I know this isn't related to the tool itself, but I saw you running jetbrains products in your demo so maybe you could help me.
I'm trying to run jetbrains toolbox that is installed in WSL2 but it's not launching, while some other apps work fine.

Steps:

  1. I've installed the toolbox using this script: https://github.com/nagygergo/jetbrains-toolbox-install
  2. Re-run wsl-windows-toolbar
  3. Launch toolbox from the toolbar -> nothing happens
    3.1 Alternatively launching toolbox from WSL cli doesn't do anything either

I am able to run other gui apps, like xeyes from WSL terminal, and I'm also able to run apps from the toolbar, like htop and vim.

I've tried adding:

dbus_status=$(service dbus status)
if [[ $dbus_status = *"is not running"* ]]; then
  sudo service dbus --full-restart
fi

at the beginning of my ~.zshrc file, but that didn't help either.

And I tried to launch this from the cmd as well:

C:\Users\sergeip>wsl.exe -d Ubuntu-20.04 -u sergio -- source ~/.zshrc ; env; jetbrains-toolbox
HOSTTYPE=x86_64
LANG=C.UTF-8
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/ProgramData/chocolatey/bin:/mnt/c/Users/sergeip/AppData/Local/Microsoft/WindowsApps
TERM=xterm-256color
WSLENV=
WSL_INTEROP=/run/WSL/31905_interop
NAME=rocinante
HOME=/home/sergio
USER=sergio
LOGNAME=sergio
SHELL=/usr/bin/zsh
WSL_DISTRO_NAME=Ubuntu-20.04
SHLVL=1
PWD=/mnt/c/Users/sergeip
OLDPWD=/mnt/c/Users/sergeip
_=/usr/bin/env

which does not give any errors.

Here's the .desktop file:

✓ ~→ less ~/.local/share/applications/jetbrains-toolbox.desktop

[Desktop Entry]
Icon=/home/sergio/.local/share/JetBrains/Toolbox/toolbox.svg
Exec=/home/sergio/.local/share/JetBrains/Toolbox/bin/jetbrains-toolbox %u
Version=1.0
Type=Application
Categories=Development
Name=JetBrains Toolbox
StartupWMClass=jetbrains-toolbox
Terminal=false
MimeType=x-scheme-handler/jetbrains;
X-GNOME-Autostart-enabled=true
StartupNotify=false
X-GNOME-Autostart-Delay=10
X-MATE-Autostart-Delay=10
X-KDE-autostart-after=panel

Launching the app from the toobar does actually create the process in WSL:

✓ ~→ ps aux | grep jetbrains

sergio   10013 27.0  0.0  12124  2356 ?        Rsl  11:29   0:00 /home/sergio/.local/share/JetBrains/Toolbox/bin/jetbrains-toolbox
sergio   10022  299  0.2 3475908 106672 ?      Rl   11:30   0:02 ./jetbrains-toolbox

Any ideas what else I could try here?

Thanks a lot for the help!

Custom j2-template seems not to be working

I'm trying to make this use zsh rather than bash, and found a closed issue (#32) where it was explained you have to make use of a custom template for that. So I made this template where I only changed the first line:

#!/bin/zsh -i

source {{rcfile}}

{% if exec_dir is defined and exec_dir != "" %}

cd "{{exec_dir}}"

{% endif %}

{% if run_in_terminal is defined and run_in_terminal == True %}

{{command}}

{% else %}

{{command}} > /dev/null 2>&1 &
disown

{% endif %}

I then run this command:
wsl-windows-toolbar -r ~/.zshrc -J ~/etc/wslmenu-template.sh.j2

The output of the command indicates that the file is being used:

2021-02-18 20:50:28,843[INFO]: jinja_template_shell = /home/roy/etc/wslmenu-template.sh.j2

There are no errors in the output, just a warning about it not finding an icon-file for windows, which I assume isn't relevant.

However, the shortcut scripts created in %USERPROFILE%/.config/wsl-windows-toolbar-launcher/metadata/ do not reflect this, they're created with #!/bin/bash -i at the first line.

Update README.md to calculate 'Win Host IP Addr' without /etc/resolv.conf (for DISPLAY env variable)

I recently had to update my /etc/resolv.conf to include a proper DNS server -- this resolved an issue I was struggling with in my Network. This had the unfortunate result of breaking my DISPLAY environment variable for wsl-windows-toolbar!

I recommend updating the README.md to include the following example for calculating own IP Address. I think this should work well for all wsl folks -- I've only tested on my WSL2 Ubuntu 20.04 so far:

export DISPLAY=$(ip route show | grep 'via.*eth0' | cut -d' ' -f3):0.0

I hope this is a more resilient solution for folks, but I'm unsure if it is a stable alternative to using /etc/resolv.conf. What do you think?

Gnome error

Is gnome a pre-requisite? Can this be bypassed?

$ wsl-windows-toolbar
Usage: wsl-windows-toolbar [OPTIONS]
Try "wsl-windows-toolbar --help" for help.

Error: Invalid value for "--menu-file" / "-f": Could not open file: /etc/xdg/menus/gnome-applications.menu: No such file or directory

Permission Error

I have successfully installed this tool before but in a new instance of Ubuntu i am now receiving the error below:

2020-12-29 21:14:29,691[INFO]: distribution = Ubuntu
2020-12-29 21:14:29,692[INFO]: user = dev
2020-12-29 21:14:29,692[INFO]: confirm_yes = False
2020-12-29 21:14:29,692[INFO]: menu_file = /etc/xdg/menus/gnome-applications.menu
2020-12-29 21:14:29,692[INFO]: wsl_executable = C:\Windows\System32\wsl.exe
2020-12-29 21:14:29,692[INFO]: target_name = WSL
2020-12-29 21:14:29,692[INFO]: preferred_theme = Adwaita
2020-12-29 21:14:29,692[INFO]: alternative_theme = ('Papirus', 'Humanity', 'elementary-xfce')
2020-12-29 21:14:29,693[INFO]: jinja_template_batch = None
2020-12-29 21:14:29,693[INFO]: jinja_template_shell = None
2020-12-29 21:14:29,693[INFO]: rc_file = /home/dev/.bashrc
2020-12-29 21:14:29,693[INFO]: has_imagemagick = True
2020-12-29 21:14:29,693[INFO]: has_cairosvg = True
2020-12-29 21:14:29,693[INFO]: launch_directory = /home/dev
2020-12-29 21:14:29,693[INFO]: batch_encoding = None
2020-12-29 21:14:29,693[INFO]: use_batch_newline_crlf = False
2020-12-29 21:14:29,694[INFO]: install_directory = /mnt/c/Users/mfreeman/.config/wsl-windows-toolbar-launcher/menus/WSL
2020-12-29 21:14:29,694[INFO]: metadata_directory = /mnt/c/Users/mfreeman/.config/wsl-windows-toolbar-launcher/metadata/WSL
2020-12-29 21:14:29,694[INFO]: For full list of options available, call script again with --help
2020-12-29 21:14:29,694[INFO]: This script will write to the above locations if it can, but giving final chance to chicken out.
Press to continue or ctrl+c to abort.
2020-12-29 21:15:00,037[INFO]: Creating menu item for: Accessories/Byobu Terminal
Traceback (most recent call last):
File "/home/dev/.local/bin/wsl-windows-toolbar", line 8, in
sys.exit(cli())
File "/usr/lib/python3/dist-packages/click/core.py", line 764, in call
return self.main(*args, **kwargs)
File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/home/dev/.local/lib/python3.8/site-packages/wsl_windows_toolbar/wsl_windows_toolbar.py", line 370, in cli
os.chmod(shell_launcher_path, 509)
PermissionError: [Errno 1] Operation not permitted: '/mnt/c/Users/mfreeman/.config/wsl-windows-toolbar-launcher/metadata/WSL/Accessories/Byobu Terminal.sh'

rc_file is not respected and zsh support.

Command

 wsl-windows-toolbar -r ~/.zshrc

Result:

#!/bin/bash -i
source /home/olega/.bashrc
cd "/home/olega"
env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/phpstorm_phpstorm.desktop /snap/bin/phpstorm  > /dev/null 2>&1 &
disown

Expected

#!/bin/zsh -i
source /home/olega/.zshrc

Built-in XServer in windows

Doesn't windows now have a native xserver built in that can be used? I actually recall being able to use it, then upgraded to windows 11 (sucked), reinstalled windows 10 - but now I can't seem to get it to work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.