Last active
October 30, 2024 06:22
-
-
Save b23prodtm/b058b8b0efbd7e9c632dbcc7affe1754 to your computer and use it in GitHub Desktop.
How to install Gnome for Ubuntu 22.04 on WSL2?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if [ -z $(command -v wslvar) ]; then printf "%s\n" "Install package wslu please" ; sleep 2; exit 0; fi | |
username=$(wslvar USERNAME | awk '{ print tolower($0) }' ) | |
mkdir -p --parents "/mnt/c/users/$username/.ubuntu/" | |
cd "/mnt/c/users/$username/.ubuntu" | |
if [ ! -f /etc/apt/sources.list.d/microsoft-prod.list ]; then | |
sudo apt-key adv --fetch-keys https://packages.microsoft.com/keys/microsoft.asc | |
sudo apt update | |
fi | |
if [ ! -f /etc/apt/sources.list.d/wsl-transdebian.list ]; then | |
sudo wget -O /etc/apt/trusted.gpg.d/wsl-transdebian.gpg https://arkane-systems.github.io/wsl-transdebian/apt/wsl-transdebian.gpg | |
sudo chmod a+r /etc/apt/trusted.gpg.d/wsl-transdebian.gpg | |
sudo cat << EOF > /etc/apt/sources.list.d/wsl-transdebian.list | |
deb https://arkane-systems.github.io/wsl-transdebian/apt/ $(lsb_release -cs) main | |
deb-src https://arkane-systems.github.io/wsl-transdebian/apt/ $(lsb_release -cs) main | |
EOF | |
sudo apt update | |
fi | |
if [ -z $(sudo apt install --yes systemd-genie > /dev/null) ]; then | |
if [ ! -f /etc/sudoers.d/$USER ]; then | |
echo "$USER ALL=(ALL) NOPASSWD:/usr/bin/genie" | sudo EDITOR="tee" visudo --fil> fi | |
fi | |
# CREATE BASH SCRIPT | |
# Save block of text in bash file | |
cat << EOF > "/mnt/c/users/$username/.ubuntu/02_start_desktop.sh" | |
# Define necessary environment variables | |
export DISPLAY="\$(cat /etc/resolv.conf | grep nameserver | awk '{ print \$2 }'):0.0" | |
export DESKTOP_SESSION="ubuntu" | |
export GDMSESSION="ubuntu" | |
export XDG_SESSION_DESKTOP="ubuntu" | |
export XDG_CURRENT_DESKTOP="ubuntu:GNOME" | |
export XDG_SESSION_TYPE="x11" | |
export XDG_BACKEND="x11" | |
export XDG_SESSION_CLASS="user" | |
export XDG_DATA_DIRS="/usr/local/share/:/usr/share/:/var/lib/snapd/desktop" | |
export XDG_CONFIG_DIRS="/etc/xdg" | |
export XDG_RUNTIME_DIR="\$HOME/xdg" | |
export XDG_CONFIG_HOME="\$HOME/.config" | |
export XDG_DATA_HOME="\$HOME/.local/share" | |
export XDG_CACHE_HOME="\$HOME/.cache" | |
export XDG_DESKTOP_DIR="\$HOME/Desktop" | |
export XDG_DOCUMENTS_DIR="\$HOME/Documents" | |
export XDG_DOWNLOAD_DIR="\$HOME/Downloads" | |
export XDG_MUSIC_DIR="\$HOME/Music" | |
export XDG_PICTURES_DIR="\$HOME/Pictures" | |
export XDG_PUBLICSHARE_DIR="\$HOME/Public" | |
export XDG_TEMPLATES_DIR="\$HOME/Templates" | |
export XDG_VIDEOS_DIR="\$HOME/Videos" | |
# Start desktop environment | |
gnome-session | |
EOF |
W: Failed to fetch https://wsl-translinux.arkane-systems.net/apt/InRelease Could not resolve 'wsl-translinux.arkane-systems.net'
W: Some index files failed to download. They have been ignored, or old ones used instead.
"gnome-session
Terminated"
Is this project still alive? Would very much like to have Gnome desktop environment on my Windows machine.
EDIT: I somehow got it working yesterday. I then reinstalled Ubuntu because of other reasons and now can't get it to work again. This time I'm getting
"dbus-launch --exit-with-session gnome-session
dbus[1015]: Unable to set up transient service directory: XDG_RUNTIME_DIR "$HOME/xdg" not available: No such file or directory
Terminated"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@b23prodtm below statement is wrong, and script fails
got working with modifications
But it fails with following, seems wsl-transdebian for Ubuntu24 not available, only Ubuntu22