Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds first system monitor app to panel right click menu if it exists #10352

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions js/ui/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ const PANEL_ZONE_ICON_SIZES = "panel-zone-icon-sizes";
const PANEL_ZONE_SYMBOLIC_ICON_SIZES = "panel-zone-symbolic-icon-sizes";
const PANEL_ZONE_TEXT_SIZES = "panel-zone-text-sizes";

/*** List of system monitor apps that can be displayed on right click of panel "COMMAND-NAME": "COMMAND/LOCATION" */
const SYSTEM_MONITOR_APPS = {"gnome-system-monitor": "/usr/bin/gnome-system-monitor",
"mate-system-monitor": "/usr/bin/mate-system-monitor",
"xfce4-taskmanager": "/usr/bin/xfce4-taskmanager",
"lxtask": "/usr/bin/lxtask"
};

const Direction = {
LEFT : 0,
RIGHT : 1
Expand Down Expand Up @@ -1530,19 +1537,19 @@ PanelCorner.prototype = {
}
}; // end of panel corner

function SettingsLauncher(label, keyword, icon) {
this._init(label, keyword, icon);
function SettingsLauncher(label, keyword, icon, command) {
this._init(label, keyword, icon, command);
}

SettingsLauncher.prototype = {
__proto__: PopupMenu.PopupIconMenuItem.prototype,

_init: function (label, keyword, icon) {
_init: function (label, keyword, icon, command) {
PopupMenu.PopupIconMenuItem.prototype._init.call(this, label, icon, St.IconType.SYMBOLIC);

this._keyword = keyword;
this.connect('activate', Lang.bind(this, function() {
Util.spawnCommandLine("cinnamon-settings " + this._keyword);
Util.spawnCommandLine(command + this._keyword);
}));
},
};
Expand All @@ -1560,10 +1567,10 @@ PanelContextMenu.prototype = {
this.actor.hide();
this.panelId = panelId;

let moreSettingsMenuItem = new SettingsLauncher(_("Panel settings"), "panel " + panelId, "emblem-system");
let moreSettingsMenuItem = new SettingsLauncher(_("Panel settings"), "panel " + panelId, "emblem-system", "cinnamon-settings ");
this.addMenuItem(moreSettingsMenuItem);

let applet_settings_item = new SettingsLauncher(_("Applets"), "applets panel" + panelId, "application-x-addon");
let applet_settings_item = new SettingsLauncher(_("Applets"), "applets panel" + panelId, "application-x-addon", "cinnamon-settings ");
this.addMenuItem(applet_settings_item);

let menu = this;
Expand Down Expand Up @@ -1664,7 +1671,17 @@ PanelContextMenu.prototype = {
menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); // separator line
menu.addMenuItem(menu.troubleshootItem);

this.addMenuItem(new SettingsLauncher(_("System Settings"), "", "preferences-desktop"));
menu.addMenuItem(new SettingsLauncher(_("System Settings"), "", "preferences-desktop", "cinnamon-settings "));

// finds a valid system monitor/task manager app from the dict SYSTEM_MONITOR_APPS and adds the first valid one to the menu
for (var key in SYSTEM_MONITOR_APPS) {
let file = Gio.file_new_for_path(SYSTEM_MONITOR_APPS[key]);
if (file.query_exists(null)) {
menu.addMenuItem(new SettingsLauncher(_("System Monitor"), "", "utilities-system-monitor", key));
break;
}
}

},

open: function(animate) {
Expand Down