How to restart Cinnamon DE from the terminal?

I’ve made a tiny script that restores Cinnamon DE settings from a backup.

I have it as a part of a set of setup scripts, which are run as root.
It looks like this:

su -c "dconf load /org/cinnamon/ < ./cinnamon_desktop_backup" my_user
pkill -HUP -f "cinnamon --replace"

The first line works as expected.
My problem is with restating the Cinnamon after that, so it would pick up the changes immediately, without log-out.

When I do it manually with

right click to menu bar -> Troubleshoot -> Restart Cinnamon

or with

Alt + F2, then type 'r' and press 'Enter'

it works as expected. But it’s a manual approach which would be nice to avoid.
Mainly because I have as a part of larger pack of setup scripts, which I want to leave running unattended.


When I run the

pkill -HUP -f "cinnamon --replace"

which I found as a advice / solution on several places around the internet, it crashes the Cinnamon, which leads to the Cinnamon restarting itself, showing pop-up window

You are currently in fallback mode, do you want to restart Cinnamon YES/NO

And clicking YES will do the job.
Effectively, it cuts the amount of manual steps to half or third, but definitely isn’t elegant :slight_smile:

pkill -HUP -f "cinnamon"

or just plain

pkill cinnamon

will kill the Cinnamon, which will restart and log you out, so you’ll lose the whole session.


Anyone know what the working approaches that require manual steps do under the hood, so I may replicate it?

Cinnamon is based on Gnome is it not? If so you could look at what gnome-session-quit can do for you. Or other gnome-session commands. It also wouldn’t hurt to look at the session manager (gdm or like that provides the login details).

For the record:

The best solution I’ve found so far:

cinnamon --replace >/dev/null 2>&1 &

Executing an entirely new instance of cinnamon,
with argument --replace that makes it replace the previous instance(s),
and ignoring the stdout and stderr as it will flood the console a bit with some output,
and finally running that all in background, as you’ll get a hard time after ending that process :slight_smile: