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?

  • Did any of the answers help? – Sparhawk Feb 10 at 20:51
1

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.

1

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.

  • 1
    Sorry @DKBose, I don't use Ubuntu any more. – Sparhawk Apr 23 at 5:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.