Do you know if it's possible to run a second session in a window?
from talkingpumpkin@lemmy.world to linux@lemmy.ml on 15 Sep 2024 23:28
https://lemmy.world/post/19811738

I’m not much hoepful, but… just in case :)

I would like to be able to start a second session in a window of my current one (I mean a second session where I log in as a different user, similar to what happens with the various ctrl+alt+Fx, but starting a graphical session rather than a console one).

Do you know of some software that lets me do it?

Can I somehow run a KVM using my host disk as a the disk for the guest VM (and without breaking stuff)?

#linux

threaded - newest

bruhsoulz@lemmy.ml on 15 Sep 2024 23:49 next collapse

i do not think it is possible, but perhaps the closest thing u can get is virtualbox or qemu/kvm/virtmanager with shared folders, i believe that allows you to passthrough files between guest and host. (shared folders allow you to copy paste something on ur host into them and have them appear in the guest, but dont think i used them before, at least not extensively, so you might have to look into them to check if this advice helps you)

refalo@programming.dev on 16 Sep 2024 00:35 collapse

Several solutions have already been posted in here, please do not try to act authoritative when you don’t know the answer. We already saw you asked what VNC is.

rtxn@lemmy.world on 16 Sep 2024 00:43 next collapse

Bro, that is literally the first comment on the post! None of the solutions were posted when it was made.

They’re wrong, but you are just being a dick.

bruhsoulz@lemmy.ml on 16 Sep 2024 00:52 collapse

Thx for sticking up 😎 🤝

bruhsoulz@lemmy.ml on 16 Sep 2024 01:21 collapse

The irony is insane. “Act authoritative” even tho I literally didn’t claim to know anything for certain (I do not -think-, perhaps, I believe). Also as other gentleman pointed out, no other comment was there when I tried to help. I asked about vnc -after- I made my initial comment, because a few minutes after other people started pitching in with more accurate and relevant information. I feared the post would go on to have no responses so I tried to pitch in; you don’t have to know everything about everything in order to try and help someone out, all I did was provide my take on the matter, which is better than ignoring the question, regardless of how fruitful or fruitless what I had to say was. People like you are why noobs are afraid if dipping their toes in more technical areas such as linux, and get scared off by smartass supremacists that like to spoil things for no good reason. Sincere, seek help. 🤦🏻‍♂️

Enkers@sh.itjust.works on 15 Sep 2024 23:50 next collapse

I’d imagine you could run a VNC server, and then just login from the same PC. This kinda what you’re looking for?

There are some limitations, like I don’t think hardware acceleration would work, for example.

Edit: I did a little searching for “nested x-session” and found out that there is a specific x11 program to do exactly what you want called xephyr. There’s also a brief guide on the arch wiki.

bruhsoulz@lemmy.ml on 16 Sep 2024 00:02 next collapse

whats a vnc server o.O

Enkers@sh.itjust.works on 16 Sep 2024 00:07 collapse

Virtual Network Computing. It’s basically an alternative to remote desktop.

bruhsoulz@lemmy.ml on 16 Sep 2024 01:01 collapse

Thanks, sounds interesting

Max_P@lemmy.max-p.me on 16 Sep 2024 00:41 collapse

It’s a lot easier with Wayland and hardware acceleration works, see my solution. It does a proper login session and starts the whole DE exactly the same way as if you logged in from a tty too so everything just works as expected there. Wayland devs use that a lot for testing and development so it’s quite well supported overall.

arran4@aussie.zone on 16 Sep 2024 00:04 next collapse

Used to use Xnest to do this. IDK how easy it still is these days.

arran4@aussie.zone on 16 Sep 2024 00:05 next collapse
lambalicious@lemmy.sdf.org on 16 Sep 2024 04:06 collapse

IDK how easy it still is these days.

[packagemanagername] install xnest, tbh.

bloodfart@lemmy.ml on 16 Sep 2024 00:07 next collapse

It’s helpful to in this case to say what you’re actually trying to do.

I don’t think you want multiseat, but I did something similar with x back in the day using a configuration for users similar to what’s described here.

Note that that isn’t what you asked for. It’s having multiple x sessions on different f1, f2 etc keys.

talkingpumpkin@lemmy.world on 16 Sep 2024 06:20 collapse

I’m just messing around with testing/configuring different desktop environment/window managers and I’m looking for a quick way to preview them (running the new session as my user would be fine too - I just thought it would be simpler as a different user)

bloodfart@lemmy.ml on 16 Sep 2024 08:35 collapse

running a “second seat” on a different F key like in the link might be a good way to do that.

back in the day i would just log out and log in. there’s so much going on with desktop environments i kinda had to spend some time in one doing my daily to figure out if it was what i wanted.

saigot@lemmy.ca on 16 Sep 2024 00:11 next collapse

Would ssh -X username@localhost work?

CameronDev@programming.dev on 16 Sep 2024 00:15 next collapse

Sway-wm used to be spawnable as a child window, not sure if that is still possible.

I think you should also be able to get multiple ctrl-alt-fX graphical sessions.

I’ll come back and update this comment when I get to my PC and give this a try.

Edit: seem Max-P’s comment.

Max_P@lemmy.max-p.me on 16 Sep 2024 00:18 next collapse

Totally possible. It’ll work best with Wayland thanks to nested compositor support, whereas on Xorg you’d need to use Xephyr which doesn’t do hardware acceleration.

# Give the other user access to your Wayland socket
setfacl -m u:otheruser:rx $XDG_RUNTIME_DIR
setfacl -m u:otheruser:rwx $XDG_RUNTIME_DIR/wayland-0

# Open a session as the other user (note the trailing @, it's there to login in to the local machine)
sudo machinectl login otheruser@

# Start your DE!
WAYLAND_DISPLAY=/run/user/$(id -u yourmainuser)/wayland-0 startplasma-wayland

And tada! <img alt="Nested Wayland session" src="https://lemmy.max-p.me/pictrs/image/c2bc514e-515b-49de-b20e-937b6b7a177d.png">

Findmysec@infosec.pub on 16 Sep 2024 01:23 next collapse

Nice

bruhsoulz@lemmy.ml on 16 Sep 2024 01:33 next collapse

This looks so neat, I screenshot for future reference if I wanted to recreate this, thanks :)

lord_ryvan@ttrpg.network on 16 Sep 2024 06:02 collapse

You can also bookmark comments on Lemmy, and copy the comment URL and store that in (synced) browser bookmarks!

Oh, copy the comment text and save it in a text- or markdown-file on your devices, in case it gets taken down! You can even for the text in case you forgot where you kept it!

BlueEther@no.lastname.nz on 16 Sep 2024 04:57 next collapse

Start your DE!

WAYLAND_DISPLAY=/run/user/$(id -u yourmainuser)/wayland-0 startplasma-wayland

This is cool

talkingpumpkin@lemmy.world on 16 Sep 2024 06:16 next collapse

Wow, that’s so neat!

On my machine it opens a fullscreen plasma spash and then it shows the new session intermixed/overlayed with my current one instead of in a new window… basically, it’s a mess :D

If I may abuse your patience:

  • what distro/plasma version are you running? (here it’s opensuse slowroll w/ plasma 6.1.4)
  • what happens if you just run startplasma-wayland from a terminal as your user? (I see the plasma splash screen and then I’m back to my old session)
nerdovic@discuss.tchncs.de on 16 Sep 2024 07:15 next collapse

Screenshot of said mess? Purley for entertainment 😄

talkingpumpkin@lemmy.world on 18 Sep 2024 03:54 collapse

I fear it was nothing that entertaining: it was just my “normal” dark panel at the top of the screen and a second “default” white one at the bottom (this last one partially covered the windows I had open). I didn’t try triggering notifications or otherwise causing some kind of mayhem.

Max_P@lemmy.max-p.me on 16 Sep 2024 07:27 collapse

Make sure to use machinectl and not sudo or anything else. That’s about the symptoms I’d expect from an incomplete session setup. The use of machinectl there was very deliberate, as it goes through all the PAM, logind, systemd and D-Bus stuff as any normal login. It gets you a clean and properly registered session, and also gets rid of anything tied to your regular user:

max-p@desktop ~> loginctl list-sessions
SESSION  UID USER  SEAT  LEADER CLASS   TTY   IDLE SINCE
      2 1000 max-p seat0 3088   user    tty2  no   -    
      3 1000 max-p -     3112   manager -     no   -    
      8 1001 tv    -     589069 user    pts/4 no   -    
      9 1001 tv    -     589073 manager -     no   -    

