239

I'm just talking about the standard KDE desktop. After a while (many days) of running the task bar stops working properly. This is due to some sort of undiagnosed bug but that's really not my boggle at the moment. It's fixed as soon as I log out and in again.

I have to close everything and ongoing processes like virtual machines have to shut down. It's a big pain. It typically means I put up with a bit of flickering for many days.

Is there a way to just reload the desktop without bombing all the running applications?

Oli
  • 293,335

10 Answers10

382

In KDE 4, you can do:

killall plasma-desktop #to stop it
kstart plasma-desktop #to restart it

In KDE 5 use:

killall plasmashell #to stop it
kstart plasmashell #to restart it

In KDE > 5.10 use:

kquitapp5 plasmashell
kstart5 plasmashell

Sometimes plasmashell is not responding so kquitapp5 fails after a timeout and you have to get back to killall. So in a nutshell, I would do :

# For KDE 4
killall plasma-desktop && kstart plasma-desktop

For KDE 5 < 5.10

killall plasmashell && kstart plasma-desktop

For KDE > 5.10

kquitapp5 plasmashell || killall plasmashell && kstart5 plasmashell

Remarks :

  1. If you are not sure which KDE version your run, kinfocenter --version will tell you.
  2. you can skip the kquitapp5 plasmashell || part if you don't want to be stuck in the timeout when plasmashell is not responding.
ChrisAga
  • 1,029
Korcia
  • 4,455
  • 2
  • 17
  • 12
  • 13
    Oddly enough these can both be run from the Alt-F2 run dialogue (I would have thought killing plasma would have inhibited it the second time) but yeah, works well and stops the flickering. – Oli Jun 24 '14 at 10:39
  • 1
    @Oli That's awesome, I didn't even know about Alt-F2! Thanks – Tobia Sep 09 '15 at 13:18
  • 4
    This doesn't work with KDE 5 Plasma. – Geremia Oct 31 '15 at 03:04
  • 7
    it's plasmashell instead of plasma-desktop in kde5 – dorien Nov 01 '15 at 01:04
  • also it works perfectly with opensuse. – devasia2112 Jul 06 '16 at 10:59
  • the simplest way to do it is using kquitapp5 for Plasma 5. http://askubuntu.com/a/663702/72652 (best done in KRunner rather than in a terminal) – Michael Tunnell Aug 30 '16 at 16:44
  • Doesn't work on Debian's "kde-plasma-desktop" implementation. First time trying it. But the Alt+F2 does work, and that's enough for me for now. – Paul Aug 07 '17 at 12:04
  • 8
    on ArchLinux it's kstart5 plasmashell for KDE5 – Daniel Andrei Mincă Apr 05 '18 at 10:36
  • 1
    killall plasmashell && kstart plasmashell apparently no longer works in KDE 5. Now I'm using kquitapp5 plasmashell && kstart5 plasmashell. – Eduardo Lucio Aug 28 '18 at 01:26
  • 13
    I added this to System Settings -> Shortcuts -> Custom Shortcuts, so now I can press Ctrl-Alt-Backspace to restart Plasma (I picked that particular combination because historically it restarts X.org). – Skylar Ittner Sep 15 '18 at 01:11
  • This works pretty well but doesn't touch the window manager components, using another answer here that can be done with kwin_x11 --replace (or kwin_wayland if on wayland). I added a global shortcut on Ctrl-Alt-Backspace that runs nohup sh -c "kquitapp5 plasmashell; kstart5 plasmashell; kwin_x11 --replace &" and it works perfectly. I can update the UI scaling without logging out and terminating all my applications. – theferrit32 Nov 20 '18 at 01:47
  • For me (using Manjaro, not Ubuntu), kquitapp5 plasmashell froze forever and kstart plasmashell was not a valid command, but a combination of the second and third solution in this answer worked: killall plasmashell and then kstart5 plasmashell. My issue was that KDE was frozen, so maybe that's why kquitapp5 also froze. – Fabian Röling Jul 29 '20 at 12:53
  • 2
    New command to restart kde plasma is "plasmashell --replace &" – BugSquanch Apr 04 '22 at 17:56
  • I had to use killall plasmashell && kstart5 plasmashell - kquitapp5 didn't help me. – Slbox Jul 28 '23 at 00:49
  • 1
    Why bother with kstart when simple plasmashell --replace & seems to work just fine? – Mikko Rantalainen Aug 16 '23 at 18:25
  • TLDR: killall plasmashell && kstart5 plasmashell – A.Casanova Jan 22 '24 at 12:53
84

In KDE5 use "kstart plasmashell" to restart the plasmashell as a service instead of plasmashell &. If you use it that way it 's run as an independed service not connected to the current terminal session (meaning you can close the terminal without the process getting terminated). TLDR:

KDE5 (in Terminal):

killall plasmashell
kstart plasmashell
  • Just wanted to say thanks for this! Once in a while Plasma 5 will place this strange black bar at the bottom of my screen just above the taskbar that sits above all windows covering whatever is underneath (you can still interact with stuff underneath you just can't see anything under the bar). No idea what causes it but killall plasmashell ; kstart plasmashell fixes it :) – riskable Sep 02 '15 at 13:30
  • the simplest way to do it is using kquitapp5 for Plasma 5. http://askubuntu.com/a/663702/72652 (best done in KRunner rather than in a terminal) – Michael Tunnell Aug 30 '16 at 16:43
  • kstart is not found. I needed to use kstart5 (Debian 11) – Mr. Developerdude Jan 26 '22 at 16:04
74

Well I didn't expect this to work (and it's not exactly what the question asks for) but pressing Alt+F2 and running:

