How to restart plasmashell wayland from a tty

I am using Neon with the latest set of updates. My graphics set up is as follows:

$ inxi --graphics
Graphics:
  Device-1: NVIDIA GA106 [GeForce RTX 3060] driver: nvidia v: 560.35.03
  Device-2: Logitech C920 PRO HD Webcam driver: snd-usb-audio,uvcvideo
    type: USB
  Display: wayland server: X.org v: 1.21.1.11 with: Xwayland v: 23.2.6
    compositor: kwin_wayland driver: X: loaded: nvidia
    unloaded: fbdev,modesetting,nouveau,vesa gpu: nvidia resolution:
    1: 1920x1080 2: 1920x1080
  API: EGL v: 1.5 drivers: nvidia,swrast
    platforms: gbm,wayland,x11,surfaceless,device
  API: OpenGL v: 4.6.0 compat-v: 4.5 vendor: nvidia mesa v: 560.35.03
    renderer: NVIDIA GeForce RTX 3060/PCIe/SSE2
  API: Vulkan v: 1.3.275 drivers: N/A surfaces: xcb,xlib,wayland

Every once in a while it appears that plasmashell hangs and all I see is a blank dark screen. I can use the Ctrl-Alt-F5 key combination to go to a different tty. Say, tty1 was where I was on origially, and now I have launched tty5. I would like to be able to restart plasmashell on tty1 from tty5. I looked at this post but could not get it to work. When I run the command w from tty5, I see that tty1 has:

USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU  WHAT
vamsi    tty1     -                07:44   15:50m  0.02s  0.02s /usr/bin/startplasma-wayland

So, may be I am supposed to run something related to plasma-wayland? But I am not sure what that command is.

Try using systemctl --user restart plasma-plasmashell.service to restart plasmashell.

If it turns out you actually need to restart kwin under wayland, you could try systemctl --user restart plasma-kwin_wayland.service, though I don’t know how that will fare as far as keeping applications open or if some of them will be closed when you do that.

Thanks, that seems to have worked. But did not do exactly what I was hoping for. Typically when it hangs, I would have a bunch of windows, say Chrome and VS Code, open that I would like to preserve. Is that possible?

You can emulate what the “logout” widget does from the KDE desktop but instead via command line (like you could run this from that tty):

qdbus-qt6 org.kde.Shutdown /Shutdown logout

You’d just need to make sure package “qt6-qttools” is installed to have “qdbus-qt6” command available.

After it logouts out, then login again. If “System Settings” → “Session” → “Desktop Session” has “Session Restore” set to have “On last logout” checked, your apps and windows should be there.

Don’t do that, use kwin_wayland --replace instead. It at least allows apps that support compositor restarts to survive

2 Likes

I put a script (filename ‘prestart’) in ~/.local/bin

#!/bin/bash

systemctl --user restart plasma-plasmashell.service

That’s all - just call prestart from krunner. (I use this on Wayland - it fixes panel glitches).

Ah, that’s good to know, and also interesting, since my understanding based on using X11 has been that you’re better off to use systemctl --user restart plasma-kwin_x11.service rather than kwin_x11 --replace, or is that incorrect?

This was also why I thought that restarting kwin_wayland via systemctl was the more correct approach.

yes, x11 is a bit different

The issue I am facing was reported here: Plasma 6.2: Black screen on wakeup
In my case, it’s not a laptop but everything else is the same. I am watching that issue to see if there is a fix.

I use these commands (they preserve your open applications)

  1. kquitapp6 plasmashell
  2. kstart plasmashell

If running kde 5.x.x

  1. kquitapp5 plasmashell
  2. kstart5 plasmashell

I put them in a function in my shell config.

1 Like

Alternatively:

Copy this to clipboard:

#!/bin/bash
systemctl --user restart plasma-plasmashell.service

Create your ‘command’:

kate ~/.local/bin/prestart

Paste and save

Make it executable:

chmod +x ~/.local/bin/prestart

Run ‘prestart’ via krunner, or terminal, or whatever :wink: