[SOLVED] Hide quit options? How?

Please post suggestions for improvement of Cinnamon on:
https://github.com/linuxmint/Cinnamon
Post Reply
markfilipak
Level 5
Level 5
Posts: 979
Joined: Sun Mar 10, 2013 8:08 pm

[SOLVED] Hide quit options? How?

Post by markfilipak »

Re, Cinnamon 3.0.7

The Cinnamon context menu 'Configure...' opens an 'Applets' dialog.
The 'Applets' dialog displays a check-box labeled 'Show favorites and quit options'.
There is no check-box for 'Show favorites but hide quit options'.
Is there a way to hide the menu's quit options?

With Regards, Mark
Last edited by markfilipak on Mon May 27, 2019 5:48 pm, edited 1 time in total.
User avatar
Moem
Level 20
Level 20
Posts: 11944
Joined: Tue Nov 17, 2015 9:14 am
Location: The Netherlands
Contact:

Re: Hide quit options? How?

Post by Moem »

I've not tried this, but can you drag them off the menu and into a submenu of your choice?
Image

If your issue is solved, kindly indicate that by editing the first post in the topic, and adding [SOLVED] to the title. Thanks!
markfilipak
Level 5
Level 5
Posts: 979
Joined: Sun Mar 10, 2013 8:08 pm

Re: Hide quit options? How?

Post by markfilipak »

Moem wrote:
Sun May 26, 2019 6:40 pm
I've not tried this, but can you drag them off the menu and into a submenu of your choice?
No. I can drag other 'Favorites', but not the 'Lock screen' 'Logout' & 'Quit' buttons. They are immovable.
User avatar
smurphos
Level 17
Level 17
Posts: 7332
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher
Contact:

Re: Hide quit options? How?

Post by smurphos »

You need to manually edit the applet's javascript to remove the system buttons.

I've not tested this on your specific ( & very old :roll: :wink: ) version of Cinnamon. but it should work.

1) Make a copy of the default applet to your local applet storage using the file manager or this terminal command.

Code: Select all

cp -R /usr/share/cinnamon/applets/menu@cinnamon.org ~/.local/share/cinnamon/applets
2) Open the local copy's applet.js in a text editor

Code: Select all

xdg-open ~/.local/share/cinnamon/applets/menu@cinnamon.org/applet.js
3) Locate and remove this section of code, save the file and restart Cinnamon - Ctrl-Alt-Esc. In case of any errors deleting the local copy will revert back to the system default.

Code: Select all

        //Separator
        if (launchers.length != 0) {
                let separator = new PopupMenu.PopupSeparatorMenuItem();
                this.favoritesBox.add_actor(separator.actor, { y_align: St.Align.END, y_fill: false });
        }

        //Lock screen
        let button = new SystemButton(this, "system-lock-screen", launchers.length + 3,
                                      _("Lock screen"),
                                      _("Lock the screen"));

        this._addEnterEvent(button, Lang.bind(this, this._favEnterEvent, button));
        button.actor.connect('leave-event', Lang.bind(this, this._favLeaveEvent, button));

        button.activate = Lang.bind(this, function() {
            this.menu.close();

            let screensaver_settings = new Gio.Settings({ schema_id: "org.cinnamon.desktop.screensaver" });
            let screensaver_dialog = Gio.file_new_for_path("/usr/bin/cinnamon-screensaver-command");
            if (screensaver_dialog.query_exists(null)) {
                if (screensaver_settings.get_boolean("ask-for-away-message")) {
                    Util.spawnCommandLine("cinnamon-screensaver-lock-dialog");
                }
                else {
                    Util.spawnCommandLine("cinnamon-screensaver-command --lock");
                }
            }
            else {
                this._screenSaverProxy.LockRemote("");
            }
        });

        this.favoritesBox.add_actor(button.actor, { y_align: St.Align.END, y_fill: false });

        //Logout button
        let button = new SystemButton(this, "system-log-out", launchers.length + 3,
                                      _("Logout"),
                                      _("Leave the session"));

        this._addEnterEvent(button, Lang.bind(this, this._favEnterEvent, button));
        button.actor.connect('leave-event', Lang.bind(this, this._favLeaveEvent, button));

        button.activate = Lang.bind(this, function() {
            this.menu.close();
            this._session.LogoutRemote(0);
        });

        this.favoritesBox.add_actor(button.actor, { y_align: St.Align.END, y_fill: false });

        //Shutdown button
        let button = new SystemButton(this, "system-shutdown", launchers.length + 3,
                                      _("Quit"),
                                      _("Shutdown the computer"));

        this._addEnterEvent(button, Lang.bind(this, this._favEnterEvent, button));
        button.actor.connect('leave-event', Lang.bind(this, this._favLeaveEvent, button));

        button.activate = Lang.bind(this, function() {
            this.menu.close();
            this._session.ShutdownRemote();
        });

        this.favoritesBox.add_actor(button.actor, { y_align: St.Align.END, y_fill: false });
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
markfilipak
Level 5
Level 5
Posts: 979
Joined: Sun Mar 10, 2013 8:08 pm

Re: Hide quit options? How?

Post by markfilipak »

smurphos wrote:
Mon May 27, 2019 12:13 am
You need to manually edit the applet's javascript to remove the system buttons.

I've not tested this on your specific ( & very old :roll: :wink: ) version of Cinnamon. but it should work.

1) Make a copy of the default applet to your local applet storage using the file manager or this terminal command.

Code: Select all

cp -R /usr/share/cinnamon/applets/menu@cinnamon.org ~/.local/share/cinnamon/applets
...
That sounds great, however...
'~/.local/share/cinnamon/applets/' exists, but is empty.

Here is a list of 'applet.js' files that do exist:

Code: Select all

/usr/share/cinnamon/applets/a11y@cinnamon.org/applet.js
/usr/share/cinnamon/applets/trash@cinnamon.org/applet.js
/usr/share/cinnamon/applets/panel-launchers@cinnamon.org/applet.js
/usr/share/cinnamon/applets/sound@cinnamon.org/applet.js
/usr/share/cinnamon/applets/separator@cinnamon.org/applet.js
/usr/share/cinnamon/applets/on-screen-keyboard@cinnamon.org/applet.js
/usr/share/cinnamon/applets/recent@cinnamon.org/applet.js
/usr/share/cinnamon/applets/xrandr@cinnamon.org/applet.js
/usr/share/cinnamon/applets/settings@cinnamon.org/applet.js
/usr/share/cinnamon/applets/settings-example@cinnamon.org/applet.js
/usr/share/cinnamon/applets/workspace-switcher@cinnamon.org/applet.js
/usr/share/cinnamon/applets/nvidia-prime@cinnamon.org/applet.js
/usr/share/cinnamon/applets/inhibit@cinnamon.org/applet.js
/usr/share/cinnamon/applets/spacer@cinnamon.org/applet.js
/usr/share/cinnamon/applets/network@cinnamon.org/applet.js
/usr/share/cinnamon/applets/notifications@cinnamon.org/applet.js
/usr/share/cinnamon/applets/power@cinnamon.org/applet.js
/usr/share/cinnamon/applets/systray@cinnamon.org/applet.js
/usr/share/cinnamon/applets/calendar@cinnamon.org/applet.js
/usr/share/cinnamon/applets/show-desktop@cinnamon.org/applet.js
/usr/share/cinnamon/applets/user@cinnamon.org/applet.js
/usr/share/cinnamon/applets/window-list@cinnamon.org/applet.js
/usr/share/cinnamon/applets/expo@cinnamon.org/applet.js
/usr/share/cinnamon/applets/slideshow@cinnamon.org/applet.js
/usr/share/cinnamon/applets/scale@cinnamon.org/applet.js
/usr/share/cinnamon/applets/keyboard@cinnamon.org/applet.js
/usr/share/cinnamon/applets/menu@cinnamon.org/applet.js
/usr/share/cinnamon/applets/windows-quick-list@cinnamon.org/applet.js
/usr/share/cinnamon/applets/removable-drives@cinnamon.org/applet.js
/usr/share/cinnamon/js/ui/applet.js
This one: '/usr/share/cinnamon/applets/menu@cinnamon.org/applet.js' contains a section that exactly matches.

I don't want to break anything but what do you think? Should I copy '/usr/share/cinnamon/applets/menu@cinnamon.org/applet.js' to '~/.local/share/cinnamon/applets/menu@cinnamon.org/applet.js'?

And how about simply commenting out the section instead of making a copy?
User avatar
smurphos
Level 17
Level 17
Posts: 7332
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher
Contact:

Re: Hide quit options? How?

Post by smurphos »

markfilipak wrote:
Mon May 27, 2019 3:58 am

That sounds great, however...
'~/.local/share/cinnamon/applets/' exists, but is empty.

----


This one: '/usr/share/cinnamon/applets/menu@cinnamon.org/applet.js' contains a section that exactly matches.

I don't want to break anything but what do you think? Should I copy '/usr/share/cinnamon/applets/menu@cinnamon.org/applet.js' to '~/.local/share/cinnamon/applets/menu@cinnamon.org/applet.js'?

And how about simply commenting out the section instead of making a copy?
It's empty after running the cp command? That's weird. Try this and report the output.

Code: Select all

cp -Rv /usr/share/cinnamon/applets/menu@cinnamon.org ~/.local/share/cinnamon/applets
You could edit the original applet directly, but I don't generally recommend doing that, as it can make it harder to recover from any editing mishaps so would suggest you get a copy of the whole menu@cinnamon.org folder and it's contents to ~/.local/share/cinnamon/applets/ before editing it there.
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
markfilipak
Level 5
Level 5
Posts: 979
Joined: Sun Mar 10, 2013 8:08 pm

Re: Hide quit options? How?

Post by markfilipak »

smurphos wrote:
Mon May 27, 2019 4:23 am

It's empty after running the cp command? That's weird. Try this and report the output.

Code: Select all

cp -Rv /usr/share/cinnamon/applets/menu@cinnamon.org ~/.local/share/cinnamon/applets
...

Code: Select all

mark@mark-VirtualBox ~ $ cp -Rv /usr/share/cinnamon/applets/menu@cinnamon.org ~/.local/share/cinnamon/applets
'/usr/share/cinnamon/applets/menu@cinnamon.org' -> '/home/mark/.local/share/cinnamon/applets/menu@cinnamon.org'
'/usr/share/cinnamon/applets/menu@cinnamon.org/applet.js' -> '/home/mark/.local/share/cinnamon/applets/menu@cinnamon.org/applet.js'
'/usr/share/cinnamon/applets/menu@cinnamon.org/settings-schema.json' -> '/home/mark/.local/share/cinnamon/applets/menu@cinnamon.org/settings-schema.json'
'/usr/share/cinnamon/applets/menu@cinnamon.org/metadata.json' -> '/home/mark/.local/share/cinnamon/applets/menu@cinnamon.org/metadata.json'
mark@mark-VirtualBox ~ $
PS: Oh, sorry. I didn't know you wanted me to copy the files. Oops. Now that they are there, I'll edit applets.js and comment out the section.
User avatar
smurphos
Level 17
Level 17
Posts: 7332
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher
Contact:

Re: Hide quit options? How?

Post by smurphos »

So the copy has worked.

The file to edit is in /home/mark/.local/share/cinnamon/applets/menu@cinnamon.org/applet.js

~ in the commands is expanded to /home/mark by the shell.
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
markfilipak
Level 5
Level 5
Posts: 979
Joined: Sun Mar 10, 2013 8:08 pm

Re: Hide quit options? How?

Post by markfilipak »

smurphos wrote:
Mon May 27, 2019 4:36 am
So the copy has worked.

The file to edit is in /home/mark/.local/share/cinnamon/applets/menu@cinnamon.org/applet.js

~ in the commands is expanded to /home/mark by the shell.
Yup! They're gone. Harah!

Thank YOU, smurphos !!

May I ask a couple of related question?
Can you point me to documentation for JS in Cinnamon? I've written ...probably 10-thousand, 20-thousand lines of js over the past 20 years.
What's the global object and what's its scope?
What's the run-time system?
How do I submit to the run-time?
What are the global objects, their properties, and methods?
Is there a DOM?
Of course, links to existing info will do.

Thanks again!
User avatar
smurphos
Level 17
Level 17
Posts: 7332
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher
Contact:

Re: Hide quit options? How?

Post by smurphos »

I'm not particularly au-fait with Cinnamon's CJS interpreter, and it's been a long time since I've done anything serious with javascript other than tweaks to Cinnamon. But I know it's not very well documented in itself.

However CJS is forked from Gnome3's version GJS which is better documented - https://gitlab.gnome.org/GNOME/gjs/wikis/home - most of the content here will be applicable.

You can also the review the contents of your /usr/share/cinnamon/js folder to see what's available to import into your own scripts to interact with the Cinnamon interface - start with /usr/share/cinnamon/js/ui/main.js.

Finally you can access a CJS command line directly from the terminal by typing cjs at the bash prompt to explore some of your other questions.
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
markfilipak
Level 5
Level 5
Posts: 979
Joined: Sun Mar 10, 2013 8:08 pm

Re: Hide quit options? How?

Post by markfilipak »

@smurphos

Congratulations on your 3500th posting. And thanks.
dnl
Level 2
Level 2
Posts: 53
Joined: Mon Dec 26, 2016 3:21 am

Re: Hide quit options? How?

Post by dnl »

markfilipak wrote:
Mon May 27, 2019 4:27 am
PS: Oh, sorry. I didn't know you wanted me to copy the files. Oops. Now that they are there, I'll edit applets.js and comment out the section.
From this comment I gather you copied all of the script files into your ~/.local/share/cinnamon/applets directory. SmurfOS suggested that you copy just the one file you want to change. Each file in your .local directory will take precedence over the corresponding file in the system-wide directory. Since you did not (yet) change any other file, you can remove them and allow the system-wide scripts to have effect.

I suggest removing any script from your .local directory that you haven't customized. If developers make future changes to the system-wide scripts, those changes would not be effective in your system because your .local scripts would be executed instead.
markfilipak
Level 5
Level 5
Posts: 979
Joined: Sun Mar 10, 2013 8:08 pm

Re: Hide quit options? How?

Post by markfilipak »

dnl wrote:
Wed May 29, 2019 4:35 pm
markfilipak wrote:
Mon May 27, 2019 4:27 am
PS: Oh, sorry. I didn't know you wanted me to copy the files. Oops. Now that they are there, I'll edit applets.js and comment out the section.
From this comment I gather you copied all of the script files into your ~/.local/share/cinnamon/applets directory. SmurfOS suggested that you copy just the one file you want to change. Each file in your .local directory will take precedence over the corresponding file in the system-wide directory. Since you did not (yet) change any other file, you can remove them and allow the system-wide scripts to have effect.

I suggest removing any script from your .local directory that you haven't customized. If developers make future changes to the system-wide scripts, those changes would not be effective in your system because your .local scripts would be executed instead.
Thank you for being vigilant and following up. What I ran was what SmurfOS suggested:

Code: Select all

cp -R /usr/share/cinnamon/applets/menu@cinnamon.org ~/.local/share/cinnamon/applets
I believe that only the '.js' and 2 '.json' files were copied. I commented out (/* */) the section that adds the 3 buttons I don't want. Thanks.
User avatar
smurphos
Level 17
Level 17
Posts: 7332
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher
Contact:

Re: Hide quit options? How?

Post by smurphos »

markfilipak wrote:
Wed May 29, 2019 4:46 pm
dnl wrote:
Wed May 29, 2019 4:35 pm
markfilipak wrote:
Mon May 27, 2019 4:27 am
PS: Oh, sorry. I didn't know you wanted me to copy the files. Oops. Now that they are there, I'll edit applets.js and comment out the section.
From this comment I gather you copied all of the script files into your ~/.local/share/cinnamon/applets directory. SmurfOS suggested that you copy just the one file you want to change.
Thank you for being vigilant and following up. What I ran was what SmurfOS suggested:

Code: Select all

cp -R /usr/share/cinnamon/applets/menu@cinnamon.org ~/.local/share/cinnamon/applets
I believe that only the '.js' and 2 '.json' files were copied. I commented out (/* */) the section that adds the 3 buttons I don't want. Thanks.
LOL, I'll have to find time to develop the expertise to make and distribute Smurf OS - it's got a nice ring to it... :)

Indeed the intention here was to copy the whole of the menu@cinnamon.org folder and it's contents to the local applet's folder, and if someone was planning any tweaks to other system applets, I'd recommend doing it the same way.

Should markfilipak's system ever receive a Cinnamon update (unlikely as it's quite an old cinnamon-version)) or he choose to update Mint versions and receives a new Cinnamon version that way he would be recommended to repeat this exercise - i.e. basically redo the edit but using the newer version of the menu applet as the base.
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
Post Reply

Return to “Cinnamon”