kwin --replace

This reloads KDE's compositor and that seems to fix the flickering. I guess it's a factor into my particular issue.

Oli
  • 293,335
  • 12
    Tried this in Kubuntu 15.04. The command in Kde 5 will be kwin_x11 or kwin_wayland depending on the server running behind – zurdo Apr 28 '15 at 20:47
  • 1
    I actually solved using a combination of all solutions: killall plasmashell kwin --replace (ALT-F2) kstart plasmashell

    withoud kwin --replace, plasmashell did't restart (Kubuntu 16.04)

    – clobrano Jun 10 '16 at 09:13
  • 2
    The solution that worked for me was a mix of accepted answer and this one killall plasmashell; kwin --replace & kstart plasmashell & exit (the & exit since i was running it in terminal, otherwise the composer remained dependent on the terminal window being open as instructed here) – Carolus Aug 11 '16 at 13:52
  • 4
    Damn this actually worked fair and square.Thank you – Suleman Sep 19 '19 at 20:01
  • ah, that's the equivalent to gnome's f2 + r + enter . – abu_bua Apr 07 '21 at 23:59
  • mine froze today and I had absolutely no idea what to do besides a full reset... thanks for this, it worked <3 running kubuntu 22.04 – João Ciocca Feb 07 '23 at 20:23
  • If you're not sure if Plasma Shell or KWin are the culprit, you could just run kwin --replace & plasmashell --replace &. KWin is the software that takes care of moving and resizing windows, Plasma Shell is the process rendering the system bar (at the bottom of the screen by default). – Mikko Rantalainen Aug 16 '23 at 18:26
10

The window manager kwin is responsible for moving around windows, etc. That can be restarted by this:

kstart kwin --replace

The kstart prefix is just to not run it as a subprocess in the current terminal, such that you can close the terminal afterwards.

plasmashell is responsible for the background and other shell things. Restarting that should work like this:

killall plasmashell
kstart plasmashell

Note that this did not bring back the menu for me.

Also, interestingly, this again breaks kwin for me, i.e. I'm not able to move windows around anymore. On console, I get sth like QXcbConnection: XCB error: 3 (BadWindow), sequence: ..., resource id: ..., major code: 15 (QueryTree), minor code: 0.

Albert
  • 2,577
3

Some times ago, the plasma desktop started to have issues when I have attached a USB hub with USB-C and a second monitor. The window panel does not show any icons.

When I restart plasma by

plasmashell --replace &

Everything works fine again. My current plasma version is 5.26.4.

stollr
  • 143
  • 5
2

I looked this up because I had an issue where I couldn't open any KDE settings menus, but I didn't really want to reboot or log out. I found that the best way to do it (in KDE 5 at least) is by using krunner (Alt+F2) to killall plasmashell then immediately afterwards, plasmashell. I tried doing it in a Konsole window, using killall plasmashell and then plasmashell & and this worked, but as soon as I closed the Konsole window, plasma would close as well. Even though you seemed to resolve your issue, I figured I would post it for people coming along in the future needing to restart plasma.

In KDE 4, just replace plasmashell with plasma-desktop

1

OK .. I am running OpenSuse Leap 15.1 running KDE5 Plasma. Periodically, my X environment is corrupted (after about 24 hours of leaving my machine running) and I get "KLauncher could not be reached via D-Bus. Error when calling start_service_by_desktop_path: Not connected to D-Bus server"

The result of this is that while my desktop still functions I can't launch any applications which use KLauncher -- very annoying. (NOTE: also my xwindows vncserver appears to launch 99 instances of display windows I could attach to -- which isnt right -- I havent corrected this yet but I will). However, I FOUND the answer to the above issue to restart KDE 5 Plasma in my environment without a reboot:

1) killall plasmashell 2) kstart5 plasmashell kwin

This restarts everything as if the system is freshly booted. Hope this helps

Thanks

1

I find I'm always having trouble with ksycoca5, and this seems to be the reason plasmashell gets in a strop, and also stops plasmashell restarting. To solve this I did:

$ mv ~/.cache/ksycoca5* /tmp
$ killall plasmashell buildksycoca5; kstart plasmashell
0

I also tried something like:

killall plasmashell; kstart plasmashell

Or even this:

killall plasmashell; kwin --replace && kstart plasmashell

But, for, unknown reasons, it didn't work.

Plasma desktop restarting began to work after I added sleeps among the commands:

killall plasmashell ; sleep 3 ; kwin --replace ; sleep 5 ; kstart plasmashell

Finally, I've noticed that, when type 'kwin|plasma' in KSysGuard filter field, it reports that after killing plasmashell, such *.so files are still present: desktop.so, file.so. We must kill them too. Otherwise, we'll have copies of that files after each restart.

So, the final plasma desktop restarting commands are:

killall plasmashell desktop.so file.so ; sleep 5 ; kwin --replace ; sleep 5 ; kstart plasmashell
0

In KDE4 I find the memory usage ramps up to around a gigglebite pretty rapidly because opening programs progressively uses more RAM, but closing them does not release it. This is in Mint 17.3 with KDE but seems to affect pretty well ALL KDE plasma 4 systems.

I got sick of logging in and out, or using ALT + F2 to kill and restart plasma. So now I just have a script (set as executable) sitting on the panel..

   
#!/bin/bash 
killall plasma-desktop 
plasma-desktop & 
   

Click on the icon and plasma does a close and restart over about 15 seconds or so. I can still use open programs on whichever virtual desktop I am currently using while plasma is restarting.

RossD
  • 21