@@ -1681,19 +1681,19 @@ PanelCorner.prototype = {
1681
1681
}
1682
1682
} ; // end of panel corner
1683
1683
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 ) ;
1686
1686
}
1687
1687
1688
1688
SettingsLauncher . prototype = {
1689
1689
__proto__ : PopupMenu . PopupIconMenuItem . prototype ,
1690
1690
1691
- _init : function ( label , keyword , icon ) {
1691
+ _init : function ( label , keyword , icon , command ) {
1692
1692
PopupMenu . PopupIconMenuItem . prototype . _init . call ( this , label , icon , St . IconType . SYMBOLIC ) ;
1693
1693
1694
1694
this . _keyword = keyword ;
1695
1695
this . connect ( 'activate' , Lang . bind ( this , function ( ) {
1696
- Util . spawnCommandLine ( "cinnamon-settings " + this . _keyword ) ;
1696
+ Util . spawnCommandLine ( command + " " + this . _keyword ) ;
1697
1697
} ) ) ;
1698
1698
} ,
1699
1699
} ;
@@ -1711,12 +1711,13 @@ PanelContextMenu.prototype = {
1711
1711
this . actor . hide ( ) ;
1712
1712
this . panelId = panelId ;
1713
1713
1714
- let moreSettingsMenuItem = new SettingsLauncher ( _ ( "Panel settings" ) , "panel " + panelId , "emblem-system" ) ;
1714
+ let moreSettingsMenuItem = new SettingsLauncher ( _ ( "Panel settings" ) , "panel " + panelId , "emblem-system" , "cinnamon-settings" ) ;
1715
1715
this . addMenuItem ( moreSettingsMenuItem ) ;
1716
1716
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" ) ;
1718
1718
this . addMenuItem ( applet_settings_item ) ;
1719
1719
1720
+
1720
1721
let menu = this ;
1721
1722
1722
1723
menu . addMenuItem ( new PopupMenu . PopupSeparatorMenuItem ( ) ) ; // separator line
@@ -1816,10 +1817,45 @@ PanelContextMenu.prototype = {
1816
1817
confirm . open ( ) ;
1817
1818
} ) ;
1818
1819
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
+
1819
1831
menu . addMenuItem ( new PopupMenu . PopupSeparatorMenuItem ( ) ) ; // separator line
1820
1832
menu . addMenuItem ( menu . troubleshootItem ) ;
1821
1833
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 ;
1823
1859
} ,
1824
1860
1825
1861
open : function ( animate ) {
0 commit comments