SOLVED Reorder panel launcher order (right-click menu)

Please post suggestions for improvement of Cinnamon on:
https://github.com/linuxmint/Cinnamon
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
arnad
Level 2
Level 2
Posts: 56
Joined: Sun Mar 26, 2017 1:59 pm

SOLVED Reorder panel launcher order (right-click menu)

Post by arnad »

Linux Mint 19 Cinnamon

Hello everyone,

when I right-click on the panel launchers (e.g. Firefox), the applications-specific functions (e.g. Open a New Window, Open a New Private Window) are all the way on top, with the general functions (Launch, Add, Edit, Remove, Preferences) being closer to the task bar. Is it possible to change this order? I am usually using the application-specific functions and would like them closer to the task bar for faster access.

Basically, I would like to change it from this:
current.png
to this:
wish.png
Greetings,

Arnad
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 3 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Hoser Rob
Level 20
Level 20
Posts: 11762
Joined: Sat Dec 15, 2012 8:57 am

Re: Reorder panel launcher order (right-click menu)

Post by Hoser Rob »

You don't say which DE version you're using but I've never heard of this in any Linux DE. Linux is highly configurable but all that stiuff about you being able to do anything you want in Linux ain't true. In any case I suspect such a feature would slow the machine down more than you clicking the right item so there wouldn't be any point anyway really.
For every complex problem there is an answer that is clear, simple, and wrong - H. L. Mencken
arnad
Level 2
Level 2
Posts: 56
Joined: Sun Mar 26, 2017 1:59 pm

Re: Reorder panel launcher order (right-click menu)

Post by arnad »

Edited the original post to include my version: Linux Mint 19 Cinnamon.
Hoser Rob wrote: Fri Nov 02, 2018 9:49 am In any case I suspect such a feature would slow the machine down more than you clicking the right item so there wouldn't be any point anyway really.
Why would it slow the machine? The order it is in currently must be configured in some file, so changing this should change the order, no? I am not averse to digging into config files or recompiling stuff if necessary.
User avatar
smurphos
Level 18
Level 18
Posts: 8501
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

Re: Reorder panel launcher order (right-click menu)

Post by smurphos »

Hi - this is a relatively straightforward edit of the panel-launcher applet's javascript.

1) Make a copy of the original applet in your local users applet folder
cp -r /usr/share/cinnamon/applets/panel-launchers@cinnamon.org ~/.local/share/cinnamon/applets

2) Open applet.js in a text editor.
xed ~/.local/share/cinnamon/applets/panel-launchers@cinnamon.org/applet.js

3) Navigate to this section and reorder as you wish. Save and then restart Cinnamon with Ctrl-Alt-Esc

Original...

Code: Select all

class PanelAppLauncherMenu extends Applet.AppletPopupMenu {
    constructor(launcher, orientation) {
        super(launcher, orientation);
        this._launcher = launcher;

        let appinfo = this._launcher.getAppInfo();

        this._actions = appinfo.list_actions();
        if (this._actions.length > 0) {
            for (let i = 0; i < this._actions.length; i++) {
                let actionName = this._actions[i];
                this.addAction(appinfo.get_action_name(actionName), Lang.bind(this, this._launchAction, actionName));
            }

            this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
        }

        let item = new PopupMenu.PopupIconMenuItem(_("Launch"), "media-playback-start", St.IconType.SYMBOLIC);
        item.connect('activate', Lang.bind(this, this._onLaunchActivate));
        this.addMenuItem(item);

        item = new PopupMenu.PopupIconMenuItem(_("Add"), "list-add", St.IconType.SYMBOLIC);
        item.connect('activate', Lang.bind(this, this._onAddActivate));
        this.addMenuItem(item);

        item = new PopupMenu.PopupIconMenuItem(_("Edit"), "document-properties", St.IconType.SYMBOLIC);
        item.connect('activate', Lang.bind(this, this._onEditActivate));
        this.addMenuItem(item);

        item = new PopupMenu.PopupIconMenuItem(_("Remove"), "window-close", St.IconType.SYMBOLIC);
        item.connect('activate', Lang.bind(this, this._onRemoveActivate));
        this.addMenuItem(item);

        this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());

