lima-vm / lima

Linux virtual machines, with a focus on running containers
https://lima-vm.io/
Apache License 2.0
14.62k stars 572 forks source link

lima+X11 #151

Open satmandu opened 2 years ago

satmandu commented 2 years ago

Is it possible short of the vsock work being completed to easily tunnel X11 connections over ssh from the lima VM to Xquartz?

Obviously connected to https://github.com/lima-vm/lima/issues/2

AkihiroSuda commented 2 years ago

qemu still doesn't support vsock for macOS hosts, so the current solution is to run ssh -X localhost:PORT.

satmandu commented 2 years ago

hmmm.

 limactl list
NAME       STATUS     SSH                ARCH      DIR
default    Running    127.0.0.1:60022    x86_64    /Users...

ssh -X localhost:60022
ssh: Could not resolve hostname localhost:60022: nodename nor servname provided, or not known

ssh -X localhost:60022
ssh: Could not resolve hostname localhost:60022: nodename nor servname provided, or not known

Do I need to enable a separate address which can be connected to via ssh?

Would it make sense to have a flag/option such that limactl start automatically starts a background connection with ssh -X localhost:PORT so that running things via, for instance, lima xterm just works?

AkihiroSuda commented 2 years ago

Sorry I meant ssh -X -p 60022 localhost

satmandu commented 2 years ago

Ah yes this is described on the front page... ssh -X -p 60022 -i ~/.lima/_config/user -o NoHostAuthenticationForLocalhost=yes 127.0.0.1 worked for me.

satmandu commented 2 years ago

Screen Shot 2021-08-07 at 12 35 35 AM

``NO_AT_BRIDGE=1 LC_ALL="en_US.UTF-8" dbus-launch gnome-terminal``` let me get gnome-terminal working from inside lima!

VitoVan commented 2 years ago

In case anyone failed to make libreoffice work on Fedora, please try:

dnf install dbus-x11

and it may solve your problem.

gautam-dev-maker commented 2 years ago

@VitoVan does that mean , I will be able to open LibreOffice in a window with proper GUI? If that so, could you pls list out the steps to follow, I am pretty new to this. Thank you.

VitoVan commented 2 years ago

@VitoVan does that mean , I will be able to open LibreOffice in a window with proper GUI? If that so, could you pls list out the steps to follow, I am pretty new to this. Thank you.

It's X11 Forwarding like any other regular Linux.

If you are using Fedora with Lima, then you can:

sudo dnf install libreoffice
sudo dnf install dbus-x11

and on your macOS, open your Terminal and:

ssh -X -p 60022 -o NoHostAuthenticationForLocalhost=yes -i ~/.lima/_config/user localhost libreoffice

Make sure you got XQuartz installed on your macOS.

I don't know what you mean by proper GUI, but it is X11 in macOS (XQuatz) and it's usable albeit not so native.

gautam-dev-maker commented 2 years ago

@VitoVan does that mean , I will be able to open LibreOffice in a window with proper GUI? If that so, could you pls list out the steps to follow, I am pretty new to this. Thank you.

It's X11 Forwarding like any other regular Linux.

If you are using Fedora with Lima, then you can:

sudo dnf install libreoffice
sudo dnf install dbus-x11

and on your macOS, open your Terminal and:

ssh -X -p 60022 -o NoHostAuthenticationForLocalhost=yes -i ~/.lima/_config/user localhost libreoffice

Make sure you got XQuartz installed on your macOS.

I don't know what you mean by proper GUI, but it is X11 in macOS (XQuatz) and it's usable albeit not so native.

I want to open the Gedit text editor with proper window and UI which doesn't seem to happen when I run gedit command in terminal, instead I get this error

Unable to init server: Could not connect: Connection refused

(gedit:3625): Gtk-WARNING **: 16:55:17.647: cannot open display:

btw I am using Ubuntu

VitoVan commented 2 years ago

@gautam-dev-maker I tried Lima Ubuntu on macOS, and it worked:

image

Check the screenshot to see if it helps.

gautam-dev-maker commented 2 years ago

Thanks for the detailed steps @VitoVan, It works fine now. xQuartz is really good.

CaelumF commented 2 years ago

It is very slow for me, like a few seconds to update when a tab changes. Any thoughts ?

MicahBird commented 11 months ago

I was recently having trouble getting Fedora to forward any X11 app through xQuartz, (it would always throw X11 forwarding request failed when running limactl shell fedora), but the following commands fixed the issue, hopes this helps others!

limactl shell fedora
sudo dnf install xauth -y
touch ~/.Xauthority
exit

# Open XQuartz
limactl shell fedora

# Install and run whatever X11 app you'd like! For example, xeyes:
sudo dnf install xeyes -y
xeyes