Skip to content

Commit bee6e72

Browse files
committed
Add System Monitor to right click panel when one is found
and update system settings to use symbolic icon
1 parent fa9911d commit bee6e72

File tree

1 file changed

+43
-7
lines changed

1 file changed

+43
-7
lines changed

js/ui/panel.js

+43-7
Original file line numberDiff line numberDiff line change
@@ -1681,19 +1681,19 @@ PanelCorner.prototype = {
16811681
}
16821682
}; // end of panel corner
16831683

1684-
function SettingsLauncher(label, keyword, icon) {
1685-
this._init(label, keyword, icon);
1684+
function SettingsLauncher(label, keyword, icon, command) {
1685+
this._init(label, keyword, icon, command);
16861686
}
16871687

16881688
SettingsLauncher.prototype = {
16891689
__proto__: PopupMenu.PopupIconMenuItem.prototype,
16901690

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

16941694
this._keyword = keyword;
16951695
this.connect('activate', Lang.bind(this, function() {
1696-
Util.spawnCommandLine("cinnamon-settings " + this._keyword);
1696+
Util.spawnCommandLine(command + " " + this._keyword);
16971697
}));
16981698
},
16991699
};
@@ -1711,12 +1711,13 @@ PanelContextMenu.prototype = {
17111711
this.actor.hide();
17121712
this.panelId = panelId;
17131713

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

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

1720+
17201721
let menu = this;
17211722

17221723
menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); // separator line
@@ -1816,10 +1817,45 @@ PanelContextMenu.prototype = {
18161817
confirm.open();
18171818
});
18181819

1820+
menu.troubleshootItem.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
1821+
1822+
// Add the System Monitor launcher to the troubleshoot menu
1823+
let systemMonitorInfo = this._findFirstSystemMonitor();
1824+
if (systemMonitorInfo) {
1825+
menu.troubleshootItem.menu.addAction(_(systemMonitorInfo.name), function(event) {
1826+
let settingsLauncher = new SettingsLauncher(systemMonitorInfo.name, "", "", systemMonitorInfo.command);
1827+
settingsLauncher.activate();
1828+
});
1829+
}
1830+
18191831
menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); // separator line
18201832
menu.addMenuItem(menu.troubleshootItem);
18211833

1822-
this.addMenuItem(new SettingsLauncher(_("System Settings"), "", "preferences-desktop"));
1834+
this.addMenuItem(new SettingsLauncher(_("System Settings"), "", "system-run", "cinnamon-settings"));
1835+
},
1836+
1837+
_findFirstSystemMonitor: function() {
1838+
let appInfoList = Gio.AppInfo.get_all();
1839+
const requiredCategories = ['System', 'Monitor'];
1840+
const excludedCategories = ['Utility', 'TerminalEmulator', 'RemoteAccess', 'Development', 'Office', 'Network'];
1841+
for (let appInfo of appInfoList) {
1842+
if (appInfo.should_show()) {
1843+
let categories = appInfo.get_categories();
1844+
//Finds the first available system monitor based on category filters
1845+
if (
1846+
categories &&
1847+
requiredCategories.every(cat => categories.includes(cat)) &&
1848+
!excludedCategories.some(cat => categories.includes(cat))) {
1849+
// Return the app name, icon, and executable command
1850+
return {
1851+
name: appInfo.get_display_name(),
1852+
icon: appInfo.get_icon().to_string(),
1853+
command: appInfo.get_executable()
1854+
};
1855+
}
1856+
}
1857+
}
1858+
return null;
18231859
},
18241860

18251861
open: function(animate) {

0 commit comments

Comments
 (0)