        let subMenu = new PopupMenu.PopupSubMenuMenuItem(_("Preferences"));
        this.addMenuItem(subMenu);

        item = new PopupMenu.PopupIconMenuItem(_("About..."), "dialog-question", St.IconType.SYMBOLIC);
        item.connect('activate', Lang.bind(this._launcher._applet, this._launcher._applet.openAbout));
        subMenu.menu.addMenuItem(item);

        item = new PopupMenu.PopupIconMenuItem(_("Configure..."), "system-run", St.IconType.SYMBOLIC);
        item.connect('activate', Lang.bind(this._launcher._applet, this._launcher._applet.configureApplet));
        subMenu.menu.addMenuItem(item);

        item = new PopupMenu.PopupIconMenuItem(_("Remove '%s'").format(_("Panel launchers")), "edit-delete", St.IconType.SYMBOLIC);
        item.connect('activate', Lang.bind(this, function() {
            AppletManager._removeAppletFromPanel(this._launcher._applet._uuid, this._launcher._applet.instance_id);
        }));
        subMenu.menu.addMenuItem(item);
    }
E.g to move the application specific settings to the bottom of the list it would be

Code: Select all

class PanelAppLauncherMenu extends Applet.AppletPopupMenu {
    constructor(launcher, orientation) {
        super(launcher, orientation);
        this._launcher = launcher;

        let appinfo = this._launcher.getAppInfo();

        let item = new PopupMenu.PopupIconMenuItem(_("Launch"), "media-playback-start", St.IconType.SYMBOLIC);
        item.connect('activate', Lang.bind(this, this._onLaunchActivate));
        this.addMenuItem(item);

        item = new PopupMenu.PopupIconMenuItem(_("Add"), "list-add", St.IconType.SYMBOLIC);
        item.connect('activate', Lang.bind(this, this._onAddActivate));
        this.addMenuItem(item);

        item = new PopupMenu.PopupIconMenuItem(_("Edit"), "document-properties", St.IconType.SYMBOLIC);
        item.connect('activate', Lang.bind(this, this._onEditActivate));
        this.addMenuItem(item);

        item = new PopupMenu.PopupIconMenuItem(_("Remove"), "window-close", St.IconType.SYMBOLIC);
        item.connect('activate', Lang.bind(this, this._onRemoveActivate));
        this.addMenuItem(item);

        this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());

        let subMenu = new PopupMenu.PopupSubMenuMenuItem(_("Preferences"));
        this.addMenuItem(subMenu);

        item = new PopupMenu.PopupIconMenuItem(_("About..."), "dialog-question", St.IconType.SYMBOLIC);
        item.connect('activate', Lang.bind(this._launcher._applet, this._launcher._applet.openAbout));
        subMenu.menu.addMenuItem(item);

        item = new PopupMenu.PopupIconMenuItem(_("Configure..."), "system-run", St.IconType.SYMBOLIC);
        item.connect('activate', Lang.bind(this._launcher._applet, this._launcher._applet.configureApplet));
        subMenu.menu.addMenuItem(item);

        item = new PopupMenu.PopupIconMenuItem(_("Remove '%s'").format(_("Panel launchers")), "edit-delete", St.IconType.SYMBOLIC);
        item.connect('activate', Lang.bind(this, function() {
            AppletManager._removeAppletFromPanel(this._launcher._applet._uuid, this._launcher._applet.instance_id);
        }));
        subMenu.menu.addMenuItem(item);
        
        this._actions = appinfo.list_actions();
        if (this._actions.length > 0) {
            for (let i = 0; i < this._actions.length; i++) {
                let actionName = this._actions[i];
                this.addAction(appinfo.get_action_name(actionName), Lang.bind(this, this._launchAction, actionName));
            }

            this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
        }
    }
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
arnad
Level 2
Level 2
Posts: 56
Joined: Sun Mar 26, 2017 1:59 pm

Re: Reorder panel launcher order (right-click menu)

Post by arnad »

That worked exactly as advertised! Thank you very much. I was even able to add a separator between preferences and the application-specific options.
Locked

Return to “Cinnamon”