Skip to content

Instantly share code, notes, and snippets.

@unlimish
Last active July 5, 2020 08:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unlimish/d9434ff4c86669aa81c0435577484a4f to your computer and use it in GitHub Desktop.
Save unlimish/d9434ff4c86669aa81c0435577484a4f to your computer and use it in GitHub Desktop.
WSL2で起動してGUIを立ち上げるときにすること
#!/bin/bash
# Prepare
sudo sh -c 'dbus-uuidgen > /var/lib/dbus/machine-id'
sudo service dbus restart
export DISPLAY="$(cat /etc/resolv.conf|grep nameserver|awk '{print $2}'):0"
# Launch VcXsrv
/mnt/c/Program\ Files/VcXsrv/vcxsrv.exe :0 -ac -keyhook &
# Start GNOME Session
XDG_CURRENT_DESKTOP=ubuntu:GNOME XDG_SESSION_TYPE=x11 gnome-session
# After End GNOME, Kill VcXsrv
/mnt/c/Windows/System32/taskkill.exe /IM vcxsrv.exe /T /F
# UUID を更新する
sudo sh -c 'dbus-uuidgen > /var/lib/dbus/machine-id'
# DBus を再起動する
sudo service dbus restart
# DISPLAY 環境変数は以下で指定する
export DISPLAY="$(cat /etc/resolv.conf|grep nameserver|awk '{print $2}'):0"
# ココまで設定したら、VcXsrv を起動する。
# DISPLAY : -1、「Dissable access control」にチェックを入れて、黒いウィンドウを出しておく
# VcXsrv を起動してある状態で、以下を実行する
XDG_CURRENT_DESKTOP=ubuntu:GNOME XDG_SESSION_TYPE=x11 gnome-session
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment