27

kwin occasionally hangs, which looks like the system not responding to mouse clicks or key presses - although the mouse pointer still moves when you move the mouse!

Robin Green
  • 1,050

8 Answers8

43

As described in the official Kwin documentation, a good way to go would be to try this either on a running terminal application or on a virtual console (i.e.: Ctrl+Alt+F1), :

DISPLAY=:0 kwin --replace
Ntropia
  • 531
  • 4
  • 7
  • +1, possibly the same effect as my solution (does kwin respond properly to sigint?), and certainly not worse. Also, a single command, so better. – Sparhawk Oct 11 '13 at 01:34
  • 2
    Don't you want to run it in the background? – Piotr Dobrogost Feb 22 '14 at 21:26
  • 1
    Thank you, thank you. Thankfully it crashed on a terminal screen; this saved me a bunch of heartache. – Peter Klipfel Oct 12 '16 at 18:48
  • What if that keyboard shortcut has no effect? – Douglas Gaskell Dec 03 '19 at 20:37
  • @DouglasGaskell If Ctrl+Alt+F1 is not working then I think you have a bigger problem than Kwin crashing. You can try the REISUB MagicSysRq keys in that situation to see if your kernel is still responsive (also to reboot more safely). It might be disabled on your system for security reasons though. You should search more about the topic before enabling them ofc. – Carolus Apr 13 '20 at 18:58
  • This worked for me, with the exception that instead of kwin it's kwin_x11 or kwin_wayland nowadays – mz8i Mar 17 '23 at 22:45
6

In later Kubuntu/Plasma 5 kwin still hangs/crashes (especially with Intel display drivers it seems), but can be more easily restarted: just run in krunner - Alt-Space, or Alt-F2: kwin --replace


Or, create a new custom shortcut for that: e.g. Trigger: Meta+K, Action, Command/URL: kwin --replace.

In this way kwin can be restarted with just the Meta-K shortcut.

6

Similar to Robin Green's answer, but this does not require a terminal window to be open already. Instead, specify the display in which to start kwin from tty1. Hence,

Press Ctrl+Alt+F1 to access a terminal. Log in.

Type killall kwin. Then, type in DISPLAY=:0 kwin.

Press Ctrl+Alt+F7 to change back to your primary display.

Sparhawk
  • 6,929
4

Press Ctrl+Alt+F1. Log in. Type killall kwin.

Press Ctrl+Alt+F7.

Quit all open applications until a terminal becomes visible. Hover the mouse over the terminal application. Type kwin &.

What's that, no terminal application open? Tough - you'll just have to reboot.

Robin Green
  • 1,050
  • I just added an answer that starts kwin from tty1, but I wonder if there is another way (that doesn't require a terminal window to be open already). Presumably you are getting keyboard input back after killing kwin, so after switching back to tty7, can you not just press alt-f2 an run kwin from there? – Sparhawk Dec 27 '12 at 01:32
  • Also, my two suggestions mean that you don't have to leave a terminal window open. – Sparhawk Dec 27 '12 at 01:34
2

Shortcuts

  • krunner: Alt+F2
  • Or: tty [number]: Ctrl+Alt+F[number]

Command

setsid kwin_x11 --replace &

Legend

  • setsid: creates a new session, so if the terminal is closed kwin still runs.
  • kwin_x11: only on x11, as in wayland the window manager holds the hole session (no way to restart without closing everything).
  • --replace: kills any running kwin before launching a new instance.
  • &: as a separate process.
  • 1
    That method is also recommended on https://reddit.com/r/kde/comments/a5d2ly/how_do_you_properly_restart_kwin_and_plasmashell/ebpw250/#c – Ganton Aug 12 '21 at 08:12
1

This actually works. It is a nasty bug but at least I can recover now.

In my case, there is no need to go back to the console login using ctrl+alt+f2 but using alt+f2 I can simply type killall plasma-desktop plasma-desktop and then using alt+f2 again,

I can run plasma-desktop. Could also be used in a script of course. This way I get back my mouse and I will not lose any work.

Seth
  • 58,122
  • 2
    I think that is a slightly different bug, because as I said, I could not use the keyboard at all except to switch to a virtual console. I do mean literally kwin, not plasma-desktop. – Robin Green Nov 18 '12 at 17:23
  • This restarts plasmashell but not kwin. I had the experience of frozen window that crushed kwin: restarting plasmashell would not fix this, but pkill kwin would. –  Jul 12 '18 at 14:54
0

If restarting kwin does not help (or if e.g. you have just lost the start menu), it may be plasma. In this case plasmashell is the one to run as of KDE 5.21 (replacing the old plasma-desktop).

eddygeek
  • 1,669
  • 1
  • 15
  • 17
-1

Just do:

killall plasma-desktop
plasma-desktop &

you could have it all in a bash script in case you need it more times,

recoverkde.sh:

killall plasma-desktop
plasma-desktop &
guntbert
  • 13,134
Korcia
  • 4,455
  • 2
  • 17
  • 12
  • 2
    And how am I supposed to execute these commands if kwin won't let me do anything on the X display? – Robin Green Nov 07 '12 at 09:47
  • 1
    This restarts plasmashell but not kwin. I had the experience of frozen window that crushed kwin: restarting plasmashell would not fix this, but pkill kwin would. –  Jul 12 '18 at 14:54
  • I sometimes do "killall kwin_x11 && kstart5 kwin_x11" , especially when plasma compositor gets slow – haytham-med haytham Oct 17 '22 at 13:20