0

Answers in this question only work if one can type the commands inside active KDE session. In another tty, kstart complains that it can't open display.

How to restart KDE from tty2? How does kstart find the display? Can I set up DISPLAY environment variable or something like that?

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
andrybak
  • 823

3 Answers3

2

You can find the display the GUI session is running on with the who command.

To send output to a display from another local session, prepend the command with DISPLAY=:n, where n is the number of the display.

You can also set a session environment variable with export DISPLAY=:n if you have several commands you need to send to that display.

Mio Rin
  • 3,040
2

If KDE is running on tty1, it's likely :0, i.e. the command to run is:

DISPLAY=:0 plasmashell

FWIW, I'm frequently restarting plasmashell, so I wrote the following script. It rebuilds the plasmashell database, then kills the old plasmashell instance in increasing levels of severity.

kbuildsycoca5
timeout 5 kquitapp5 plasmashell
pgrep -U $USER -x plasmashell &>/dev/null && pkill -U $USER -x plasmashell
pgrep -U $USER -x plasmashell &>/dev/null && pkill -U $USER -x -9 plasmashell
pgrep -U $USER -x plasmashell &>/dev/null && echo "ERROR: cannot kill plasmashell"
plasmashell &

N.B. if you want to adapt this for usage from another tty, you can kill the previous plasmashell without defining DISPLAY. It's just starting the new instance that needs the variable.

Sparhawk
  • 19,941
-1

You can kill the process running Plasma and then the login screen should start again. Example for plasmashell version 5.26.2:

killall startplasma-x11
loup
  • 119
  • 3