It basically gets you to a state of having properly logged into the system, as if you logged in from SDDM or in a virtual console. From there, if you actually had just logged in a tty as that user, you could run startplasma-wayland and end up in just as if you had logged in with SDDM, that’s what SDDM eventually launches after logging you in, as per the session file:

max-p@desktop ~> cat /usr/share/wayland-sessions/plasma.desktop 
[Desktop Entry]
Exec=/usr/lib/plasma-dbus-run-session-if-needed /usr/bin/startplasma-wayland
TryExec=/usr/bin/startplasma-wayland
DesktopNames=KDE
Name=Plasma (Wayland)
# ... and translations in every languages

From there we need one last trick, it’s to get KWin to start nested. That’s what the additional WAYLAND_DISPLAY=/run/user/1000/wayland-0 before is supposed to do. Make sure that this one is ran within the machinectl shell, as that shell and only that shell is the session leader.

The possible gotcha I see with this, is if startplasma-wayland doesn’t replace that WAYLAND_DISPLAY environment variable with KWin’s, so all the applications from that session ends up using the main user. You can confirm this particular edge case by logging in with the secondary user on a tty, and running the same command including the WAYLAND_DISPLAY part of it. If it starts and all the windows pop up on your primary user’s session, that’s the problem. If it doesn’t, then you have incorrect session setup and stuff from your primary user bled in.

Like, that part is really important, by using machinectl the process tree for the secondary user starts from PID 1:

max-p@desktop ~> pstree
systemd─┬─auditd───{auditd}
        ├─bash─┬─(sd-pam)                 # <--- This is the process machinectl spawned
        │      └─fish───zsh───fish───zsh  # <-- Here I launched a bunch of shells to verify it's my machinectl shell
        ├─systemd─┬─(sd-pam) # <-- And that's my regular user
        │         ├─Discord─┬─Discord───Discord───46*[{Discord}]
        │         ├─DiscoverNotifie───9*[{DiscoverNotifie}]
        │         ├─cool-retro-term─┬─fish───btop───{btop}
        │         ├─dbus-broker-lau───dbus-broker
        │         ├─dconf-service───3*[{dconf-service}]
        │         ├─easyeffects───11*[{easyeffects}]
        │         ├─firefox─┬─3*[Isolated Web Co───30*[{Isolated Web Co}]]

Super weird stuff happens otherwise that I can’t explain other than some systemd PAM voodoo happens. There’s a lot of things that happens when you log in, for example giving your user access to keyboard, mouse and GPU, and the type of session depends on the point of entry. Obviously if you log in over SSH you don’t get the keyboard assigned to you. When you switch TTY, systemd-logind also moves access to peripherals such that user A can’t keylog user B while A’s session is in the background. Make sure the machinectl session is also the only session opened fo

Max_P@lemmy.max-p.me on 16 Sep 2024 09:05 collapse

You can also nest rootful Xwayland in there too!

From the user’s shell,

WAYLAND_DISPLAY=/run/user/1000/wayland-0 Xwayland :1 &
export DISPLAY=:1 WAYLAND_DISPLAY=
i3 &
xterm &
konsole &

<img alt="" src="https://lemmy.max-p.me/pictrs/image/95c14b29-97a1-41ba-910c-2acf3c6065c6.png">

Of course you that means you can also run Plasma X11 that way for example:

<img alt="" src="https://lemmy.max-p.me/pictrs/image/eb81959c-01d3-4e48-8c5d-4c459855cf43.png">

RustyHeater@lemmy.world on 16 Sep 2024 00:19 next collapse

Multi head X like this? duskopijetlovic.com/…/xorg-x11-multihead-two-sepa…

rtxn@lemmy.world on 16 Sep 2024 00:35 next collapse

XWayland has something called a “rootful mode” where it opens an X11 session as a window nested inside a Wayland session. www.youtube.com/watch?v=Ij3rsqX2pKQ XWayland will be started as your own user, but maybe you could use sudo -u … to set a different user.

The other possibility is to switch to another terminal session with a different user, start an X11 session with startx, and use x11vnc -listen 127.0.0.1 -forever -passwd PASS1234 to run a VNC server that’s only accessible from the local machine.

Whirling_Cloudburst@lemmy.world on 16 Sep 2024 07:02 next collapse

dysprosium@lemmy.dbzer0.com on 16 Sep 2024 07:50 collapse

possiblylinux127@lemmy.zip on 17 Sep 2024 02:23 collapse

Yes?

All the options you brought up are possible. What are you trying to do?