├── .gitignore ├── Controllers ├── XRGAppDelegate.h ├── XRGAppDelegate.m ├── XRGGraphWindow.h ├── XRGGraphWindow.m ├── XRGPrefController.h ├── XRGPrefController.m ├── XRGSensorViewController.h └── XRGSensorViewController.m ├── Data Miners ├── APSL │ ├── APSL.txt │ ├── AppleHIDUsageTables.h │ ├── IOHIDEventTypes.h │ ├── SMCInterface.h │ ├── SMCInterface.m │ ├── SMCSensorGroup.h │ ├── SMCSensorGroup.m │ ├── SMCSensors.h │ ├── SMCSensors.m │ ├── XRGAppleSiliconSensorMiner.h │ └── XRGAppleSiliconSensorMiner.m ├── XRGBatteryMiner.h ├── XRGBatteryMiner.m ├── XRGCPUMiner.h ├── XRGCPUMiner.m ├── XRGGPUMiner.h ├── XRGGPUMiner.m ├── XRGMemoryMiner.h ├── XRGMemoryMiner.m ├── XRGNetMiner.h ├── XRGNetMiner.m ├── XRGProcessMiner.h ├── XRGProcessMiner.m ├── XRGTemperatureMiner.h └── XRGTemperatureMiner.m ├── Graph Views ├── XRGBackgroundView.h ├── XRGBackgroundView.m ├── XRGBatteryView.h ├── XRGBatteryView.m ├── XRGCPUView.h ├── XRGCPUView.m ├── XRGDiskView.h ├── XRGDiskView.m ├── XRGGPUView.h ├── XRGGPUView.m ├── XRGGenericView.h ├── XRGGenericView.m ├── XRGMemoryView.h ├── XRGMemoryView.m ├── XRGNetView.h ├── XRGNetView.m ├── XRGStockView.h ├── XRGStockView.m ├── XRGTemperatureView.h ├── XRGTemperatureView.m ├── XRGWeatherView.h └── XRGWeatherView.m ├── LICENSE ├── Other Sources ├── XRG-Prefix.pch ├── XRGPlugin.h ├── definitions.h ├── main.m └── ppp_msg.h ├── README.md ├── Resources ├── InfoPlist.strings ├── MainMenu.nib │ ├── designable.nib │ └── keyedobjects.nib ├── Online Help │ ├── CVS │ │ ├── Entries │ │ ├── Repository │ │ └── Root │ ├── Online Help idx │ ├── help_icon.gif │ ├── images │ │ ├── CVS │ │ │ ├── Entries │ │ │ ├── Repository │ │ │ └── Root │ │ ├── battery.gif │ │ ├── cpu.gif │ │ ├── disk.gif │ │ ├── mem.gif │ │ ├── net.gif │ │ ├── prefs_color.gif │ │ ├── prefs_cpu.gif │ │ ├── prefs_disk.gif │ │ ├── prefs_general.gif │ │ ├── prefs_memory.gif │ │ ├── prefs_network.gif │ │ ├── prefs_stock.gif │ │ ├── prefs_temperature.jpg │ │ ├── prefs_weather.gif │ │ ├── stock.gif │ │ ├── temperature.gif │ │ ├── weather.gif │ │ ├── xrg_icon3.jpg │ │ └── xrg_icon4.png │ ├── index.html │ ├── modules.html │ └── preferences.html ├── Preferences-Appearance.tiff ├── Preferences-CPU.tiff ├── Preferences-Disk.tiff ├── Preferences-General.tiff ├── Preferences-Memory.tiff ├── Preferences-Network.tiff ├── Preferences-Stocks.tiff ├── Preferences-Temperature.tiff ├── Preferences-Weather.tiff ├── Preferences.nib │ ├── designable.nib │ ├── keyedobjects-101300.nib │ └── keyedobjects.nib ├── SMCSensorNames.plist ├── Sensors.xib ├── icon.icns └── xtf.icns ├── Utility ├── NSStringUtil.h ├── NSStringUtil.m ├── XRGCommon.h ├── XRGCommon.m ├── XRGDataSet.h ├── XRGDataSet.m ├── XRGFlippedView.h ├── XRGFlippedView.m ├── XRGModule.h ├── XRGModule.m ├── XRGModuleManager.h ├── XRGModuleManager.m ├── XRGNonInteractableTextField.h ├── XRGNonInteractableTextField.m ├── XRGSettings.h ├── XRGSettings.m ├── XRGStatsManager.h ├── XRGStatsManager.m ├── XRGStock.h ├── XRGStock.m ├── XRGURL.h └── XRGURL.m ├── XRG-Info.plist ├── XRG.entitlements └── XRG.xcodeproj └── project.pbxproj /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | build/* 3 | *.pbxuser 4 | !default.pbxuser 5 | *.mode1v3 6 | !default.mode1v3 7 | *.mode2v3 8 | !default.mode2v3 9 | *.perspectivev3 10 | !default.perspectivev3 11 | *.xcworkspace 12 | !default.xcworkspace 13 | xcuserdata 14 | profile 15 | *.moved-aside 16 | .DS_Store 17 | -------------------------------------------------------------------------------- /Controllers/XRGAppDelegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGAppDelegate.h 25 | // 26 | 27 | #import 28 | #import "XRGPrefController.h" 29 | #import "XRGSensorViewController.h" 30 | #import "XRGSettings.h" 31 | #import "XRGModuleManager.h" 32 | 33 | @class XRGGraphWindow; 34 | 35 | @interface XRGAppDelegate : NSObject 36 | 37 | @property (strong) IBOutlet XRGPrefController *prefController; 38 | @property (strong) IBOutlet XRGGraphWindow *xrgGraphWindow; 39 | @property (strong) IBOutlet NSWindow *sensorWindow; 40 | @property (strong) IBOutlet XRGSensorViewController *sensorViewController; 41 | 42 | - (IBAction)showPrefs:(id)sender; 43 | - (void)showPrefsWithPanel:(NSString *)panelName; 44 | - (IBAction)openSensorWindow:(id)sender; 45 | 46 | - (XRGSettings *)appSettings; 47 | - (XRGModuleManager *)moduleManager; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /Controllers/XRGAppDelegate.m: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGAppDelegate.m 25 | // 26 | 27 | #import "XRGAppDelegate.h" 28 | #import "XRGGraphWindow.h" 29 | 30 | @implementation XRGAppDelegate 31 | 32 | - (IBAction) showPrefs:(id)sender { 33 | if(!self.prefController) [NSBundle loadNibNamed:@"Preferences.nib" owner:self]; 34 | 35 | // Refresh the temperature settings to pick up any new sensors. 36 | [self.prefController setUpTemperaturePanel]; 37 | [[self.prefController window] makeKeyAndOrderFront:sender]; 38 | } 39 | 40 | - (void) showPrefsWithPanel:(NSString *)panelName { 41 | if (!self.prefController) [NSBundle loadNibNamed:@"Preferences.nib" owner:self]; 42 | 43 | // Refresh the temperature settings to pick up any new sensors. 44 | [self.prefController setUpTemperaturePanel]; 45 | [[self.prefController window] makeKeyAndOrderFront:self]; 46 | 47 | if ([panelName isEqualTo:@"CPU"]) [self.prefController CPU:self]; 48 | else if ([panelName isEqualTo:@"RAM"]) [self.prefController RAM:self]; 49 | else if ([panelName isEqualTo:@"Temperature"]) [self.prefController Temperature:self]; 50 | else if ([panelName isEqualTo:@"Network"]) [self.prefController Network:self]; 51 | else if ([panelName isEqualTo:@"Disk"]) [self.prefController Disk:self]; 52 | else if ([panelName isEqualTo:@"Weather"]) [self.prefController Weather:self]; 53 | else if ([panelName isEqualTo:@"Stocks"]) [self.prefController Stocks:self]; 54 | else if ([panelName isEqualTo:@"General"]) [self.prefController General:self]; 55 | else if ([panelName isEqualTo:@"Appearance"]) [self.prefController Colors:self]; 56 | } 57 | 58 | - (IBAction)openSensorWindow:(id)sender { 59 | if (!self.sensorViewController) { 60 | [NSBundle.mainBundle loadNibNamed:@"Sensors" owner:self topLevelObjects:nil]; 61 | } 62 | 63 | [self.sensorWindow setLevel:NSNormalWindowLevel]; 64 | [self.sensorWindow makeKeyAndOrderFront:self]; 65 | [[NSUserDefaults standardUserDefaults] setBool:YES forKey:XRG_showSensorWindow]; 66 | } 67 | 68 | - (BOOL)windowShouldClose:(NSWindow *)sender { 69 | if (sender == self.sensorWindow) { 70 | [[NSUserDefaults standardUserDefaults] setBool:NO forKey:XRG_showSensorWindow]; 71 | } 72 | 73 | return YES; 74 | } 75 | 76 | - (void)changeFont:(id)sender { 77 | NSFont *oldFont = [[self.xrgGraphWindow appSettings] graphFont]; 78 | NSFont *newFont = [sender convertFont:oldFont]; 79 | if (oldFont == newFont) return; 80 | [[self.xrgGraphWindow appSettings] setGraphFont:newFont]; 81 | [[self.xrgGraphWindow moduleManager] graphFontChanged]; 82 | 83 | return; 84 | } 85 | 86 | // Cleanup when the application exits caused by a restart or logout 87 | - (void)NSWorkSpaceWillPowerOffNotification:(NSNotification *)aNotification { 88 | [self.xrgGraphWindow cleanupBeforeExiting]; 89 | } 90 | 91 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { 92 | [self.xrgGraphWindow.moduleManager windowChangedToSize:self.xrgGraphWindow.frame.size]; 93 | 94 | if ([[NSUserDefaults standardUserDefaults] boolForKey:XRG_windowIsMinimized]) { 95 | // minimize the window. 96 | [self.xrgGraphWindow.backgroundView minimizeWindow]; 97 | [self.xrgGraphWindow.backgroundView setClickedMinimized:YES]; 98 | } 99 | 100 | if ([[NSUserDefaults standardUserDefaults] boolForKey:XRG_showSensorWindow]) { 101 | [self openSensorWindow:self]; 102 | } 103 | 104 | // This is an ugly hack, but we were running into an issue where the menubar wouldn't be selectable at launch until switching to another app and back to XRG (issue exists as of macOS 10.15). This will perform that programmatically, and switches to the Dock so the user doesn't notice any UI changes. 105 | [[[NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.apple.dock"] firstObject] activateWithOptions:0]; 106 | dispatch_async(dispatch_get_main_queue(), ^{ 107 | [NSApp activateIgnoringOtherApps:YES]; 108 | }); 109 | } 110 | 111 | // Cleanup when the application is quit by the user. 112 | - (void)applicationWillTerminate:(NSNotification *)aNotification { 113 | [self.xrgGraphWindow cleanupBeforeExiting]; 114 | } 115 | 116 | - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename { 117 | if ([filename length] == 0) return NO; 118 | 119 | NSData *themeData = [NSData dataWithContentsOfFile:filename]; 120 | 121 | if ([themeData length] == 0) { 122 | NSRunInformationalAlertPanel(@"Error", @"The theme file dragged is not a valid theme file.", @"OK", nil, nil); 123 | } 124 | 125 | NSString *error = nil; 126 | NSPropertyListFormat format; 127 | NSDictionary *themeDictionary = [NSPropertyListSerialization propertyListFromData:themeData 128 | mutabilityOption:NSPropertyListImmutable 129 | format:&format 130 | errorDescription:&error]; 131 | 132 | if (!themeDictionary) { 133 | NSRunInformationalAlertPanel(@"Error", @"The theme file dragged is not a valid theme file.", @"OK", nil, nil); 134 | NSLog(@"%@", error); 135 | } 136 | else { 137 | [self.xrgGraphWindow.appSettings readXTFDictionary:themeDictionary]; 138 | [self.xrgGraphWindow display]; 139 | } 140 | 141 | [self.prefController setUpColorPanel]; 142 | 143 | return YES; 144 | } 145 | 146 | - (XRGSettings *)appSettings { 147 | return [self.xrgGraphWindow appSettings]; 148 | } 149 | 150 | - (XRGModuleManager *)moduleManager { 151 | return [self.xrgGraphWindow moduleManager]; 152 | } 153 | 154 | @end 155 | -------------------------------------------------------------------------------- /Controllers/XRGGraphWindow.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGGraphWindow.h 25 | // 26 | 27 | #import 28 | #import "XRGCPUView.h" 29 | #import "XRGNetView.h" 30 | #import "XRGDiskView.h" 31 | #import "XRGMemoryView.h" 32 | #import "XRGWeatherView.h" 33 | #import "XRGStockView.h" 34 | #import "XRGBatteryView.h" 35 | #import "XRGGPUView.h" 36 | #import "XRGTemperatureView.h" 37 | #import "XRGBackgroundView.h" 38 | #import "XRGSettings.h" 39 | #import "XRGModuleManager.h" 40 | 41 | @interface XRGGraphWindow : NSWindow 42 | 43 | @property int borderWidth; 44 | //@property NSSize minSize; 45 | @property BOOL minimized; 46 | 47 | // Timers 48 | @property NSTimer *min30Timer; 49 | @property NSTimer *min5Timer; 50 | @property NSTimer *graphTimer; 51 | @property NSTimer *fastTimer; 52 | 53 | // Settings 54 | @property NSFontManager *fontManager; 55 | 56 | // Outlets 57 | @property IBOutlet id preferenceWindow; 58 | @property IBOutlet XRGAppDelegate *controller; 59 | 60 | @property XRGURL *xrgCheckURL; 61 | 62 | @property XRGSettings *appSettings; 63 | @property XRGModuleManager *moduleManager; 64 | 65 | @property XRGCPUView *cpuView; 66 | @property XRGGPUView *gpuView; 67 | @property XRGNetView *netView; 68 | @property XRGDiskView *diskView; 69 | @property XRGMemoryView *memoryView; 70 | @property XRGWeatherView *weatherView; 71 | @property XRGStockView *stockView; 72 | @property XRGBatteryView *batteryView; 73 | @property XRGTemperatureView *temperatureView; 74 | @property (nonatomic) IBOutlet id backgroundView; 75 | 76 | @property BOOL draggingWindow; 77 | @property NSPoint originAtDragStart; 78 | @property NSPoint dragStart; 79 | 80 | // Initialization 81 | + (void)initialize; 82 | + (NSMutableDictionary*)getDefaultPrefs; 83 | - (void)setupSettingsFromDictionary:(NSDictionary *) defs; 84 | - (bool)systemJustWokeUp; 85 | - (void)setSystemJustWokeUp:(bool)yesNo; 86 | - (void)checkServerForUpdates; 87 | - (void)checkServerForUpdatesPostProcess; 88 | - (bool)isVersion:(NSString *)latestVersion laterThanVersion:(NSString *)currentVersion; 89 | - (XRGSettings *)appSettings; 90 | - (XRGModuleManager *)moduleManager; 91 | 92 | // Timer methods 93 | - (void)initTimers; 94 | - (void)min30Update:(NSTimer *)aTimer; 95 | - (void)min5Update:(NSTimer *)aTimer; 96 | - (void)graphUpdate:(NSTimer *)aTimer; 97 | - (void)fastUpdate:(NSTimer *)aTimer; 98 | 99 | // Methods that set up module references 100 | - (void)setBackgroundView:(id)background; 101 | 102 | // Actions 103 | - (IBAction)setShowCPUGraph:(id)sender; 104 | - (IBAction)setShowGPUGraph:(id)sender; 105 | - (IBAction)setShowNetGraph:(id)sender; 106 | - (IBAction)setShowDiskGraph:(id)sender; 107 | - (IBAction)setShowMemoryGraph:(id)sender; 108 | - (IBAction)setShowWeatherGraph:(id)sender; 109 | - (IBAction)setShowStockGraph:(id)sender; 110 | - (IBAction)setShowBatteryGraph:(id)sender; 111 | - (IBAction)setShowTemperatureGraph:(id)sender; 112 | - (IBAction)setBorderWidthAction:(id)sender; 113 | - (IBAction)setGraphOrientation:(id)sender; 114 | - (IBAction)setAntiAliasing:(id)sender; 115 | - (IBAction)setGraphRefreshActionPart2:(id)sender; 116 | - (IBAction)setWindowLevel:(id)sender; 117 | - (IBAction)setStickyWindow:(id)sender; 118 | - (IBAction)setCheckForUpdates:(id)sender; 119 | - (IBAction)setDropShadow:(id)sender; 120 | - (IBAction)setShowTotalBandwidthSinceBoot:(id)sender; 121 | - (IBAction)setShowTotalBandwidthSinceLoad:(id)sender; 122 | - (IBAction)setWindowTitle:(id)sender; 123 | - (IBAction)setAutoExpandGraph:(id)sender; 124 | - (IBAction)setForegroundWhenExpanding:(id)sender; 125 | - (IBAction)setShowSummary:(id)sender; 126 | - (IBAction)setMinimizeUpDown:(id)sender; 127 | 128 | - (IBAction)setObjectsToColor:(id)sender; 129 | - (IBAction)setObjectsToTransparency:(id)sender; 130 | 131 | - (IBAction)setFastCPUUsageCheckbox:(id)sender; 132 | - (IBAction)setSeparateCPUColor:(id)sender; 133 | - (IBAction)setShowLoadAverage:(id)sender; 134 | - (IBAction)setShowCPUTemperature:(id)sender; 135 | - (IBAction)setCPUTemperatureUnits:(id)sender; 136 | - (IBAction)setCPUShowAverageUsage:(id)sender; 137 | - (IBAction)setCPUShowUptime:(id)sender; 138 | 139 | - (IBAction)setMemoryCheckbox:(id)sender; 140 | 141 | - (IBAction)setTempUnits:(id)sender; 142 | - (IBAction)setTempFG1Location:(NSMenuItem *)sender; 143 | - (IBAction)setTempFG2Location:(NSMenuItem *)sender; 144 | - (IBAction)setTempFG3Location:(NSMenuItem *)sender; 145 | 146 | - (IBAction)setNetGraphMode:(id)sender; 147 | - (IBAction)setNetworkInterface:(id)sender; 148 | 149 | - (IBAction)setDiskGraphMode:(id)sender; 150 | 151 | - (IBAction)setICAO:(id)sender; 152 | - (IBAction)setSecondaryWeatherGraph:(id)sender; 153 | - (IBAction)setTemperatureUnits:(id)sender; 154 | - (IBAction)setDistanceUnits:(id)sender; 155 | - (IBAction)setPressureUnits:(id)sender; 156 | 157 | - (IBAction)setStockSymbols:(id)sender; 158 | - (IBAction)setStockGraphTimeFrame:(id)sender; 159 | - (IBAction)setStockShowChange:(id)sender; 160 | - (IBAction)setShowDJIA:(id)sender; 161 | 162 | // Action helpers 163 | - (void)setWindowLevelHelper:(NSInteger)index; 164 | - (NSColor *)colorForTag:(NSInteger)aTag; 165 | - (float)transparencyForTag:(NSInteger)aTag; 166 | - (void)checkWindowSize; 167 | 168 | - (void)cleanupBeforeExiting; 169 | 170 | @end 171 | -------------------------------------------------------------------------------- /Controllers/XRGPrefController.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // PrefController.h 25 | // 26 | 27 | #import 28 | #import "XRGTemperatureMiner.h" 29 | 30 | @class XRGGraphWindow; 31 | 32 | @interface XRGPrefController : NSObject { 33 | // toolbar objects 34 | NSToolbar *toolbar; 35 | NSMutableDictionary *toolbarItems; 36 | NSView *currentView; 37 | IBOutlet NSView *GeneralPrefView; 38 | IBOutlet NSView *ColorPrefView; 39 | IBOutlet NSView *CPUPrefView; 40 | IBOutlet NSView *MemoryPrefView; 41 | IBOutlet NSView *TemperaturePrefView; 42 | IBOutlet NSView *NetworkPrefView; 43 | IBOutlet NSView *DiskPrefView; 44 | IBOutlet NSView *WeatherPrefView; 45 | IBOutlet NSView *StockPrefView; 46 | 47 | IBOutlet NSWindow *window; 48 | 49 | IBOutlet id borderWidthSlider; 50 | IBOutlet id showCPUGraph; 51 | IBOutlet id showGPUGraph; 52 | IBOutlet id showMemoryGraph; 53 | IBOutlet id showBatteryGraph; 54 | IBOutlet id showTemperatureGraph; 55 | IBOutlet id showNetGraph; 56 | IBOutlet id showDiskGraph; 57 | IBOutlet id showWeatherGraph; 58 | IBOutlet id showStockGraph; 59 | IBOutlet id graphOrientation; 60 | IBOutlet id enableAntiAliasing; 61 | IBOutlet id graphRefreshValue; 62 | IBOutlet id graphRefreshText; 63 | IBOutlet id windowLevel; 64 | IBOutlet id stickyWindow; 65 | IBOutlet id checkForUpdates; 66 | IBOutlet id dropShadow; 67 | IBOutlet id windowTitle; 68 | IBOutlet id generalAutoExpandGraph; 69 | IBOutlet id generalForegroundWhenExpanding; 70 | IBOutlet id generalShowSummary; 71 | IBOutlet id generalMinimizeUpDown; 72 | 73 | IBOutlet id backgroundColorWell; 74 | IBOutlet id backgroundTransparency; 75 | IBOutlet id graphBGColorWell; 76 | IBOutlet id graphBGTransparency; 77 | IBOutlet id graphFG1ColorWell; 78 | IBOutlet id graphFG1Transparency; 79 | IBOutlet id graphFG2ColorWell; 80 | IBOutlet id graphFG2Transparency; 81 | IBOutlet id graphFG3ColorWell; 82 | IBOutlet id graphFG3Transparency; 83 | IBOutlet id borderColorWell; 84 | IBOutlet id borderTransparency; 85 | IBOutlet id textColorWell; 86 | IBOutlet id textTransparency; 87 | IBOutlet id font; 88 | 89 | IBOutlet id fastCPUUsageCheckbox; 90 | IBOutlet id separateCPUColor; 91 | IBOutlet id showCPUTemperature; 92 | IBOutlet id cpuTemperatureUnits; 93 | IBOutlet id cpuShowAverageUsage; 94 | IBOutlet id showLoadAverage; 95 | IBOutlet id cpuShowUptime; 96 | 97 | IBOutlet id memoryShowWired; 98 | IBOutlet id memoryShowActive; 99 | IBOutlet id memoryShowInactive; 100 | IBOutlet id memoryShowFree; 101 | IBOutlet id memoryShowCache; 102 | IBOutlet id memoryShowPage; 103 | IBOutlet id memoryShowPagingGraph; 104 | 105 | IBOutlet id tempUnits; 106 | IBOutlet NSPopUpButton *tempFG1Location; 107 | IBOutlet NSPopUpButton *tempFG2Location; 108 | IBOutlet NSPopUpButton *tempFG3Location; 109 | 110 | IBOutlet id networkInterface; 111 | IBOutlet id netMinGraphScaleUnits; 112 | IBOutlet id netMinGraphScaleValue; 113 | IBOutlet id netGraphMode; 114 | IBOutlet id showTotalBandwidthSinceBoot; 115 | IBOutlet id showTotalBandwidthSinceLoad; 116 | 117 | IBOutlet id diskGraphMode; 118 | 119 | IBOutlet id ICAOCode; 120 | IBOutlet id secondaryWeatherGraph; 121 | IBOutlet id temperatureUnits; 122 | IBOutlet id distanceUnits; 123 | IBOutlet id pressureUnits; 124 | IBOutlet id weatherStationListLink; 125 | 126 | IBOutlet id stockSymbols; 127 | IBOutlet id stockGraphTimeFrame; 128 | IBOutlet id stockShowChange; 129 | IBOutlet id showDJIA; 130 | 131 | IBOutlet id hiddenModules; 132 | IBOutlet id displayedModules; 133 | } 134 | 135 | @property (weak) XRGGraphWindow *xrgGraphWindow; 136 | @property NSArray *temperatureSensors; 137 | 138 | - (IBAction)save:(id)sender; 139 | - (IBAction)revert:(id)sender; 140 | - (IBAction)loadTheme:(id)sender; 141 | - (void)loadTheme2:(NSOpenPanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo; 142 | - (IBAction)saveTheme:(id)sender; 143 | - (void)saveTheme2:(NSSavePanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo; 144 | 145 | - (NSWindow *)window; 146 | - (void)setUpGeneralPanel; 147 | - (void)setUpColorPanel; 148 | - (void)setUpCPUPanel; 149 | - (void)setUpMemoryPanel; 150 | - (void)setUpTemperaturePanel; 151 | - (void)setUpNetworkPanel; 152 | - (void)setUpDiskPanel; 153 | - (void)setUpWeatherPanel; 154 | - (void)setUpStockPanel; 155 | 156 | - (void)setUpWell:(NSColorWell *)well withTransparency:(NSSlider *)tSlider; 157 | - (void)setUpModuleSelection; 158 | - (IBAction)setGraphRefreshAction:(id)sender; 159 | - (IBAction)setNetMinGraphValueAction:(id)sender; 160 | - (IBAction)setNetMinGraphUnitsAction:(id)sender; 161 | - (NSColorWell *)colorWellForTag:(int)aTag; 162 | 163 | //Required NSToolbar delegate methods 164 | - (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag; 165 | - (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar*)toolbar; 166 | - (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar*)toolbar; 167 | 168 | //Action methods 169 | - (IBAction)General:(id)sender; 170 | - (IBAction)Colors:(id)sender; 171 | - (IBAction)CPU:(id)sender; 172 | - (IBAction)RAM:(id)sender; 173 | - (IBAction)Temperature:(id)sender; 174 | - (IBAction)Network:(id)sender; 175 | - (IBAction)Disk:(id)sender; 176 | - (IBAction)Weather:(id)sender; 177 | - (IBAction)Stocks:(id)sender; 178 | - (IBAction)setFont:(id)sender; 179 | 180 | - (IBAction)openWeatherStationList:(id)sender; 181 | 182 | @end 183 | -------------------------------------------------------------------------------- /Controllers/XRGSensorViewController.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGSensorViewController.h 25 | // 26 | 27 | #import 28 | 29 | NS_ASSUME_NONNULL_BEGIN 30 | 31 | @interface XRGSensorViewController : NSViewController 32 | 33 | @end 34 | 35 | NS_ASSUME_NONNULL_END 36 | -------------------------------------------------------------------------------- /Controllers/XRGSensorViewController.m: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGSensorViewController.m 25 | // 26 | 27 | #import "XRGSensorViewController.h" 28 | #import "XRGTemperatureMiner.h" 29 | #import "XRGCPUMiner.h" 30 | #import "XRGSettings.h" 31 | #import "XRGAppDelegate.h" 32 | #import "XRGStatsManager.h" 33 | #import "XRGTemperatureView.h" 34 | 35 | @interface XRGSensorViewController () 36 | 37 | @property NSTimer *timer; 38 | 39 | @property IBOutlet NSTextField *nameValuesLabel; 40 | @property IBOutlet NSTextField *currentValuesLabel; 41 | @property IBOutlet NSTextField *statsValuesLabel; 42 | @property IBOutlet NSLayoutConstraint *statsWidthConstraint; 43 | 44 | @property (weak,nullable) IBOutlet NSButton *exportButton; 45 | 46 | @property XRGSettings *appSettings; 47 | 48 | @end 49 | 50 | @implementation XRGSensorViewController 51 | 52 | - (void)viewDidLoad { 53 | [super viewDidLoad]; 54 | 55 | id appDelegate = [NSApp delegate]; 56 | if ([appDelegate isKindOfClass:[XRGAppDelegate class]]) { 57 | self.appSettings = [(XRGAppDelegate *)appDelegate appSettings]; 58 | } 59 | 60 | self.statsWidthConstraint = [[self.statsValuesLabel widthAnchor] constraintEqualToConstant:20]; 61 | [self.statsWidthConstraint setActive:YES]; 62 | } 63 | 64 | - (void)viewWillAppear { 65 | [super viewWillAppear]; 66 | 67 | __weak XRGSensorViewController *weakSelf = self; 68 | self.timer = [NSTimer scheduledTimerWithTimeInterval:1.0 repeats:YES block:^(NSTimer * _Nonnull timer) { 69 | [weakSelf refresh]; 70 | }]; 71 | } 72 | 73 | - (void)viewDidDisappear { 74 | [super viewDidDisappear]; 75 | 76 | [self.timer invalidate]; 77 | self.timer = nil; 78 | } 79 | 80 | - (void)refresh { 81 | NSArray *sensorKeys = [[XRGTemperatureMiner shared] locationKeysIncludingUnknown:[XRGTemperatureView showUnknownSensors]]; 82 | 83 | NSMutableString *sensorNames = [[NSMutableString alloc] init]; 84 | NSMutableString *currentValues = [[NSMutableString alloc] init]; 85 | NSMutableString *statsValues = [[NSMutableString alloc] init]; 86 | 87 | BOOL convertToF = [self.appSettings tempUnits] == XRGTemperatureUnitsF; 88 | NSString *cUnitsString = [NSString stringWithFormat:@"%CC", (unsigned short)0x00B0]; 89 | NSString *fUnitsString = [NSString stringWithFormat:@"%CF", (unsigned short)0x00B0]; 90 | 91 | XRGStatsManager *statsManager = [XRGStatsManager shared]; 92 | 93 | for (NSString *key in sensorKeys) { 94 | XRGSensorData *sensor = [[XRGTemperatureMiner shared] sensorForLocation:key]; 95 | XRGStatsContentItem *sensorStats = [statsManager statForKey:key inModule:XRGStatsModuleNameTemperature]; 96 | 97 | double current = sensorStats.last; 98 | double avg = sensorStats.average; 99 | double min = sensorStats.min; 100 | double max = sensorStats.max; 101 | 102 | NSString *units = sensor.units; 103 | if ([units isEqualToString:cUnitsString] && convertToF) { 104 | current = current * 1.8 + 32; 105 | avg = avg * 1.8 + 32; 106 | min = min * 1.8 + 32; 107 | max = max * 1.8 + 32; 108 | 109 | units = fUnitsString; 110 | } 111 | 112 | [sensorNames appendFormat:@"%@\n", sensor.humanReadableName]; 113 | [currentValues appendFormat:@"%.0f%@\n", current, units]; 114 | [statsValues appendFormat:@"%.0f - %.0f - %.0f\n", min, avg, max]; 115 | } 116 | 117 | [self.nameValuesLabel setStringValue:sensorNames]; 118 | [self.currentValuesLabel setStringValue:currentValues]; 119 | [self.statsValuesLabel setStringValue:statsValues]; 120 | 121 | [self.statsValuesLabel sizeToFit]; 122 | self.statsWidthConstraint.constant = self.statsValuesLabel.frame.size.width; 123 | } 124 | 125 | - (IBAction)exportAction:(id)sender { 126 | // Copy text to a clipboard. 127 | NSMutableString *copyText = [[NSMutableString alloc] init]; 128 | 129 | NSString *appVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"]; 130 | if (!appVersion) appVersion = @""; 131 | 132 | [copyText appendFormat:@"XRG %@\n", appVersion]; 133 | [copyText appendFormat:@"Mac model: %@\n", [XRGCPUMiner systemModelIdentifier]]; 134 | [copyText appendFormat:@"Running macOS %@\n\n", [[NSProcessInfo processInfo] operatingSystemVersionString]]; 135 | [copyText appendString:@"Discovered Sensors:\n"]; 136 | 137 | for (NSString *sensorKey in [[XRGTemperatureMiner shared] locationKeysIncludingUnknown:YES]) { 138 | XRGSensorData *sensor = [[XRGTemperatureMiner shared] sensorForLocation:sensorKey]; 139 | 140 | [copyText appendFormat:@"\t%@: %.1f\n", sensor.label, sensor.currentValue]; 141 | } 142 | 143 | [[NSPasteboard generalPasteboard] clearContents]; 144 | [[NSPasteboard generalPasteboard] setString:copyText forType:NSStringPboardType]; 145 | } 146 | 147 | 148 | @end 149 | -------------------------------------------------------------------------------- /Data Miners/APSL/AppleHIDUsageTables.h: -------------------------------------------------------------------------------- 1 | /* 2 | * @APPLE_LICENSE_HEADER_START@ 3 | * 4 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. Please obtain a copy of the License at 10 | * http://www.opensource.apple.com/apsl/ and read it before using this 11 | * file. 12 | * 13 | * The Original Code and all software distributed under the License are 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 | * Please see the License for the specific language governing rights and 19 | * limitations under the License. 20 | * 21 | * @APPLE_LICENSE_HEADER_END@ 22 | */ 23 | #ifndef _APPLEHIDUSAGETABLES_H 24 | #define _APPLEHIDUSAGETABLES_H 25 | 26 | /* ****************************************************************************************** 27 | * Apple HID Usage Tables 28 | * 29 | * The following constants are Apple Vendor specific usages 30 | * ****************************************************************************************** */ 31 | 32 | 33 | /* Usage Pages */ 34 | enum 35 | { 36 | kHIDPage_AppleVendor = 0xff00, 37 | kHIDPage_AppleVendorKeyboard = 0xff01, 38 | kHIDPage_AppleVendorMouse = 0xff02, 39 | kHIDPage_AppleVendorAccelerometer = 0xff03, 40 | kHIDPage_AppleVendorAmbientLightSensor = 0xff04, 41 | kHIDPage_AppleVendorTemperatureSensor = 0xff05, 42 | kHIDPage_AppleVendorHeadset = 0xff07, 43 | kHIDPage_AppleVendorPowerSensor = 0xff08, 44 | kHIDPage_AppleVendorSmartCover = 0xff09, 45 | kHIDPage_AppleVendorPlatinum = 0xff0A, 46 | kHIDPage_AppleVendorLisa = 0xff0B, 47 | kHIDPage_AppleVendorMotion = 0xff0C, 48 | kHIDPage_AppleVendorBattery = 0xff0D, 49 | kHIDPage_AppleVendorIRRemote = 0xff0E, 50 | kHIDPage_AppleVendorDebug = 0xff0F, 51 | kHIDPage_AppleVendorFilteredEvent = 0xff50, 52 | kHIDPage_AppleVendorMultitouch = 0xff60, 53 | kHIDPage_AppleVendorDisplay = 0xff92, 54 | kHIDPage_AppleVendorTopCase = 0x00ff 55 | }; 56 | 57 | 58 | /* AppleVendor Page (0xff00) */ 59 | enum 60 | { 61 | kHIDUsage_AppleVendor_TopCase = 0x0001, /* Application Collection */ 62 | kHIDUsage_AppleVendor_Display = 0x0002, /* Application Collection */ 63 | kHIDUsage_AppleVendor_Accelerometer = 0x0003, /* Application Collection */ 64 | kHIDUsage_AppleVendor_AmbientLightSensor = 0x0004, /* Application Collection */ 65 | kHIDUsage_AppleVendor_TemperatureSensor = 0x0005, /* Application Collection */ 66 | kHIDUsage_AppleVendor_Keyboard = 0x0006, /* Application Collection */ 67 | kHIDUsage_AppleVendor_Headset = 0x0007, /* Application Collection */ 68 | kHIDUsage_AppleVendor_ProximitySensor = 0x0008, /* Application Collection */ 69 | kHIDUsage_AppleVendor_Gyro = 0x0009, /* Application Collection */ 70 | kHIDUsage_AppleVendor_Compass = 0x000A, /* Application Collection */ 71 | kHIDUsage_AppleVendor_DeviceManagement = 0x000B, /* Application Collection */ 72 | kHIDUsage_AppleVendor_Trackpad = 0x000C, /* Application Collection */ 73 | kHIDUsage_AppleVendor_TopCaseReserved = 0x000D, /* Application Collection */ 74 | kHIDUsage_AppleVendor_Motion = 0x000E, /* Application Collection */ 75 | kHIDUsage_AppleVendor_KeyboardBacklight = 0x000F, /* Application Collection */ 76 | kHIDUsage_AppleVendor_DeviceMotionLite = 0x0010, /* Application Collection */ 77 | kHIDUsage_AppleVendor_Force = 0x0011, /* Application Collection */ 78 | kHIDUsage_AppleVendor_BluetoothRadio = 0x0012, /* Application Collection */ 79 | kHIDUsage_AppleVendor_Orb = 0x0013, /* Application Collection */ 80 | kHIDUsage_AppleVendor_AccessoryBattery = 0x0014, /* Application Collection */ 81 | }; 82 | 83 | 84 | /* AppleVendor Keyboard Page (0xff01) */ 85 | enum 86 | { 87 | kHIDUsage_AppleVendorKeyboard_Spotlight = 0x0001, 88 | kHIDUsage_AppleVendorKeyboard_Dashboard = 0x0002, 89 | kHIDUsage_AppleVendorKeyboard_Function = 0x0003, 90 | kHIDUsage_AppleVendorKeyboard_Launchpad = 0x0004, 91 | kHIDUsage_AppleVendorKeyboard_Reserved = 0x000a, 92 | kHIDUsage_AppleVendorKeyboard_CapsLockDelayEnable = 0x000b, 93 | kHIDUsage_AppleVendorKeyboard_PowerState = 0x000c, 94 | kHIDUsage_AppleVendorKeyboard_Expose_All = 0x0010, 95 | kHIDUsage_AppleVendorKeyboard_Expose_Desktop = 0x0011, 96 | kHIDUsage_AppleVendorKeyboard_Brightness_Up = 0x0020, 97 | kHIDUsage_AppleVendorKeyboard_Brightness_Down = 0x0021, 98 | kHIDUsage_AppleVendorKeyboard_Language = 0x0030 99 | }; 100 | 101 | /* AppleVendor Page Headset (0xff07) */ 102 | enum 103 | { 104 | kHIDUsage_AV_Headset_Availability = 0x0001 105 | }; 106 | 107 | /* AppleVendor Power Page (0xff08) */ 108 | enum { 109 | kHIDUsage_AppleVendorPowerSensor_Power = 0x0001, 110 | kHIDUsage_AppleVendorPowerSensor_Current = 0x0002, 111 | kHIDUsage_AppleVendorPowerSensor_Voltage = 0x0003, 112 | }; 113 | 114 | /* AppleVendor Smart Cover Page (0xff09) */ 115 | enum { 116 | kHIDUsage_AppleVendorSmartCover_Open = 0x0001, 117 | kHIDUsage_AppleVendorSmartCover_Flap1 = 0x0002, 118 | kHIDUsage_AppleVendorSmartCover_Flap2 = 0x0003, 119 | kHIDUsage_AppleVendorSmartCover_Flap3 = 0x0004, 120 | }; 121 | 122 | /* AppleVendor Platinum (0xff0A) */ 123 | enum { 124 | kHIDUsage_AppleVendorPlatinum_Platinum = 0x0001, 125 | kHIDUsage_AppleVendorPlatinum_Osmium = 0x0002, 126 | kHIDUsage_AppleVendorPlatinum_Lutetim = 0x0003, 127 | }; 128 | 129 | /* AppleVendor Motion (0xff0C) */ 130 | enum { 131 | kHIDUsage_AppleVendorMotion_Motion = 0x0001, 132 | kHIDUsage_AppleVendorMotion_Activity = 0x0002, 133 | kHIDUsage_AppleVendorMotion_Gesture = 0x0003, 134 | kHIDUsage_AppleVendorMotion_DeviceMotion = 0x0004, 135 | }; 136 | 137 | /* AppleVendor Battery (0xff0D) */ 138 | enum { 139 | kHIDUsage_AppleVendorBattery_RawCapacity = 0x0001, 140 | kHIDUsage_AppleVendorBattery_NominalChargeCapacity = 0x0002, 141 | kHIDUsage_AppleVendorBattery_CumulativeCurrent = 0x0003, 142 | }; 143 | 144 | /* AppleVendor IR Remote (0xff0E) */ 145 | enum { 146 | kHIDUsage_AppleVendorIRRemote_Pair = 0x0001, 147 | kHIDUsage_AppleVendorIRRemote_Unpair = 0x0002, 148 | kHIDUsage_AppleVendorIRRemote_LowBattery = 0x0003, 149 | kHIDUsage_AppleVendorIRRemote_BTLEDiscoveryMode = 0x0004, 150 | }; 151 | 152 | /* AppleVendor Debug (0xff0F) */ 153 | enum { 154 | kHIDUsage_AppleVendorDebug_Screenshot = 0x0001, 155 | kHIDUsage_AppleVendorDebug_Stackshot = 0x0002, 156 | kHIDUsage_AppleVendorDebug_SendLogs = 0x0003, 157 | kHIDUsage_AppleVendorDebug_BlackScreenRecover = 0x0004, 158 | }; 159 | 160 | /* AppleVendor Multitouch Page (0xff60) */ 161 | enum 162 | { 163 | kHIDUsage_AppleVendorMultitouch_PowerOff = 0x0001, 164 | kHIDUsage_AppleVendorMultitouch_DeviceReady = 0x0002, 165 | kHIDUsage_AppleVendorMultitouch_ExternalMessage = 0x0003, 166 | kHIDUsage_AppleVendorMultitouch_WillPowerOn = 0x0004, 167 | kHIDUsage_AppleVendorMultitouch_TouchCancel = 0x0005 168 | }; 169 | 170 | /* AppleVendor Page Top Case (0x00ff) */ 171 | enum 172 | { 173 | kHIDUsage_AV_TopCase_KeyboardFn = 0x0003, 174 | kHIDUsage_AV_TopCase_BrightnessUp = 0x0004, 175 | kHIDUsage_AV_TopCase_BrightnessDown = 0x0005, 176 | kHIDUsage_AV_TopCase_VideoMirror = 0x0006, 177 | kHIDUsage_AV_TopCase_IlluminationToggle = 0x0007, 178 | kHIDUsage_AV_TopCase_IlluminationUp = 0x0008, 179 | kHIDUsage_AV_TopCase_IlluminationDown = 0x0009, 180 | kHIDUsage_AV_TopCase_ClamshellLatched = 0x000a, 181 | kHIDUsage_AV_TopCase_Reserved_MouseData = 0x00c0 182 | }; 183 | 184 | 185 | #endif /* _APPLEHIDUSAGETABLES_H */ 186 | -------------------------------------------------------------------------------- /Data Miners/APSL/SMCInterface.h: -------------------------------------------------------------------------------- 1 | /* The implementation file is partially derived from IOPMLibPrivate.c 2 | which is licensed under the APSL, so APSL applies: */ 3 | 4 | /* 5 | * Copyright (c) 2004 Apple Computer, Inc. All rights reserved. 6 | * 7 | * @APPLE_LICENSE_HEADER_START@ 8 | * 9 | * This file contains Original Code and/or Modifications of Original Code 10 | * as defined in and that are subject to the Apple Public Source License 11 | * Version 2.0 (the 'License'). You may not use this file except in 12 | * compliance with the License. Please obtain a copy of the License at 13 | * http://www.opensource.apple.com/apsl/ and read it before using this 14 | * file. 15 | * 16 | * The Original Code and all software distributed under the License are 17 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 18 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 19 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 21 | * Please see the License for the specific language governing rights and 22 | * limitations under the License. 23 | * 24 | * @APPLE_LICENSE_HEADER_END@ 25 | */ 26 | 27 | 28 | #import 29 | #import 30 | 31 | @interface SMCInterface : NSObject 32 | - (id) readValue:(FourCharCode) aKey error:(NSError **) outError; 33 | - (NSInteger) keyCount; 34 | - (FourCharCode) keyAtIndex:(NSInteger) anIndex; 35 | @end 36 | -------------------------------------------------------------------------------- /Data Miners/APSL/SMCSensorGroup.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // SMCSensorGroup.h 25 | // 26 | 27 | #import 28 | 29 | NS_ASSUME_NONNULL_BEGIN 30 | 31 | /// A series is a group of SMC keys that happen in order. An example might be if the group being looked at was Tp0?, then a series might be Tp0a, Tp0b, Tp0c. In that case, `characters` would be ["a", "b", "c"] and `concurrentValues` would be 3. 32 | @interface SMCSensorSeries: NSObject 33 | /// The wildcard character for the series. 34 | @property NSArray *characters; 35 | 36 | - (instancetype)initWithStartingCharacter:(NSString *)character; 37 | 38 | /// Add another subsequent character. 39 | - (void)addCharacter:(NSString *)character; 40 | /// The number of concurrent characters in this series that are valid SMC keys. 41 | - (NSInteger)concurrentValues; 42 | 43 | @end 44 | 45 | @interface SMCSensorGroup : NSObject 46 | 47 | /// The order of the sensor data. These are raw SMC keys that act as keys in sensorKeyDescriptions. 48 | @property NSArray *sensorKeyOrder; 49 | /// The group raw SMC keys and their cooresponding description values. 50 | @property NSDictionary *sensorKeyDescriptions; 51 | 52 | /// Creates a key group from the sensor data or nil if no group could be matched for this pattern. 53 | - (instancetype)initWithPattern:(NSString *)pattern usingAvailableSensors:(NSSet *)sensorList description:(NSString *)description; 54 | 55 | @end 56 | 57 | NS_ASSUME_NONNULL_END 58 | -------------------------------------------------------------------------------- /Data Miners/APSL/SMCSensorGroup.m: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // SMCSensorGroup.m 25 | // 26 | 27 | #import "SMCSensorGroup.h" 28 | 29 | NSArray *__SMCSensorGroup_wildcardOrder = nil; 30 | 31 | @implementation SMCSensorSeries 32 | 33 | - (instancetype)initWithStartingCharacter:(NSString *)character { 34 | if (self = [super init]) { 35 | self.characters = @[character]; 36 | } 37 | 38 | return self; 39 | } 40 | 41 | /// Add another subsequent character. 42 | - (void)addCharacter:(NSString *)character { 43 | self.characters = [self.characters arrayByAddingObject:character]; 44 | } 45 | 46 | /// The number of concurrent characters in this series that are valid SMC keys. 47 | - (NSInteger)concurrentValues { 48 | return self.characters.count; 49 | } 50 | 51 | - (BOOL)isFullNumericSeries { 52 | return self.characters.count == 10 && [self.characters[0] isEqualToString:@"0"]; 53 | } 54 | 55 | @end 56 | 57 | @interface SMCSensorGroup () 58 | @property NSArray *wildcardOrder; 59 | @end 60 | 61 | @implementation SMCSensorGroup 62 | 63 | + (nonnull NSArray *)seriesForPattern:(NSString *)pattern inSensorList:(NSSet *)sensorList { 64 | NSArray *wildcardCharacters = [SMCSensorGroup wildcardOrder]; 65 | 66 | NSMutableArray *prefixGroups = [NSMutableArray array]; 67 | SMCSensorSeries *currentSeries = nil; 68 | 69 | for (NSString *wildcardCharacter in wildcardCharacters) { 70 | NSString *checkString = [pattern stringByReplacingOccurrencesOfString:@"?" withString:wildcardCharacter]; 71 | 72 | if ([sensorList containsObject:checkString]) { 73 | if (currentSeries) { 74 | [currentSeries addCharacter:wildcardCharacter]; 75 | } 76 | else { 77 | currentSeries = [[SMCSensorSeries alloc] initWithStartingCharacter:wildcardCharacter]; 78 | } 79 | } 80 | else if (currentSeries) { 81 | [prefixGroups addObject:currentSeries]; 82 | currentSeries = nil; 83 | } 84 | } 85 | 86 | // Check for a 0-9 prefix. 87 | NSInteger fullNumericIndex = NSNotFound; 88 | for (int i = 0; i < prefixGroups.count; i++) { 89 | if ([prefixGroups[i] isFullNumericSeries]) { 90 | fullNumericIndex = i; 91 | break; 92 | } 93 | } 94 | 95 | // Check for a prefix starting with 'a'. 96 | NSInteger lowerAPrefixIndex = NSNotFound; 97 | for (int i = 0; i < prefixGroups.count; i++) { 98 | if ([prefixGroups[i].characters[0] isEqualToString:@"a"]) { 99 | lowerAPrefixIndex = i; 100 | } 101 | } 102 | 103 | if (fullNumericIndex != NSNotFound && lowerAPrefixIndex != NSNotFound) { 104 | // Concatenate the "a" prefix onto the 0-9 prefix. 105 | SMCSensorSeries *numericSeries = prefixGroups[fullNumericIndex]; 106 | SMCSensorSeries *lowerASeries = prefixGroups[lowerAPrefixIndex]; 107 | 108 | numericSeries.characters = [numericSeries.characters arrayByAddingObjectsFromArray:lowerASeries.characters]; 109 | 110 | // Remove the "a" prefix series. 111 | [prefixGroups removeObjectAtIndex:lowerAPrefixIndex]; 112 | } 113 | 114 | return prefixGroups; 115 | } 116 | 117 | + (nonnull NSArray *)wildcardOrder { 118 | if (__SMCSensorGroup_wildcardOrder == nil) { 119 | // Populate the wildcard order. 120 | NSMutableArray *order = [NSMutableArray array]; 121 | 122 | for (int i = 0; i <= 9; i++) { 123 | [order addObject:[NSString stringWithFormat:@"%d", i]]; 124 | } 125 | for (char c = 'A'; c <= 'Z'; c++) { 126 | [order addObject:[NSString stringWithFormat:@"%c", c]]; 127 | } 128 | for (char c = 'a'; c <= 'z'; c++) { 129 | [order addObject:[NSString stringWithFormat:@"%c", c]]; 130 | } 131 | 132 | __SMCSensorGroup_wildcardOrder = order; 133 | } 134 | 135 | return __SMCSensorGroup_wildcardOrder; 136 | } 137 | 138 | - (instancetype)initWithPattern:(NSString *)pattern usingAvailableSensors:(NSSet *)sensorList description:(NSString *)description { 139 | NSArray *seriesArray = [SMCSensorGroup seriesForPattern:pattern inSensorList:sensorList]; 140 | if (!seriesArray.count) { 141 | return nil; 142 | } 143 | 144 | seriesArray = [self filteredSeriesArray:seriesArray]; 145 | if (!seriesArray) { 146 | return nil; 147 | } 148 | 149 | if (self = [super init]) { 150 | [self processSeries:seriesArray pattern:pattern description:description]; 151 | } 152 | 153 | return self; 154 | } 155 | 156 | - (void)processSeries:(NSArray *)seriesArray pattern:(NSString *)pattern description:(NSString *)description { 157 | NSMutableArray *names = [NSMutableArray array]; 158 | NSMutableDictionary *parsedSensors = [NSMutableDictionary dictionary]; 159 | 160 | if (seriesArray.count == 1) { 161 | // We only have one series in this group. Interpret as several individual sensors in order. 162 | SMCSensorSeries *series = seriesArray[0]; 163 | 164 | if (series.concurrentValues > 1 && ([series.characters[0] isEqualToString:@"0"] || [series.characters[0] isEqualToString:@"1"] )) { 165 | for (int i = 0; i < series.concurrentValues; i++) { 166 | NSString *sensorDescription = [NSString stringWithFormat:@"%@ %d", description, i + 1]; 167 | NSString *sensorKey = [pattern stringByReplacingOccurrencesOfString:@"?" withString:series.characters[i]]; 168 | 169 | parsedSensors[sensorKey] = sensorDescription; 170 | [names addObject:sensorKey]; 171 | } 172 | } 173 | else if (series.concurrentValues == 1) { 174 | NSString *sensorDescription = description; 175 | NSString *sensorKey = [pattern stringByReplacingOccurrencesOfString:@"?" withString:series.characters[0]]; 176 | 177 | parsedSensors[sensorKey] = sensorDescription; 178 | [names addObject:sensorKey]; 179 | } 180 | } 181 | else { 182 | // We have multiple series matching this group. Check that each series has 2 or 3 values. If so, then take the 2nd value of each series and add it as the sensor. Most Apple silicon sensors use this to monitor min/current/max sensor values. 183 | for (int i = 0; i < seriesArray.count; i++) { 184 | SMCSensorSeries *series = seriesArray[i]; 185 | 186 | if (series.concurrentValues == 2 || series.concurrentValues == 3) { 187 | NSString *sensorDescription = [NSString stringWithFormat:@"%@ %d", description, i + 1]; 188 | NSString *sensorKey = [pattern stringByReplacingOccurrencesOfString:@"?" withString:series.characters[1]]; 189 | 190 | parsedSensors[sensorKey] = sensorDescription; 191 | [names addObject:sensorKey]; 192 | } 193 | } 194 | } 195 | 196 | self.sensorKeyOrder = names; 197 | self.sensorKeyDescriptions = parsedSensors; 198 | } 199 | 200 | - (nullable NSArray *)filteredSeriesArray:(NSArray *)seriesArray { 201 | if (!seriesArray.count) { 202 | return nil; 203 | } 204 | 205 | // Check for an array of equal-length series. 206 | NSInteger firstDetectedConcurrentValues = seriesArray[0].concurrentValues; 207 | BOOL hasConcurrentSeries = YES; 208 | for (SMCSensorSeries *series in seriesArray) { 209 | if (series.concurrentValues != firstDetectedConcurrentValues) { 210 | hasConcurrentSeries = NO; 211 | } 212 | } 213 | if (hasConcurrentSeries) return seriesArray; 214 | 215 | // If we don't have equal-length series, then just return the first series. 216 | return @[seriesArray[0]]; 217 | } 218 | 219 | - (NSString *)description { 220 | return [NSString stringWithFormat:@"SMCSensorGroup %@", self.sensorKeyDescriptions]; 221 | } 222 | 223 | @end 224 | -------------------------------------------------------------------------------- /Data Miners/APSL/SMCSensors.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Interface to read SMC based sensor data in a convenient Cocoa-ish way 3 | * (C) CodeExchange 2012, licensed under the APSL 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2004 Apple Computer, Inc. All rights reserved. 8 | * 9 | * @APPLE_LICENSE_HEADER_START@ 10 | * 11 | * This file contains Original Code and/or Modifications of Original Code 12 | * as defined in and that are subject to the Apple Public Source License 13 | * Version 2.0 (the 'License'). You may not use this file except in 14 | * compliance with the License. Please obtain a copy of the License at 15 | * http://www.opensource.apple.com/apsl/ and read it before using this 16 | * file. 17 | * 18 | * The Original Code and all software distributed under the License are 19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 | * Please see the License for the specific language governing rights and 24 | * limitations under the License. 25 | * 26 | * @APPLE_LICENSE_HEADER_END@ 27 | */ 28 | 29 | 30 | #import 31 | 32 | @class SMCInterface; 33 | 34 | @interface SMCSensors : NSObject 35 | 36 | @property (strong) NSDictionary *descriptionsForSMCKeys; 37 | 38 | @property (nonatomic, readonly, strong) NSSet *unknownTemperatureKeys; // property descs for temp properties with description 39 | @property (nonatomic, readonly, strong) NSSet *knownTemperatureKeys; // property descs for temp properties with description 40 | 41 | /// returns an plain dict of values with their 4cc IDs. 42 | /// contains only values where a known conversion from the SMC data type to NSNumber / NDSData is implemented in SMCInterface 43 | @property (readonly, copy) NSDictionary *allValues; 44 | 45 | /// as far as their meaning is known (==guessable), the values have human readable keys 46 | /// Fan values - returns an NSDictionary of NSDictionaries 47 | @property (readonly, copy) NSDictionary *fanValues; 48 | 49 | /// Temperature senor values 50 | /// withUnknownSensors: include sensors where humanReadableNameForKey will fail 51 | /// return an NSDictionary with key: SMCSensorName, value: NSNumber with temperature in Celsius 52 | - (NSDictionary *) temperatureValuesIncludingUnknown:(BOOL) withUnknownSensors; 53 | 54 | /// additional sensors (motion etc.). 55 | @property (readonly, copy) NSDictionary *sensorValues; 56 | 57 | /// lookup a human readbale description of the 4 character string key. 58 | /// will return key, if no description can be found 59 | - (NSString *) humanReadableNameForKey:(NSString *)key; 60 | 61 | - (BOOL) isKnownKey:(NSString *)key; 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /Data Miners/APSL/XRGAppleSiliconSensorMiner.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGAppleSiliconSensorMiner.h 25 | // 26 | 27 | #import 28 | 29 | NS_ASSUME_NONNULL_BEGIN 30 | 31 | @interface XRGAppleSiliconSensorMiner : NSObject 32 | 33 | + (nullable NSDictionary *)sensorData; 34 | 35 | @end 36 | 37 | NS_ASSUME_NONNULL_END 38 | -------------------------------------------------------------------------------- /Data Miners/APSL/XRGAppleSiliconSensorMiner.m: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGAppleSiliconSensorMiner.h 25 | // 26 | 27 | // This code is based on https://github.com/yujitach/MenuMeters/ 28 | // which was in turn based on https://github.com/fermion-star/apple_sensors/blob/master/temp_sensor.m 29 | // which followed https://github.com/freedomtan/sensors/blob/master/sensors/sensors.m 30 | // whose detail can be found in https://www2.slideshare.net/kstan2/exploring-thermal-related-stuff-in-idevices-using-opensource-tool 31 | 32 | #import "XRGAppleSiliconSensorMiner.h" 33 | #import 34 | #import "IOHIDEventTypes.h" 35 | #import "AppleHIDUsageTables.h" 36 | #include "TargetConditionals.h" 37 | 38 | #import 39 | #import 40 | 41 | typedef struct __IOHIDEvent *IOHIDEventRef; 42 | 43 | IOHIDEventSystemClientRef IOHIDEventSystemClientCreate(CFAllocatorRef allocator); 44 | IOHIDEventRef IOHIDServiceClientCopyEvent(IOHIDServiceClientRef, int64_t, int32_t, int64_t); 45 | int IOHIDEventSystemClientSetMatching(IOHIDEventSystemClientRef client, CFDictionaryRef match); 46 | IOHIDFloat IOHIDEventGetFloatValue(IOHIDEventRef event, int32_t field); 47 | 48 | @implementation XRGAppleSiliconSensorMiner 49 | 50 | + (NSDictionary *)sensorData { 51 | #if TARGET_CPU_ARM64 52 | CFStringRef productKey = CFSTR("Product"); 53 | 54 | IOHIDEventSystemClientRef eventSystemClient = IOHIDEventSystemClientCreate(kCFAllocatorDefault);; 55 | IOHIDEventSystemClientSetMatching(eventSystemClient, (__bridge CFDictionaryRef)@{ 56 | @"PrimaryUsagePage": @(kHIDPage_AppleVendor), 57 | @"PrimaryUsage": @(kHIDUsage_AppleVendor_TemperatureSensor) 58 | }); 59 | 60 | CFArrayRef hidServices = IOHIDEventSystemClientCopyServices(eventSystemClient); 61 | if (!hidServices) return nil; 62 | 63 | NSMutableDictionary *sensorDictionary = [NSMutableDictionary dictionary]; 64 | CFIndex count = CFArrayGetCount(hidServices); 65 | for (int i = 0; i < count; i++) { 66 | IOHIDServiceClientRef serviceRef = (IOHIDServiceClientRef)CFArrayGetValueAtIndex(hidServices, i); 67 | 68 | NSString *name = CFBridgingRelease(IOHIDServiceClientCopyProperty(serviceRef, productKey)); 69 | IOHIDEventRef event = IOHIDServiceClientCopyEvent(serviceRef, kIOHIDEventTypeTemperature, 0, 0); 70 | 71 | if (name && event) { 72 | IOHIDFloat temperature = IOHIDEventGetFloatValue(event, IOHIDEventFieldBase(kIOHIDEventTypeTemperature)); 73 | sensorDictionary[name] = @(temperature); 74 | } 75 | 76 | if (event) CFRelease(event); 77 | } 78 | 79 | CFRelease(hidServices); 80 | CFRelease(eventSystemClient); 81 | 82 | return sensorDictionary; 83 | #else 84 | return nil; 85 | #endif 86 | } 87 | 88 | @end 89 | -------------------------------------------------------------------------------- /Data Miners/XRGBatteryMiner.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGBatteryMiner.h 25 | // 26 | 27 | #import 28 | #import "XRGDataSet.h" 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | typedef NS_ENUM(NSInteger, XRGBatteryStatus) { 33 | XRGBatteryStatusUnknown = 0, 34 | XRGBatteryStatusRunningOnBattery = 1, 35 | XRGBatteryStatusCharging = 2, 36 | XRGBatteryStatusCharged = 3, 37 | XRGBatteryStatusOnHold = 4, 38 | XRGBatteryStatusNoBattery = 5 39 | }; 40 | 41 | @interface XRGBatteryInfo: NSObject 42 | 43 | @property NSInteger currentCharge; 44 | @property NSInteger totalCapacity; 45 | @property CGFloat voltage; 46 | @property CGFloat amperage; 47 | @property NSInteger minutesRemaining; 48 | @property BOOL isCharging; 49 | @property BOOL isFullyCharged; 50 | @property BOOL isPluggedIn; 51 | 52 | - (CGFloat)percentCharged; 53 | 54 | @end 55 | 56 | @interface XRGBatteryMiner : NSObject 57 | 58 | @property (nonnull) NSArray *batteries; 59 | @property (nonnull) XRGDataSet *chargeWatts; 60 | @property (nonnull) XRGDataSet *dischargeWatts; 61 | @property NSInteger numSamples; 62 | 63 | - (void)setDataSize:(NSInteger)newNumSamples; 64 | - (void)graphUpdate:(nullable NSTimer *)aTimer; 65 | - (void)reset; 66 | 67 | - (XRGBatteryStatus)batteryStatus; 68 | - (NSInteger)minutesRemaining; 69 | - (NSInteger)totalCharge; 70 | - (NSInteger)totalCapacity; 71 | - (NSInteger)chargePercent; 72 | 73 | @end 74 | 75 | NS_ASSUME_NONNULL_END 76 | -------------------------------------------------------------------------------- /Data Miners/XRGBatteryMiner.m: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGBatteryMiner.m 25 | // 26 | 27 | #import "XRGBatteryMiner.h" 28 | 29 | @implementation XRGBatteryInfo 30 | 31 | - (instancetype)initWithBatteryDictionary:(NSDictionary *)batteryDictionary { 32 | if (self = [super init]) { 33 | self.totalCapacity = [batteryDictionary[@"AppleRawMaxCapacity"] integerValue]; 34 | self.currentCharge = [batteryDictionary[@"AppleRawCurrentCapacity"] integerValue]; 35 | self.amperage = (CGFloat)[batteryDictionary[@"Amperage"] integerValue] / 1000; 36 | self.voltage = (CGFloat)[batteryDictionary[@"Voltage"] integerValue] / 1000; 37 | self.minutesRemaining = [batteryDictionary[@"TimeRemaining"] integerValue]; 38 | self.isCharging = [batteryDictionary[@"IsCharging"] boolValue]; 39 | self.isFullyCharged = [batteryDictionary[@"FullyCharged"] boolValue]; 40 | self.isPluggedIn = [batteryDictionary[@"ExternalConnected"] boolValue]; 41 | } 42 | 43 | return self; 44 | } 45 | 46 | - (CGFloat)percentCharged { 47 | return (CGFloat)self.currentCharge / (CGFloat)self.totalCapacity; 48 | } 49 | 50 | @end 51 | 52 | @implementation XRGBatteryMiner 53 | 54 | - (instancetype)init { 55 | self = [super init]; 56 | if (self) { 57 | self.batteries = @[]; 58 | self.chargeWatts = [[XRGDataSet alloc] init]; 59 | self.dischargeWatts = [[XRGDataSet alloc] init]; 60 | self.numSamples = 0; 61 | } 62 | return self; 63 | } 64 | 65 | - (void)setDataSize:(NSInteger)newNumSamples { 66 | [self.chargeWatts resize:newNumSamples]; 67 | [self.dischargeWatts resize:newNumSamples]; 68 | 69 | self.numSamples = newNumSamples; 70 | } 71 | 72 | - (void)graphUpdate:(NSTimer *)aTimer { 73 | NSMutableArray *newBatteries = [NSMutableArray array]; 74 | 75 | io_iterator_t ioObjects = 0; 76 | kern_return_t kr = IOServiceGetMatchingServices(kIOMasterPortDefault, 77 | IOServiceMatching("IOPMPowerSource"), 78 | &ioObjects); 79 | if (kr != KERN_SUCCESS) return; 80 | 81 | io_object_t ioService = 0; 82 | while ((ioService = IOIteratorNext(ioObjects))) { 83 | CFMutableDictionaryRef serviceProperties = NULL; 84 | kr = IORegistryEntryCreateCFProperties(ioService, &serviceProperties, NULL, 0); 85 | if (kr == KERN_SUCCESS && serviceProperties) { 86 | NSDictionary *batteryDictionary = CFBridgingRelease(serviceProperties); 87 | 88 | XRGBatteryInfo *batteryInfo = [[XRGBatteryInfo alloc] initWithBatteryDictionary:batteryDictionary]; 89 | [newBatteries addObject:batteryInfo]; 90 | } 91 | 92 | IOObjectRelease(ioService); 93 | } 94 | 95 | self.batteries = newBatteries; 96 | 97 | // Save the watts being used. 98 | CGFloat chargeWattsSum = 0; 99 | CGFloat dischargeWattsSum = 0; 100 | for (XRGBatteryInfo *battery in self.batteries) { 101 | CGFloat watts = battery.amperage * battery.voltage; 102 | if (watts < 0) { 103 | dischargeWattsSum += -watts; 104 | } 105 | else { 106 | chargeWattsSum += watts; 107 | } 108 | } 109 | 110 | [self.chargeWatts setNextValue:chargeWattsSum]; 111 | [self.dischargeWatts setNextValue:dischargeWattsSum]; 112 | } 113 | 114 | - (void)reset { 115 | [self.chargeWatts reset]; 116 | [self.dischargeWatts reset]; 117 | } 118 | 119 | - (XRGBatteryStatus)batteryStatus { 120 | if (self.batteries.count) { 121 | // We just use the first battery. 122 | XRGBatteryInfo *firstBattery = self.batteries[0]; 123 | 124 | if (firstBattery.isPluggedIn && firstBattery.isFullyCharged) { 125 | return XRGBatteryStatusCharged; 126 | } 127 | else if (firstBattery.isPluggedIn && firstBattery.isCharging) { 128 | return XRGBatteryStatusCharging; 129 | } 130 | else if (firstBattery.isPluggedIn && !firstBattery.isCharging) { 131 | return XRGBatteryStatusOnHold; 132 | } 133 | else { 134 | return XRGBatteryStatusRunningOnBattery; 135 | } 136 | } 137 | else { 138 | return XRGBatteryStatusNoBattery; 139 | } 140 | } 141 | 142 | - (NSInteger)minutesRemaining { 143 | NSInteger maxMinutesRemaining = 0; 144 | for (XRGBatteryInfo *battery in self.batteries) { 145 | maxMinutesRemaining = MAX(maxMinutesRemaining, battery.minutesRemaining); 146 | } 147 | 148 | return maxMinutesRemaining; 149 | } 150 | 151 | - (NSInteger)totalCharge { 152 | NSInteger totalCharge = 0; 153 | for (XRGBatteryInfo *battery in self.batteries) { 154 | totalCharge += battery.currentCharge; 155 | } 156 | return totalCharge; 157 | } 158 | 159 | - (NSInteger)totalCapacity { 160 | NSInteger totalCapacity = 0; 161 | for (XRGBatteryInfo *battery in self.batteries) { 162 | totalCapacity += battery.totalCapacity; 163 | } 164 | return totalCapacity; 165 | } 166 | 167 | - (NSInteger)chargePercent { 168 | return ([self totalCharge] > 0 && [self totalCapacity] > 0) ? (NSInteger)(100.0 * [self totalCharge] / [self totalCapacity] + 0.5) : 0; 169 | } 170 | 171 | @end 172 | -------------------------------------------------------------------------------- /Data Miners/XRGCPUMiner.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGCPUMiner.h 25 | // 26 | 27 | #import 28 | #import "XRGDataSet.h" 29 | #import "XRGTemperatureMiner.h" 30 | 31 | @interface XRGCPUMiner : NSObject { 32 | @private 33 | 34 | NSInteger numSamples; 35 | 36 | CGFloat *immediateUser; 37 | CGFloat *immediateSystem; 38 | CGFloat *immediateNice; 39 | CGFloat *immediateTotal; 40 | NSMutableDictionary *temperatureKeys; 41 | 42 | processor_cpu_load_info_t lastSlowCPUInfo; 43 | processor_cpu_load_info_t lastFastCPUInfo; 44 | 45 | host_name_port_t host; 46 | } 47 | 48 | @property BOOL loadAverage; 49 | @property BOOL uptime; 50 | 51 | @property NSInteger uptimeDays; 52 | @property NSInteger uptimeHours; 53 | @property NSInteger uptimeMinutes; 54 | @property NSInteger uptimeSeconds; 55 | 56 | @property NSInteger numberOfCPUs; 57 | @property CGFloat currentLoadAverage; 58 | 59 | @property NSInteger *fastValues; 60 | @property NSMutableArray *userValues; 61 | @property NSMutableArray *systemValues; 62 | @property NSMutableArray *niceValues; 63 | 64 | + (NSString *)systemModelIdentifier; 65 | 66 | - (void)graphUpdate:(NSTimer *)aTimer; 67 | - (void)fastUpdate:(NSTimer *)aTimer; 68 | - (NSInteger)calculateCPUUsageForCPUs:(processor_cpu_load_info_t *)lastCPUInfo count:(NSInteger)count; 69 | - (NSInteger)getNumCPUs; 70 | - (CGFloat)getLoadAverage; 71 | - (void)reset; 72 | 73 | - (void)setCurrentUptime; 74 | - (void)setDataSize:(NSInteger)newNumSamples; 75 | 76 | - (NSArray *)dataForCPU:(NSInteger)cpuNumber; 77 | - (NSArray *)combinedData; 78 | 79 | @end 80 | -------------------------------------------------------------------------------- /Data Miners/XRGGPUMiner.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGGraphicsMiner.h 25 | // 26 | 27 | #import 28 | #import "XRGDataSet.h" 29 | 30 | typedef NS_ENUM(UInt32, XRGPCIVendor) { 31 | XRGPCIVendorIntel = 0x8086, 32 | XRGPCIVendorAMD = 0x1002, 33 | XRGPCIVendorNVidia = 0x10de, 34 | XRGPCIVendorApple = 0x106b 35 | }; 36 | 37 | @interface XRGGPUMiner : NSObject 38 | 39 | /// Represents the number of samples in each XRGDataSet object. 40 | @property NSInteger numSamples; 41 | 42 | /// Represents the number of XRGDataSet objects in each of the following arrays. 43 | @property (nonatomic) NSInteger numberOfGPUs; 44 | 45 | /// Values are XRGDataSet objects representing total memory for each GPU. 46 | @property (readonly) NSArray *totalVRAMDataSets; 47 | /// Values are XRGDataSet objects representing free memory for each GPU. 48 | @property (readonly) NSArray *freeVRAMDataSets; 49 | /// Values are XRGDataSet objects representing the CPU wait time for the GPU (units: nanoseconds). 50 | @property (readonly) NSArray *cpuWaitDataSets; 51 | /// Values are XRGDataSet objects representing the device utilization for the GPU (units: %) 52 | @property (readonly) NSArray *utilizationDataSets; 53 | /// Values are NSString objects representing vendor names. 54 | @property (readonly) NSArray *vendorNames; 55 | 56 | - (void)getLatestGraphicsInfo; 57 | - (void)setDataSize:(NSInteger)newNumSamples; 58 | 59 | @end 60 | 61 | 62 | @interface XRGGraphicsCard : NSObject 63 | 64 | // The PCI vendor id for this card. 65 | @property XRGPCIVendor vendor; 66 | 67 | /// The total memory of the GPU in bytes. 68 | @property long long totalVRAM; 69 | /// The used memory of the GPU in bytes. 70 | @property long long usedVRAM; 71 | /// The free memory of the GPU in bytes. 72 | @property long long freeVRAM; 73 | /// The time in nanosecods the CPU waits for the GPU. 74 | @property long long cpuWait; 75 | /// The device utilization in %. 76 | @property int deviceUtilization; 77 | 78 | /// Returns YES if the PCI device matches the accelerator. To test for a match, we detect the PCI device ID (if present) and the PCI vendor ID from the pciDictionary and make sure that the combined value is present in the IOPCIMatch key of the accelerator dictionary. 79 | + (BOOL)matchingPCIDevice:(NSDictionary *)pciDictionary accelerator:(NSDictionary *)acceleratorDictionary; 80 | 81 | /// Initializes the properties using the given PCI dictionary and accelerator. It is assumed that the client has checked for a match with matchingPCIDevice:accelerator: previously. 82 | - (instancetype)initWithPCIDevice:(NSDictionary *)pciDictionary accelerator:(NSDictionary *)acceleratorDictionary; 83 | 84 | /// Returns a string representing the vendor of the GPU. 85 | - (NSString *)vendorString; 86 | 87 | @end 88 | -------------------------------------------------------------------------------- /Data Miners/XRGMemoryMiner.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGMemoryMiner.h 25 | // 26 | 27 | #import 28 | #import 29 | #import 30 | #import "XRGDataSet.h" 31 | 32 | @interface XRGMemoryMiner : NSObject { 33 | @private 34 | int numSamples; 35 | 36 | XRGDataSet *values1; 37 | XRGDataSet *values2; 38 | XRGDataSet *values3; 39 | 40 | host_name_port_t host; 41 | vm_statistics_data_t currentDiffs; 42 | vm_statistics_data_t lastStats; 43 | 44 | unsigned long pageSize; 45 | } 46 | 47 | @property UInt64 usedSwap; 48 | @property UInt64 totalSwap; 49 | 50 | - (void)getLatestMemoryInfo; 51 | - (void)setDataSize:(int)newNumSamples; 52 | - (void)reset; 53 | 54 | // actually kilobytes, not bytes - limited to 4TB with 32bit 55 | - (UInt64)freeBytes; 56 | - (UInt64)activeBytes; 57 | - (UInt64)inactiveBytes; 58 | - (UInt64)wiredBytes; 59 | - (UInt32)totalFaults; 60 | - (UInt32)recentFaults; 61 | - (UInt32)totalPageIns; 62 | - (UInt32)recentPageIns; 63 | - (UInt32)totalPageOuts; 64 | - (UInt32)recentPageOuts; 65 | - (UInt32)totalCacheLookups; 66 | - (UInt32)totalCacheHits; 67 | - (XRGDataSet *)faultData; 68 | - (XRGDataSet *)pageInData; 69 | - (XRGDataSet *)pageOutData; 70 | 71 | @end 72 | -------------------------------------------------------------------------------- /Data Miners/XRGMemoryMiner.m: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGMemoryMiner.m 25 | // 26 | 27 | #import "XRGMemoryMiner.h" 28 | #include 29 | 30 | @implementation XRGMemoryMiner 31 | 32 | - (instancetype)init { 33 | self = [super init]; 34 | if (self) { 35 | host = mach_host_self(); 36 | 37 | values1 = [[XRGDataSet alloc] init]; 38 | values2 = [[XRGDataSet alloc] init]; 39 | values3 = [[XRGDataSet alloc] init]; 40 | 41 | self.usedSwap = 0; 42 | self.totalSwap = 0; 43 | 44 | int mib[2] = { CTL_HW, HW_PAGESIZE }; 45 | size_t sz = sizeof(pageSize); 46 | if (-1 == sysctl(mib, 2, &pageSize, &sz, NULL, 0)) 47 | pageSize = vm_page_size; 48 | 49 | [self getLatestMemoryInfo]; 50 | } 51 | 52 | return self; 53 | } 54 | 55 | - (void)setDataSize:(int)newNumSamples { 56 | if (newNumSamples < 0) return; 57 | 58 | if(values1 && values2 && values3) { 59 | [values1 resize:(size_t)newNumSamples]; 60 | [values2 resize:(size_t)newNumSamples]; 61 | [values3 resize:(size_t)newNumSamples]; 62 | } 63 | else { 64 | values1 = [[XRGDataSet alloc] init]; 65 | values2 = [[XRGDataSet alloc] init]; 66 | values3 = [[XRGDataSet alloc] init]; 67 | 68 | [values1 resize:(size_t)newNumSamples]; 69 | [values2 resize:(size_t)newNumSamples]; 70 | [values3 resize:(size_t)newNumSamples]; 71 | } 72 | 73 | numSamples = newNumSamples; 74 | } 75 | 76 | - (void)reset { 77 | [values1 reset]; 78 | [values2 reset]; 79 | [values3 reset]; 80 | } 81 | 82 | - (void)getLatestMemoryInfo { 83 | kern_return_t kr; 84 | vm_statistics_data_t stats; 85 | unsigned int numBytes = HOST_VM_INFO_COUNT; 86 | 87 | kr = host_statistics(host, HOST_VM_INFO, (host_info_t)&stats, &numBytes); 88 | if (kr != KERN_SUCCESS) { 89 | return; 90 | } 91 | else { 92 | currentDiffs.free_count = (stats.free_count - lastStats.free_count); 93 | currentDiffs.active_count = (stats.active_count - lastStats.active_count); 94 | currentDiffs.inactive_count = (stats.inactive_count - lastStats.inactive_count); 95 | currentDiffs.wire_count = (stats.wire_count - lastStats.wire_count); 96 | currentDiffs.faults = (stats.faults - lastStats.faults); 97 | currentDiffs.pageins = (stats.pageins - lastStats.pageins); 98 | currentDiffs.pageouts = (stats.pageouts - lastStats.pageouts); 99 | 100 | lastStats.free_count = stats.free_count; 101 | lastStats.active_count = stats.active_count; 102 | lastStats.inactive_count = stats.inactive_count; 103 | lastStats.wire_count = stats.wire_count; 104 | lastStats.faults = stats.faults; 105 | lastStats.pageins = stats.pageins; 106 | lastStats.pageouts = stats.pageouts; 107 | lastStats.lookups = stats.lookups; 108 | lastStats.hits = stats.hits; 109 | } 110 | 111 | if (values1) [values1 setNextValue:currentDiffs.faults]; 112 | if (values2) [values2 setNextValue:currentDiffs.pageins]; 113 | if (values3) [values3 setNextValue:currentDiffs.pageouts]; 114 | 115 | // Swap space monitoring. 116 | int vmmib[2] = { CTL_VM, VM_SWAPUSAGE }; 117 | struct xsw_usage swapInfo; 118 | size_t swapLength = sizeof(swapInfo); 119 | if (sysctl(vmmib, 2, &swapInfo, &swapLength, NULL, 0) >= 0) { 120 | self.usedSwap = swapInfo.xsu_used; 121 | self.totalSwap = swapInfo.xsu_total; 122 | // NSLog(@"Used: %d (%3.2fM) Total: %d (%3.2fM)", usedSwap, (float)usedSwap / 1024. / 1024., totalSwap, (float)totalSwap / 1024. / 1024.); 123 | } 124 | } 125 | 126 | // actually kilobytes, not bytes 127 | - (UInt64)freeBytes { 128 | return (NSUInteger)lastStats.free_count * pageSize; 129 | } 130 | 131 | - (UInt64)activeBytes { 132 | return (NSUInteger)lastStats.active_count * pageSize; 133 | } 134 | 135 | - (UInt64)inactiveBytes { 136 | return (NSUInteger)lastStats.inactive_count * pageSize; 137 | } 138 | 139 | - (UInt64)wiredBytes { 140 | return (NSUInteger)lastStats.wire_count * pageSize; 141 | } 142 | 143 | - (UInt32)totalFaults { 144 | return lastStats.faults; 145 | } 146 | 147 | - (UInt32)recentFaults { 148 | return currentDiffs.faults; 149 | } 150 | 151 | - (UInt32)totalPageIns { 152 | return lastStats.pageins; 153 | } 154 | 155 | - (UInt32)recentPageIns { 156 | return currentDiffs.pageins; 157 | } 158 | 159 | - (UInt32)totalPageOuts { 160 | return lastStats.pageouts; 161 | } 162 | 163 | - (UInt32)recentPageOuts { 164 | return currentDiffs.pageouts; 165 | } 166 | 167 | - (UInt32)totalCacheLookups { 168 | return lastStats.lookups; 169 | } 170 | 171 | - (UInt32)totalCacheHits { 172 | return lastStats.hits; 173 | } 174 | 175 | - (XRGDataSet *)faultData { 176 | return values1; 177 | } 178 | 179 | - (XRGDataSet *)pageInData { 180 | return values2; 181 | } 182 | 183 | - (XRGDataSet *)pageOutData { 184 | return values3; 185 | } 186 | 187 | @end 188 | -------------------------------------------------------------------------------- /Data Miners/XRGNetMiner.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGNetMiner.h 25 | // 26 | 27 | #import 28 | #import "definitions.h" 29 | #import "XRGDataSet.h" 30 | 31 | @interface XRGNetMiner : NSObject { 32 | @private 33 | io_stats i_net, o_net; 34 | NSInteger pppInterfaceNum; 35 | NSInteger sendBytes; 36 | NSInteger recvBytes; 37 | int mib[6]; 38 | char *buf; 39 | size_t alloc; 40 | 41 | BOOL firstTimeStats; 42 | 43 | NSMutableArray *networkInterfaces; 44 | } 45 | 46 | @property UInt64 totalBytesSinceBoot; 47 | @property UInt64 totalBytesSinceLoad; 48 | 49 | @property NSString *monitorNetworkInterface; 50 | 51 | @property (readonly) NSInteger numInterfaces; 52 | @property (readonly) network_interface_stats *interfaceStats; 53 | 54 | @property (readonly) XRGDataSet *rxValues; 55 | @property (readonly) XRGDataSet *txValues; 56 | @property (readonly) XRGDataSet *totalValues; // rxValues + txValues 57 | 58 | - (void)getLatestNetInfo; 59 | - (void)setDataSize:(NSInteger)newNumSamples; 60 | - (CGFloat)maxBandwidth; 61 | - (CGFloat)currentTX; 62 | - (CGFloat)currentRX; 63 | - (void)reset; 64 | 65 | - (NSArray *)networkInterfaces; 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /Data Miners/XRGProcessMiner.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | #import 24 | 25 | #define XRGProcessPercentCPU @"%cpu" 26 | #define XRGProcessResidentMemorySize @"rss" 27 | #define XRGProcessVirtualMemorySize @"vsz" 28 | #define XRGProcessTotalSwaps @"nswap" 29 | #define XRGProcessUser @"user" 30 | #define XRGProcessID @"pid" 31 | #define XRGProcessCommand @"command" 32 | 33 | @interface XRGProcessMiner : NSObject 34 | 35 | @property NSArray *processes; 36 | 37 | - (void) graphUpdate:(NSTimer *)aTimer; 38 | 39 | - (NSArray *) processesSortedByCPUUsage; 40 | - (NSArray *) processesSortedByMemoryUsage; 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /Data Miners/XRGProcessMiner.m: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | #import "XRGProcessMiner.h" 24 | 25 | 26 | @implementation XRGProcessMiner 27 | 28 | - (void) graphUpdate:(NSTimer *)aTimer { 29 | // Init the task. 30 | NSTask *task = [[NSTask alloc] init]; 31 | [task setLaunchPath:@"/bin/ps"]; 32 | [task setArguments:@[@"axwwrco", @"%cpu,pid,rss,vsz,nswap,user,command"]]; 33 | 34 | // Init the stdout pipe. 35 | NSPipe *pipe = [NSPipe pipe]; 36 | [task setStandardOutput:pipe]; 37 | 38 | // Grab a filehandle for the stdout pipe. 39 | NSFileHandle *file = [pipe fileHandleForReading]; 40 | 41 | // Launch the task. 42 | [task launch]; 43 | 44 | // Get the output string from the file handle data. 45 | NSString *outputString = [[NSString alloc] initWithData:[file readDataToEndOfFile] encoding:NSUTF8StringEncoding]; 46 | 47 | // Parse the output string. 48 | NSArray *outputLines = [outputString componentsSeparatedByString:@"\n"]; 49 | NSMutableArray *newProcessArray = [NSMutableArray arrayWithCapacity:[outputLines count]]; 50 | 51 | // For each line (excluding the first header line). 52 | for (int i = 1; i < [outputLines count]; i++) { 53 | NSString *line = outputLines[i]; 54 | NSArray *lineComponents = [line componentsSeparatedByString:@" "]; 55 | NSMutableArray *lineComponentsNoBlanks = [NSMutableArray arrayWithCapacity:[lineComponents count]]; 56 | 57 | // Remove all the blank objects. 58 | int j; 59 | for (j = 0; j < [lineComponents count]; j++) { 60 | NSString *component = lineComponents[j]; 61 | if ([component length] > 0) { 62 | [lineComponentsNoBlanks addObject:component]; 63 | } 64 | } 65 | 66 | NSInteger numLineComponents = [lineComponentsNoBlanks count]; 67 | if (numLineComponents >= 7) { 68 | 69 | NSString *percentCPUString = lineComponentsNoBlanks[0]; 70 | NSString *pid = lineComponentsNoBlanks[1]; 71 | NSString *rssString = lineComponentsNoBlanks[2]; 72 | NSString *vssString = lineComponentsNoBlanks[3]; 73 | NSString *nswapString = lineComponentsNoBlanks[4]; 74 | NSString *userString = lineComponentsNoBlanks[5]; 75 | NSMutableString *commandString = [NSMutableString stringWithString:lineComponentsNoBlanks[6]]; 76 | for (j = 7; j < numLineComponents; j++) { 77 | [commandString appendFormat:@" %@", lineComponentsNoBlanks[j]]; 78 | } 79 | if ([nswapString isEqualToString:@"-"]) nswapString = @"0"; 80 | 81 | NSDictionary *d = @{ XRGProcessCommand: commandString, 82 | XRGProcessPercentCPU: @([percentCPUString floatValue]), 83 | XRGProcessID: @([pid intValue]), 84 | XRGProcessResidentMemorySize: @([rssString intValue]), 85 | XRGProcessVirtualMemorySize: @([vssString intValue]), 86 | XRGProcessTotalSwaps: @([nswapString intValue]), 87 | XRGProcessUser: userString }; 88 | 89 | [newProcessArray addObject:d]; 90 | } 91 | } 92 | 93 | [self setProcesses:newProcessArray]; 94 | } 95 | 96 | - (NSArray *) processesSortedByCPUUsage { 97 | NSSortDescriptor *cpuSorter = [[NSSortDescriptor alloc] initWithKey:XRGProcessPercentCPU ascending:NO selector:@selector(compare:)]; 98 | return [self.processes sortedArrayUsingDescriptors:@[cpuSorter]]; 99 | } 100 | 101 | - (NSArray *) processesSortedByMemoryUsage { 102 | NSSortDescriptor *memorySorter = [[NSSortDescriptor alloc] initWithKey:XRGProcessResidentMemorySize ascending:NO selector:@selector(compare:)]; 103 | return [self.processes sortedArrayUsingDescriptors:@[memorySorter]]; 104 | } 105 | 106 | @end 107 | -------------------------------------------------------------------------------- /Data Miners/XRGTemperatureMiner.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGTemperatureMiner.h 25 | // 26 | 27 | #import 28 | #import "XRGDataSet.h" 29 | #import "SMCSensors.h" 30 | 31 | @class SMCSensors; 32 | 33 | #pragma mark - XRGFan 34 | @interface XRGFan: NSObject 35 | 36 | @property (nullable) NSString *name; 37 | @property (nonnull) NSString *key; 38 | @property NSInteger actualSpeed; 39 | @property NSInteger targetSpeed; 40 | @property NSInteger minimumSpeed; 41 | @property NSInteger maximumSpeed; 42 | 43 | @end 44 | 45 | #pragma mark - XRGSensorData 46 | @interface XRGSensorData: NSObject 47 | 48 | @property (nullable) NSString *humanReadableName; 49 | @property (nullable) NSString *units; 50 | @property (nonnull) NSString *key; 51 | 52 | @property double currentValue; 53 | @property (nonnull) XRGDataSet *dataSet; 54 | 55 | @property BOOL isEnabled; 56 | 57 | - (nonnull instancetype)initWithSensorKey:(nonnull NSString *)key; 58 | 59 | - (nonnull NSString *)label; 60 | 61 | @end 62 | 63 | 64 | #pragma mark - XRGTemperatureMiner 65 | @interface XRGTemperatureMiner : NSObject { 66 | host_name_port_t host; 67 | host_basic_info_data_t hostInfo; 68 | NSInteger numCPUs; 69 | } 70 | 71 | @property (nonnull) SMCSensors *smcSensors; 72 | 73 | + (nonnull instancetype)shared; 74 | 75 | - (void)setDataSize:(NSInteger)newNumSamples; 76 | - (void)reset; 77 | - (NSInteger)numberOfCPUs; 78 | 79 | - (void)updateCurrentTemperatures:(BOOL)includeUnknown; 80 | 81 | - (nonnull NSArray *)locationKeysIncludingUnknown:(BOOL)includeUnknown; 82 | - (nonnull NSArray *)allSensorKeys; 83 | - (void)regenerateLocationKeyOrder; 84 | - (void)setCurrentValue:(float)value andUnits:(nullable NSString *)units forLocation:(nonnull NSString *)location; 85 | 86 | - (nullable XRGSensorData *)sensorForLocation:(nonnull NSString *)location; 87 | - (BOOL)isFanSensor:(nonnull XRGSensorData *)sensor; 88 | 89 | - (nonnull NSArray *)fanValues; 90 | - (NSInteger)maxSpeedForFan:(nonnull XRGSensorData *)sensor; 91 | 92 | @end 93 | 94 | -------------------------------------------------------------------------------- /Graph Views/XRGBackgroundView.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGBackgroundView.h 25 | // 26 | 27 | #import 28 | #import "XRGSettings.h" 29 | 30 | @class XRGGraphWindow; 31 | 32 | @interface XRGBackgroundView : NSView { 33 | @private 34 | XRGGraphWindow *parentWindow; 35 | XRGSettings *appSettings; 36 | id moduleManager; 37 | 38 | float lastWidth; 39 | bool inInner; 40 | bool inOuter; 41 | bool inHeader; 42 | bool isVertical; 43 | bool uiIsHidden; 44 | NSRect unminimizedRect; 45 | 46 | NSPoint viewPointClicked; 47 | } 48 | 49 | @property NSString *hostname; 50 | @property NSArray *resizeRects; 51 | 52 | @property NSTrackingArea *trackingArea; 53 | 54 | @property BOOL clickedMinimized; 55 | 56 | - (void)getHostname; 57 | - (void)offsetDrawingOrigin:(NSSize)offset; 58 | - (void)minimizeWindow; 59 | - (void)expandWindow; 60 | - (void)mouseDownAction:(NSEvent *)theEvent; 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /Graph Views/XRGBatteryView.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGBatteryView.h 25 | // 26 | 27 | #import 28 | #import "definitions.h" 29 | #import "XRGGenericView.h" 30 | #import "XRGBatteryMiner.h" 31 | 32 | #define SMALL 0 33 | #define NORMAL 1 34 | #define WIDE 2 35 | 36 | @interface XRGBatteryView : XRGGenericView { 37 | @private 38 | NSSize graphSize; 39 | XRGModule *m; 40 | 41 | // Cache Variables 42 | //NSMutableDictionary *textWidthCache; 43 | CGFloat NBF_WIDE; 44 | CGFloat NBF_NORMAL; 45 | CGFloat PERCENT_WIDE; 46 | CGFloat CHARGED_WIDE; 47 | CGFloat ESTIMATING_WIDE; 48 | CGFloat ESTIMATING_NORMAL; 49 | CGFloat POWER_WIDE; 50 | CGFloat CURRENT_WIDE; 51 | CGFloat CURRENT_NORMAL; 52 | CGFloat CAPACITY_WIDE; 53 | CGFloat CAPACITY_NORMAL; 54 | CGFloat NBIF_WIDE; 55 | CGFloat NBIF_NORMAL; 56 | CGFloat MAH_STRING; 57 | 58 | NSInteger lastPowerStatus; 59 | NSInteger displayMode; 60 | NSInteger tripleCount; 61 | 62 | NSInteger graphPixelTimeFrame; 63 | NSInteger statsUpdateTimeFrame; 64 | CGFloat currentPixelTime; 65 | CGFloat currentStatsTime; 66 | } 67 | 68 | @property XRGBatteryMiner *batteryMiner; 69 | 70 | - (void)setGraphSize:(NSSize)newSize; 71 | - (void)setWidth:(NSInteger)newWidth; 72 | - (void)updateMinSize; 73 | - (void)graphUpdate:(NSTimer *)aTimer; 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /Graph Views/XRGCPUView.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGCPUView.h 25 | // 26 | 27 | #import 28 | #import "XRGGenericView.h" 29 | #import "XRGCPUMiner.h" 30 | #import "XRGProcessMiner.h" 31 | 32 | @interface XRGCPUView : XRGGenericView 33 | { 34 | @private 35 | NSSize graphSize; 36 | NSRect fastCPUDisplayRect; 37 | XRGModule *m; 38 | XRGCPUMiner *CPUMiner; 39 | XRGProcessMiner *processMiner; 40 | 41 | CGFloat UPTIME_WIDE; 42 | CGFloat UPTIME_NORMAL; 43 | CGFloat AVG_WIDE; 44 | CGFloat AVG_NORMAL; 45 | 46 | NSInteger numSamples; 47 | } 48 | 49 | - (void)setGraphSize:(NSSize)newSize; 50 | - (void)setWidth:(NSInteger)newWidth; 51 | - (void)updateMinSize; 52 | 53 | - (void)graphUpdate:(NSTimer *)aTimer; 54 | - (void)fastUpdate:(NSTimer *)aTimer; 55 | - (void)drawGraph:(NSRect)inRect; 56 | @end 57 | -------------------------------------------------------------------------------- /Graph Views/XRGDiskView.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGDiskView.h 25 | // 26 | 27 | #import 28 | #import 29 | #import 30 | #import "definitions.h" 31 | #import "XRGGenericView.h" 32 | 33 | @interface XRGDiskView : XRGGenericView { 34 | @private 35 | NSSize graphSize; 36 | int numSamples; 37 | XRGModule *m; 38 | 39 | UInt64 *values; 40 | UInt64 *readValues; 41 | UInt64 *writeValues; 42 | int currentIndex; 43 | UInt64 maxVal; 44 | 45 | UInt64 readBytes; 46 | UInt64 writeBytes; 47 | UInt64 totalDiskIO; 48 | UInt64 diskIOSinceLaunch; 49 | 50 | UInt64 fastReadBytes; 51 | UInt64 fastWriteBytes; 52 | UInt64 fastMax; 53 | io_stats fast_i; 54 | io_stats fast_o; 55 | 56 | mach_port_t masterPort; 57 | io_iterator_t drivelist; /* needs release */ 58 | NSMutableArray *volumeInfo; 59 | 60 | io_stats i_dsk; 61 | io_stats o_dsk; 62 | } 63 | 64 | - (void)setGraphSize:(NSSize)newSize; 65 | - (void)setWidth:(int)newWidth; 66 | - (void)updateMinSize; 67 | - (int)convertHeight:(int) yComponent; 68 | - (void)graphUpdate:(NSTimer *)aTimer; 69 | - (void)min5Update:(NSTimer *)aTimer; 70 | - (void)updateVolumeInfo; 71 | 72 | - (NSString *)readBytesString; 73 | - (NSString *)writeBytesString; 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /Graph Views/XRGGPUView.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGGraphicsView.h 25 | // 26 | 27 | #import 28 | #import "XRGGenericView.h" 29 | #import "XRGGPUMiner.h" 30 | 31 | @interface XRGGPUView : XRGGenericView 32 | { 33 | @private 34 | NSSize graphSize; 35 | NSInteger numSamples; 36 | NSInteger textRectHeight; 37 | XRGModule *m; 38 | XRGGPUMiner *graphicsMiner; 39 | } 40 | 41 | - (void)setGraphSize:(NSSize)newSize; 42 | - (void)setWidth:(int)newWidth; 43 | - (void)updateMinSize; 44 | - (void)graphUpdate:(NSTimer *)aTimer; 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /Graph Views/XRGGenericView.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGGenericView.h 25 | // 26 | 27 | 28 | #import 29 | #define NOVALUE -1000 30 | 31 | #define XRG_MINI_HEIGHT ([appSettings textRectHeight]) 32 | 33 | #import "XRGModule.h" 34 | #import "XRGSettings.h" 35 | #import "XRGModuleManager.h" 36 | #import "XRGAppDelegate.h" 37 | #import "XRGDataSet.h" 38 | 39 | @interface XRGGenericView : NSView { 40 | @protected 41 | XRGSettings *appSettings; 42 | XRGModuleManager *moduleManager; 43 | id parentWindow; 44 | } 45 | 46 | @property NSTextField *leftLabel; 47 | @property NSTextField *centerLabel; 48 | @property NSTextField *rightLabel; 49 | 50 | - (void)drawGraphWithData:(CGFloat *)samples size:(NSInteger)nSamples currentIndex:(NSInteger)cIndex maxValue:(CGFloat)max inRect:(NSRect)rect flipped:(BOOL)flipped color:(NSColor *)color; 51 | 52 | - (void)drawGraphWithDataFromDataSet:(XRGDataSet *)dataSet maxValue:(CGFloat)max inRect:(NSRect)rect flipped:(BOOL)flipped filled:(BOOL)filled color:(NSColor *)color; 53 | 54 | - (void)drawRangedGraphWithData:(CGFloat *)samples size:(NSInteger)nSamples currentIndex:(NSInteger)cIndex upperBound:(CGFloat)max lowerBound:(CGFloat)min inRect:(NSRect)rect flipped:(BOOL)flipped filled:(BOOL)filled color:(NSColor *)color; 55 | 56 | - (void)drawRangedGraphWithDataFromDataSet:(XRGDataSet *)dataSet upperBound:(CGFloat)max lowerBound:(CGFloat)min inRect:(NSRect)rect flipped:(BOOL)flipped filled:(BOOL)filled color:(NSColor *)color; 57 | 58 | - (void)drawMiniGraphWithValues:(NSArray *)values upperBound:(double)max lowerBound:(double)min leftLabel:(NSString *)leftLabel printValueBytes:(UInt64)printValue printValueIsRate:(BOOL)isRate; 59 | 60 | - (void)drawMiniGraphWithValues:(NSArray *)values upperBound:(double)max lowerBound:(double)min leftLabel:(NSString *)leftLabel rightLabel:(NSString *)rightLabel; 61 | 62 | - (void)fillRect:(NSRect)rect withColor:(NSColor *)color; 63 | 64 | - (void)drawLeftText:(NSString *)leftText centerText:(NSString *)centerText rightText:(NSString *)rightText inRect:(CGRect)rect; 65 | 66 | - (BOOL)shouldDrawMiniGraph; 67 | - (NSRect)paddedTextRect; 68 | 69 | // The following methods are to be implemented in subclasses. 70 | - (void)setGraphSize:(NSSize)newSize; 71 | - (void)updateMinSize; 72 | - (void)graphUpdate:(NSTimer *)aTimer; 73 | - (void)fastUpdate:(NSTimer *)aTimer; 74 | - (void)min5Update:(NSTimer *)aTimer; 75 | - (void)min30Update:(NSTimer *)aTimer; 76 | 77 | @end 78 | -------------------------------------------------------------------------------- /Graph Views/XRGMemoryView.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGMemoryView.h 25 | // 26 | 27 | #import 28 | #import "XRGGenericView.h" 29 | #import "XRGMemoryMiner.h" 30 | #import "XRGProcessMiner.h" 31 | 32 | @interface XRGMemoryView : XRGGenericView 33 | { 34 | @private 35 | NSSize graphSize; 36 | NSInteger numSamples; 37 | NSInteger textRectHeight; 38 | XRGModule *m; 39 | XRGMemoryMiner *memoryMiner; 40 | XRGProcessMiner *processMiner; 41 | } 42 | - (void)setGraphSize:(NSSize)newSize; 43 | - (void)setWidth:(int)newWidth; 44 | - (void)updateMinSize; 45 | - (void)graphUpdate:(NSTimer *)aTimer; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /Graph Views/XRGNetView.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGNetView.h 25 | // 26 | 27 | #import 28 | #import "definitions.h" 29 | #import "XRGGenericView.h" 30 | #import "XRGNetMiner.h" 31 | 32 | @interface XRGNetView : XRGGenericView { 33 | @private 34 | NSSize graphSize; 35 | NSInteger numSamples; 36 | XRGModule *m; 37 | 38 | NSInteger fastRXValue; 39 | NSInteger fastTXValue; 40 | } 41 | 42 | @property XRGNetMiner *miner; 43 | @property XRGNetMiner *fastMiner; 44 | 45 | - (void)setGraphSize:(NSSize)newSize; 46 | - (void)setWidth:(int)newWidth; 47 | - (void)updateMinSize; 48 | - (NSInteger)convertHeight:(NSInteger) yComponent; 49 | - (void)graphUpdate:(NSTimer *)aTimer; 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /Graph Views/XRGStockView.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGStockView.h 25 | // 26 | 27 | #import 28 | #import "XRGStock.h" 29 | #import "XRGModule.h" 30 | #import "XRGGenericView.h" 31 | 32 | @interface XRGStockView : XRGGenericView { 33 | @private 34 | XRGModule *m; 35 | 36 | NSMutableArray *stockSymbols; 37 | NSMutableArray *stockObjects; 38 | XRGStock *djia; 39 | NSInteger slowIncrementer; 40 | NSInteger slowTime; 41 | NSInteger switchIncrementer; 42 | NSInteger switchTime; 43 | NSInteger stockToShow; 44 | } 45 | 46 | @property NSSize graphSize; 47 | @property BOOL gettingData; 48 | 49 | - (void)updateMinSize; 50 | - (void)ticker; 51 | - (void)graphUpdate:(NSTimer *)aTimer; 52 | - (void)min30Update:(NSTimer *)aTimer; 53 | - (void)setStockSymbolsFromString:(NSString *)s; 54 | - (void)resetStockObjects; 55 | - (void)reloadStockData; 56 | - (bool)dataIsReady; 57 | - (int)convertHeight:(int) yComponent; 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /Graph Views/XRGTemperatureView.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGTemperatureView.h 25 | // 26 | 27 | #import 28 | #import "XRGGenericView.h" 29 | #import "XRGTemperatureMiner.h" 30 | 31 | @interface XRGTemperatureView : XRGGenericView 32 | { 33 | NSSize graphSize; 34 | 35 | float temperatureWidth; 36 | float rpmWidth; 37 | NSInteger graphWidth; 38 | NSMutableDictionary *locationSizeCache; 39 | 40 | XRGModule *m; 41 | 42 | NSInteger numSamples; 43 | BOOL showFanSpeed; 44 | NSInteger updateCounter; 45 | } 46 | 47 | + (BOOL)showUnknownSensors; 48 | 49 | - (void)setGraphSize:(NSSize)newSize; 50 | - (void)setWidth:(NSInteger)newWidth; 51 | - (void)updateMinSize; 52 | //- (int) getWidthForLabel:(NSString *)label; 53 | 54 | - (void)graphUpdate:(NSTimer *)aTimer; 55 | - (void)openTemperaturePreferences:(NSEvent *)theEvent; 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /Graph Views/XRGWeatherView.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGWeatherView.h 25 | // 26 | 27 | #import 28 | #import "XRGURL.h" 29 | #import "XRGGenericView.h" 30 | 31 | #define XRGWEATHER_NONE 0 32 | #define XRGWEATHER_WIND 1 33 | #define XRGWEATHER_HUMIDITY 2 34 | #define XRGWEATHER_VISIBILITY 3 35 | #define XRGWEATHER_DEWPOINT 4 36 | #define XRGWEATHER_PRESSURE 5 37 | 38 | #define XRGWEATHER_TEMPERATURE_F 0 39 | #define XRGWEATHER_TEMPERATURE_C 1 40 | 41 | #define XRGWEATHER_DISTANCE_MI 0 42 | #define XRGWEATHER_DISTANCE_KM 1 43 | 44 | #define XRGWEATHER_PRESSURE_IN 0 45 | #define XRGWEATHER_PRESSURE_HPA 1 46 | 47 | NSInteger matchRegex(char *pattern, char *inString); 48 | 49 | @interface XRGWeatherView : XRGGenericView { 50 | @private 51 | NSSize graphSize; 52 | XRGModule *m; 53 | 54 | // Caching variables 55 | CGFloat STATION_WIDE; 56 | CGFloat TEMPERATURE_WIDE; 57 | CGFloat TEMPERATURE_NORMAL; 58 | CGFloat TEMPERATURE_SMALL; 59 | CGFloat HL_WIDE; 60 | CGFloat WIND_WIDE; 61 | CGFloat WIND_NORMAL; 62 | CGFloat WIND_SMALL; 63 | CGFloat HUMIDITY_WIDE; 64 | CGFloat HUMIDITY_NORMAL; 65 | CGFloat VISIBILITY_WIDE; 66 | CGFloat DEWPOINT_WIDE; 67 | CGFloat PRESSURE_WIDE; 68 | CGFloat PRESSURE_NORMAL; 69 | 70 | XRGURL *wurl1; 71 | XRGURL *wurl2; 72 | BOOL triedWURL1; 73 | BOOL triedWURL2; 74 | 75 | NSString *stationName; 76 | NSMutableArray *metarArray; 77 | BOOL gettingData; 78 | BOOL processing; 79 | BOOL hasGoodURL; 80 | BOOL hasGoodMETARArray; 81 | BOOL hasGoodDisplayData; 82 | 83 | NSInteger time; 84 | NSInteger windDirection; 85 | NSInteger windSpeed; 86 | NSInteger gustSpeed; 87 | CGFloat visibilityInMiles; 88 | CGFloat visibilityInKilometers; 89 | NSInteger temperatureF; 90 | CGFloat temperatureC; 91 | NSInteger dewpointF; 92 | CGFloat dewpointC; 93 | CGFloat pressureIn; 94 | NSInteger pressureHPA; 95 | CGFloat high; 96 | CGFloat low; 97 | NSInteger relativeHumidity; 98 | CGFloat *lastDayTemps; 99 | CGFloat *lastDaySecondary; 100 | 101 | CGFloat secondaryGraphLowerBound; 102 | CGFloat secondaryGraphUpperBound; 103 | 104 | NSString *shortTemp; 105 | NSString *longTemp; 106 | NSString *shortHL; 107 | NSString *longHL; 108 | NSString *shortWind; 109 | NSString *longWind; 110 | NSString *shortHumidity; 111 | NSString *longHumidity; 112 | NSString *shortVisibility; 113 | NSString *longVisibility; 114 | NSString *shortDewpoint; 115 | NSString *longDewpoint; 116 | NSString *shortPressure; 117 | NSString *longPressure; 118 | 119 | NSInteger interval; 120 | } 121 | - (void)setGraphSize:(NSSize)newSize; 122 | - (void)updateMinSize; 123 | - (CGFloat)convertHeight:(CGFloat)yComponent; 124 | - (void)ticker; 125 | - (void)graphUpdate:(NSTimer *)aTimer; 126 | - (void)min30Update:(NSTimer *)aTimer; 127 | - (void)min30UpdatePostProcessing; 128 | - (void)setMETARFromText:(NSString *)s; 129 | - (void)setCurrentWeatherDataFromMETAR; 130 | - (void)setURL:(NSString *)icao; 131 | - (NSInteger)findString:(char *)s inArray:(NSArray *)inArray; 132 | - (NSArray *)getSecondaryGraphList; 133 | - (void)setUpSecondaryGraph; 134 | - (void)cancelLoading; 135 | - (bool)hasInvalidData; 136 | 137 | - (char *)getWindDirection; 138 | 139 | - (NSInteger)getTimeFromMETARFields:(NSArray *)fields; 140 | - (NSInteger)getWindDirectionFromMETARFields:(NSArray *)fields; 141 | - (NSInteger)getWindSpeedFromMETARFields:(NSArray *)fields; 142 | - (NSInteger)getGustSpeedFromMETARFields:(NSArray *)fields; 143 | - (CGFloat)getVisibilityInMilesFromMETARFields:(NSArray *)fields; 144 | - (CGFloat)getVisibilityInKilometersFromMETARFields:(NSArray *)fields; 145 | - (CGFloat)getTemperatureFromMETARFields:(NSArray *)fields; 146 | - (CGFloat)getDewpointFromMETARFields:(NSArray *)fields; 147 | - (CGFloat)getPressureInFromMETARFields:(NSArray *)fields; 148 | - (NSInteger)getPressureHPAFromMETARFields:(NSArray *)fields; 149 | - (NSInteger)getRelativeHumidityFromTemperature: (CGFloat)t andDewpoint: (CGFloat)d; 150 | 151 | @end 152 | -------------------------------------------------------------------------------- /Other Sources/XRG-Prefix.pch: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // Prefix header for all source files of the 'XRG' target in the 'XRG' project 25 | // 26 | 27 | #ifdef __OBJC__ 28 | #import 29 | #endif 30 | -------------------------------------------------------------------------------- /Other Sources/XRGPlugin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | @protocol XRGPlugin 24 | 25 | - (NSView *) graphView; 26 | - (NSView *) prefsView; 27 | - (NSString *) prefsIcon; 28 | 29 | - (NSString *) pluginName; 30 | - (NSString *) pluginShortName; 31 | 32 | - (NSDictionary *) fetchData; // Returns a dictionary of keys as labels and values being the data values. 33 | - (void) tick5; 34 | - (void) tick300; 35 | - (void) tick1800; 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /Other Sources/definitions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // definitions.h 25 | // 26 | 27 | #ifndef DEFINITIONS_H 28 | #define DEFINITIONS_H 29 | 30 | // Print Debugging Output 31 | #undef XRG_DEBUG 32 | 33 | typedef struct io_stats { 34 | UInt64 bytes_delta; 35 | UInt64 bytes_prev; 36 | UInt64 bytes; 37 | UInt64 bsd_bytes_prev; 38 | UInt64 bsd_bytes; 39 | }io_stats; 40 | 41 | typedef struct network_interface_stats { 42 | char if_name[32]; 43 | struct io_stats if_in; 44 | struct io_stats if_out; 45 | }network_interface_stats; 46 | 47 | // Define the names of our saved settings 48 | #define XRG_windowWidth @"windowWidth" 49 | #define XRG_windowHeight @"windowHeight" 50 | #define XRG_windowOriginX @"windowOriginX" 51 | #define XRG_windowOriginY @"windowOriginY" 52 | 53 | #define XRG_showSensorWindow @"showSensorWindow" 54 | 55 | #define XRG_borderWidth @"borderWidth" 56 | #define XRG_graphOrientationVertical @"graphOrientationVertical" 57 | #define XRG_antiAliasing @"antiAliasing" 58 | #define XRG_graphRefresh @"graphRefresh" 59 | #define XRG_windowLevel @"windowLevel" 60 | #define XRG_stickyWindow @"stickyWindow" 61 | #define XRG_checkForUpdates @"checkForUpdates" 62 | #define XRG_dropShadow @"dropShadow" 63 | #define XRG_windowTitle @"windowTitle" 64 | #define XRG_autoExpandGraph @"autoExpandGraph" 65 | #define XRG_foregroundWhenExpanding @"foregroundWhenExpanding" 66 | #define XRG_showSummary @"showSummary" 67 | #define XRG_minimizeUpDown @"minimizeUpDown" 68 | #define XRG_windowIsMinimized @"windowIsMinimized" 69 | #define XRG_isDockIconHidden @"isDockIconHidden" 70 | 71 | #define XRG_backgroundColor @"backgroundColor" 72 | #define XRG_graphBGColor @"graphBGColor" 73 | #define XRG_graphFG1Color @"graphFG1Color" 74 | #define XRG_graphFG2Color @"graphFG2Color" 75 | #define XRG_graphFG3Color @"graphFG3Color" 76 | #define XRG_borderColor @"borderColor" 77 | #define XRG_textColor @"textColor" 78 | #define XRG_backgroundTransparency @"backgroundTransparency" 79 | #define XRG_graphBGTransparency @"graphBGTransparency" 80 | #define XRG_graphFG1Transparency @"graphFG1Transparency" 81 | #define XRG_graphFG2Transparency @"graphFG2Transparency" 82 | #define XRG_graphFG3Transparency @"graphFG3Transparency" 83 | #define XRG_borderTransparency @"borderTransparency" 84 | #define XRG_textTransparency @"textTransparency" 85 | #define XRG_graphFont @"graphFont" 86 | 87 | #define XRG_showCPUBars @"showCPUBars" 88 | #define XRG_separateCPUColor @"separateCPUColor" 89 | #define XRG_showCPUTemperature @"showCPUTemperature" 90 | #define XRG_cpuTemperatureUnits @"cpuTemperatureUnits" 91 | #define XRG_showLoadAverage @"showLoadAverage" 92 | #define XRG_cpuShowAverageUsage @"cpuShowAverageUsage" 93 | #define XRG_cpuShowUptime @"cpuShowUptime" 94 | 95 | #define XRG_showMemoryPagingGraph @"showMemoryPagingGraph" 96 | #define XRG_memoryShowWired @"memoryShowWired" 97 | #define XRG_memoryShowActive @"memoryShowActive" 98 | #define XRG_memoryShowInactive @"memoryShowInactive" 99 | #define XRG_memoryShowFree @"memoryShowFree" 100 | #define XRG_memoryShowCache @"memoryShowCache" 101 | #define XRG_memoryShowPage @"memoryShowPage" 102 | 103 | #define XRG_tempUnits @"tempUnits" 104 | #define XRG_tempFG1Location @"tempFG1Location" 105 | #define XRG_tempFG2Location @"tempFG2Location" 106 | #define XRG_tempFG3Location @"tempFG3Location" 107 | #define XRG_tempFanSpeed @"tempFanSpeed" 108 | #define XRG_tempShowUnknownSensors @"tempShowUnknownSensors" 109 | #define XRG_tempLocationsAutoconfigured @"tempLocationsAutoconfigured" 110 | 111 | #define XRG_netMinGraphScale @"netMinGraphScale" 112 | #define XRG_netGraphMode @"netGraphMode" 113 | #define XRG_showTotalBandwidthSinceBoot @"showTotalBandwidthSinceBoot" 114 | #define XRG_showTotalBandwidthSinceLoad @"showTotalBandwidthSinceLoad" 115 | #define XRG_networkInterface @"networkInterface" 116 | 117 | #define XRG_diskGraphMode @"diskGraphMode" 118 | 119 | #define XRG_ICAO @"icao" 120 | #define XRG_secondaryWeatherGraph @"secondaryWeatherGraph" 121 | #define XRG_temperatureUnits @"temperatureUnits" 122 | #define XRG_distanceUnits @"distanceUnits" 123 | #define XRG_pressureUnits @"pressureUnits" 124 | 125 | #define XRG_stockSymbols @"stockSymbols" 126 | #define XRG_stockGraphTimeFrame @"stockGraphTimeFrame" 127 | #define XRG_stockShowChange @"stockShowChange" 128 | #define XRG_showDJIA @"showDJIA" 129 | 130 | #define XRG_showCPUGraph @"showCPUGraph" 131 | #define XRG_showGPUGraph @"showGPUGraph" 132 | #define XRG_showNetworkGraph @"showNetworkGraph" 133 | #define XRG_showDiskGraph @"showDiskGraph" 134 | #define XRG_showMemoryGraph @"showMemoryGraph" 135 | #define XRG_showWeatherGraph @"showWeatherGraph" 136 | #define XRG_showStockGraph @"showStockGraph" 137 | #define XRG_showBatteryGraph @"showBatteryGraph" 138 | #define XRG_showTemperatureGraph @"showTemperatureGraph" 139 | 140 | #define XRG_CPUOrder @"CPUOrder" 141 | #define XRG_NetworkOrder @"NetworkOrder" 142 | #define XRG_DiskOrder @"DiskOrder" 143 | #define XRG_MemoryOrder @"MemoryOrder" 144 | #define XRG_WeatherOrder @"WeatherOrder" 145 | #define XRG_StockOrder @"StockOrder" 146 | #define XRG_BatteryOrder @"BatteryOrder" 147 | 148 | #define XRG_CPU 1 149 | #define XRG_MEMORY 2 150 | #define XRG_BATTERY 3 151 | #define XRG_NET 4 152 | #define XRG_DISK 5 153 | #define XRG_WEATHER 6 154 | 155 | #define FLOAT(x) [NSNumber numberWithFloat:x] 156 | 157 | #define N1 0. 158 | #define NNE 22.5 159 | #define NE 45. 160 | #define ENE 67.5 161 | #define E 90. 162 | #define ESE 112.5 163 | #define SE 135. 164 | #define SSE 157.5 165 | #define S 180. 166 | #define SSW 202.5 167 | #define SW 225. 168 | #define WSW 247.5 169 | #define W 270. 170 | #define WNW 292.5 171 | #define NW 315. 172 | #define NNW 337.5 173 | #define N2 360. 174 | 175 | #endif 176 | -------------------------------------------------------------------------------- /Other Sources/main.m: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // main.m 25 | // 26 | 27 | #import 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | int main(int argc, const char *argv[]) { 34 | errno = 0; 35 | if (getpriority(PRIO_PROCESS, getpid()) <= 10) { 36 | if (errno == 0) { 37 | if (setpriority(PRIO_PROCESS, getpid(), 10) == -1) perror("Failed to renice"); 38 | } 39 | else { 40 | perror("Couldn't get process priority"); 41 | } 42 | } 43 | 44 | return NSApplicationMain(argc, argv); 45 | } 46 | -------------------------------------------------------------------------------- /Other Sources/ppp_msg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_LICENSE_HEADER_START@ 5 | * 6 | * The contents of this file constitute Original Code as defined in and 7 | * are subject to the Apple Public Source License Version 1.1 (the 8 | * "License"). You may not use this file except in compliance with the 9 | * License. Please obtain a copy of the License at 10 | * http://www.apple.com/publicsource and read it before using this file. 11 | * 12 | * This Original Code and all software distributed under the License are 13 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER 14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the 17 | * License for the specific language governing rights and limitations 18 | * under the License. 19 | * 20 | * @APPLE_LICENSE_HEADER_END@ 21 | */ 22 | 23 | 24 | #ifndef PPP_MSG_H 25 | #define PPP_MSG_H 26 | 27 | #include 28 | 29 | 30 | /* local socket path */ 31 | #define PPP_PATH "/var/run/pppconfd\0" 32 | 33 | 34 | /* PPP message paquets */ 35 | struct ppp_msg_hdr { 36 | u_int16_t m_flags; // special flags 37 | u_int16_t m_type; // type of the message 38 | u_int32_t m_result; // error code of notification message 39 | u_int32_t m_cookie; // user param 40 | u_int32_t m_link; // link for this message 41 | u_int32_t m_len; // len of the following data 42 | }; 43 | 44 | struct ppp_msg { 45 | u_int16_t m_flags; // special flags 46 | u_int16_t m_type; // type of the message 47 | u_int32_t m_result; // error code of notification message 48 | u_int32_t m_cookie; // user param, or error num for event 49 | u_int32_t m_link; // link for this message 50 | u_int32_t m_len; // len of the following data 51 | u_char m_data[1]; // msg data sent or received 52 | }; 53 | 54 | 55 | 56 | /* codes for ppp messages */ 57 | enum { 58 | /* API client commands */ 59 | PPP_VERSION = 1, 60 | PPP_STATUS, 61 | PPP_CONNECT, 62 | PPP_DISCONNECT = 5, 63 | PPP_GETOPTION, 64 | PPP_SETOPTION, 65 | PPP_ENABLE_EVENT, 66 | PPP_DISABLE_EVENT, 67 | PPP_EVENT, 68 | PPP_GETNBLINKS, 69 | PPP_GETLINKBYINDEX, 70 | PPP_GETLINKBYSERVICEID, 71 | PPP_GETLINKBYIFNAME, 72 | PPP_SUSPEND, 73 | PPP_RESUME 74 | }; 75 | 76 | // flags 77 | 78 | /* When USE_SERVICEID is set, m_link contains the serviceID length 79 | serviceID string is put after m_len field 80 | and m_len still contains the data lenght, excluding serviceID string */ 81 | #define USE_SERVICEID 0x8000 82 | 83 | 84 | /* macro to access real data base on header flags */ 85 | #define MSG_DATAOFF(msg) (((struct ppp_msg_hdr *)msg)->m_flags & USE_SERVICEID ? ((struct ppp_msg_hdr *)msg)->m_link : 0) 86 | 87 | // struct for an option 88 | struct ppp_opt_hdr { 89 | u_int32_t o_type; 90 | }; 91 | 92 | struct ppp_opt { 93 | u_int32_t o_type; 94 | u_char o_data[1]; 95 | }; 96 | 97 | 98 | /* codes for options management */ 99 | enum { 100 | 101 | PPP_OPT_DEV_NAME = 1, // string 102 | PPP_OPT_DEV_SPEED, // 4 bytes 103 | PPP_OPT_DEV_CONNECTSCRIPT, // string 104 | 105 | PPP_OPT_COMM_IDLETIMER, // 4 bytes 106 | PPP_OPT_COMM_REMOTEADDR, // string 107 | 108 | PPP_OPT_AUTH_PROTO, // 4 bytes 109 | PPP_OPT_AUTH_NAME, // string 110 | PPP_OPT_AUTH_PASSWD, // string 111 | 112 | PPP_OPT_LCP_HDRCOMP, // 4 bytes 113 | PPP_OPT_LCP_MRU, // 4 bytes 114 | PPP_OPT_LCP_MTU, // 4 bytes 115 | PPP_OPT_LCP_RCACCM, // 4 bytes 116 | PPP_OPT_LCP_TXACCM, // 4 bytes 117 | 118 | PPP_OPT_IPCP_HDRCOMP, // 4 bytes 119 | PPP_OPT_IPCP_LOCALADDR, // 4 bytes 120 | PPP_OPT_IPCP_REMOTEADDR, // 4 bytes 121 | 122 | PPP_OPT_LOGFILE, // string 123 | PPP_OPT_RESERVED, // 4 bytes 124 | PPP_OPT_COMM_REMINDERTIMER, // 4 bytes 125 | PPP_OPT_ALERTENABLE, // 4 bytes 126 | 127 | PPP_OPT_LCP_ECHO, // struct ppp_opt_echo 128 | 129 | PPP_OPT_COMM_CONNECTDELAY, // 4 bytes 130 | PPP_OPT_COMM_SESSIONTIMER, // 4 bytes 131 | PPP_OPT_COMM_TERMINALMODE, // 4 bytes 132 | PPP_OPT_COMM_TERMINALSCRIPT, // string. Additionnal connection script, once modem is connected 133 | PPP_OPT_RESERVED1, // place holder 134 | 135 | PPP_OPT_RESERVED2, // place holder 136 | PPP_OPT_DEV_CONNECTSPEED, // 4 bytes, actual connection speed 137 | PPP_OPT_SERVICEID, // string, name of the associated service in the cache 138 | PPP_OPT_IFNAME, // string, name of the associated interface (ppp0, ...) 139 | 140 | PPP_OPT_DEV_DIALMODE // 4 bytes, dial mode, applies to modem connection 141 | }; 142 | 143 | // options values 144 | 145 | // PPP_LCP_OPT_HDRCOMP -- option ppp addr/ctrl compression 146 | enum { 147 | PPP_LCP_HDRCOMP_NONE = 0, 148 | PPP_LCP_HDRCOMP_ADDR = 1, 149 | PPP_LCP_HDRCOMP_PROTO = 2 150 | }; 151 | 152 | enum { 153 | PPP_COMM_TERM_NONE = 0, 154 | PPP_COMM_TERM_SCRIPT, 155 | PPP_COMM_TERM_WINDOW 156 | }; 157 | 158 | enum { 159 | PPP_ALERT_ERRORS = 2, // disconnection causes 160 | PPP_ALERT_PASSWORDS = 8, // password and CCL Ask 161 | 162 | PPP_ALERT_DISABLEALL = 0, 163 | PPP_ALERT_ENABLEALL = 0xFFFFFFFF 164 | }; 165 | 166 | 167 | enum { 168 | PPP_IPCP_HDRCOMP_NONE = 0, 169 | PPP_IPCP_HDRCOMP_VJ 170 | }; 171 | 172 | // PPP_LCP_OPT_RCACCM -- option receive control asynchronous character map 173 | enum { 174 | PPP_LCP_ACCM_NONE = 0, 175 | PPP_LCP_ACCM_XONXOFF = 0x000A0000, 176 | PPP_LCP_ACCM_ALL = 0xFFFFFFFF 177 | }; 178 | 179 | // PPP_OPT_AUTH 180 | enum { 181 | PPP_AUTH_NONE = 0, 182 | PPP_AUTH_PAPCHAP, 183 | PPP_AUTH_PAP, 184 | PPP_AUTH_CHAP 185 | }; 186 | 187 | // PPP_OPT_DEV_DIALMODE 188 | enum { 189 | PPP_DEV_WAITFORDIALTONE = 0, 190 | PPP_DEV_IGNOREDIALTONE, 191 | PPP_DEV_MANUALDIAL 192 | }; 193 | 194 | // state machine 195 | enum { 196 | PPP_IDLE = 0, 197 | PPP_INITIALIZE, 198 | PPP_CONNECTLINK, 199 | PPP_STATERESERVED, 200 | PPP_ESTABLISH, 201 | PPP_AUTHENTICATE, 202 | PPP_CALLBACK, 203 | PPP_NETWORK, 204 | PPP_RUNNING, 205 | PPP_TERMINATE, 206 | PPP_DISCONNECTLINK, 207 | PPP_HOLDOFF, 208 | PPP_ONHOLD, 209 | PPP_WAITONBUSY 210 | }; 211 | 212 | // events 213 | enum { 214 | PPP_EVT_DISCONNECTED = 1, 215 | PPP_EVT_CONNSCRIPT_STARTED, 216 | PPP_EVT_CONNSCRIPT_FINISHED, 217 | PPP_EVT_TERMSCRIPT_STARTED, 218 | PPP_EVT_TERMSCRIPT_FINISHED, 219 | PPP_EVT_LOWERLAYER_UP, 220 | PPP_EVT_LOWERLAYER_DOWN, 221 | PPP_EVT_LCP_UP, 222 | PPP_EVT_LCP_DOWN, 223 | PPP_EVT_IPCP_UP, 224 | PPP_EVT_IPCP_DOWN, 225 | PPP_EVT_AUTH_STARTED, 226 | PPP_EVT_AUTH_FAILED, 227 | PPP_EVT_AUTH_SUCCEDED, 228 | PPP_EVT_CONN_STARTED, 229 | PPP_EVT_CONN_FAILED, 230 | PPP_EVT_CONN_SUCCEDED, 231 | PPP_EVT_DISC_STARTED, 232 | PPP_EVT_DISC_FINISHED, 233 | PPP_EVT_STOPPED, 234 | PPP_EVT_CONTINUED 235 | }; 236 | 237 | struct ppp_opt_echo { // 0 for the following value will cancel echo option 238 | u_int16_t interval; // delay in seconds between echo requests 239 | u_int16_t failure; // # of failure before declaring the link down 240 | }; 241 | 242 | struct ppp_status { 243 | // connection stats 244 | u_int32_t status; 245 | union { 246 | struct connected { 247 | u_int32_t timeElapsed; 248 | u_int32_t timeRemaining; 249 | // bytes stats 250 | u_int32_t inBytes; 251 | u_int32_t inPackets; 252 | u_int32_t inErrors; 253 | u_int32_t outBytes; 254 | u_int32_t outPackets; 255 | u_int32_t outErrors; 256 | } run; 257 | struct disconnected { 258 | u_int32_t lastDiscCause; 259 | } disc; 260 | struct waitonbusy { 261 | u_int32_t timeRemaining; 262 | } busy; 263 | } s; 264 | }; 265 | 266 | enum { 267 | // from 0 to 255, we use bsd error codes from errno.h 268 | 269 | // ppp speficic error codes 270 | PPP_ERR_GEN_ERROR = 256, 271 | PPP_ERR_CONNSCRIPTFAILED, 272 | PPP_ERR_TERMSCRIPTFAILED, 273 | PPP_ERR_LCPFAILED, 274 | PPP_ERR_AUTHFAILED, 275 | PPP_ERR_IDLETIMEOUT, 276 | PPP_ERR_SESSIONTIMEOUT, 277 | PPP_ERR_LOOPBACK, 278 | PPP_ERR_PEERDEAD, 279 | PPP_ERR_DISCSCRIPTFAILED, 280 | PPP_ERR_DISCBYPEER, 281 | PPP_ERR_DISCBYDEVICE, 282 | PPP_ERR_NODEVICE, 283 | 284 | // modem specific error codes 285 | PPP_ERR_MOD_NOCARRIER = 512, 286 | PPP_ERR_MOD_BUSY, 287 | PPP_ERR_MOD_NODIALTONE, 288 | PPP_ERR_MOD_ERROR, 289 | PPP_ERR_MOD_HANGUP, 290 | PPP_ERR_MOD_NOANSWER, 291 | PPP_ERR_MOD_NONUMBER 292 | }; 293 | 294 | #endif /* PPP_MSG_H */ 295 | 296 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | XRG 2 | === 3 | 4 | A system monitor for macOS. 5 | 6 | https://gaucho.software/xrg/ 7 | -------------------------------------------------------------------------------- /Resources/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/InfoPlist.strings -------------------------------------------------------------------------------- /Resources/MainMenu.nib/keyedobjects.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/MainMenu.nib/keyedobjects.nib -------------------------------------------------------------------------------- /Resources/Online Help/CVS/Entries: -------------------------------------------------------------------------------- 1 | /Online Help idx/1.4/Fri May 7 05:04:33 2004// 2 | /help_icon.gif/1.1/Mon Jun 16 17:49:43 2003// 3 | /index.html/1.4/Mon Jan 10 20:01:03 2005// 4 | /preferences.html/1.5/Mon Jan 10 20:01:03 2005// 5 | D/images//// 6 | /modules.html/1.7/Sun Oct 7 22:45:39 2007// 7 | -------------------------------------------------------------------------------- /Resources/Online Help/CVS/Repository: -------------------------------------------------------------------------------- 1 | /code/cvs/Gauchosoft/XRG/Resources/Online Help 2 | -------------------------------------------------------------------------------- /Resources/Online Help/CVS/Root: -------------------------------------------------------------------------------- 1 | mike@playa-dev.gauchosoft.com:/code/cvs/Gauchosoft 2 | -------------------------------------------------------------------------------- /Resources/Online Help/Online Help idx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Online Help/Online Help idx -------------------------------------------------------------------------------- /Resources/Online Help/help_icon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Online Help/help_icon.gif -------------------------------------------------------------------------------- /Resources/Online Help/images/CVS/Entries: -------------------------------------------------------------------------------- 1 | /battery.gif/1.2/Fri May 7 05:04:33 2004// 2 | /cpu.gif/1.3/Fri May 7 05:04:33 2004// 3 | /disk.gif/1.3/Fri May 7 05:04:33 2004// 4 | /mem.gif/1.3/Fri May 7 05:04:33 2004// 5 | /net.gif/1.3/Fri May 7 05:04:33 2004// 6 | /prefs_color.gif/1.2/Fri May 7 05:04:33 2004// 7 | /prefs_cpu.gif/1.2/Fri May 7 05:04:33 2004// 8 | /prefs_disk.gif/1.1/Fri May 7 05:05:26 2004// 9 | /prefs_general.gif/1.2/Fri May 7 05:04:33 2004// 10 | /prefs_memory.gif/1.2/Fri May 7 05:04:33 2004// 11 | /prefs_network.gif/1.2/Fri May 7 05:04:33 2004// 12 | /prefs_stock.gif/1.2/Fri May 7 05:04:33 2004// 13 | /prefs_temperature.jpg/1.1/Fri May 7 05:05:26 2004// 14 | /prefs_weather.gif/1.2/Fri May 7 05:04:33 2004// 15 | /stock.gif/1.3/Fri May 7 05:04:33 2004// 16 | /temperature.gif/1.1/Fri May 7 05:05:26 2004// 17 | /weather.gif/1.3/Fri May 7 05:04:33 2004// 18 | /xrg_icon3.jpg/1.1/Mon Jun 9 06:20:49 2003// 19 | /xrg_icon4.png/1.1/Mon Jan 10 20:00:41 2005// 20 | D 21 | -------------------------------------------------------------------------------- /Resources/Online Help/images/CVS/Repository: -------------------------------------------------------------------------------- 1 | /code/cvs/Gauchosoft/XRG/Resources/Online Help/images 2 | -------------------------------------------------------------------------------- /Resources/Online Help/images/CVS/Root: -------------------------------------------------------------------------------- 1 | mike@playa-dev.gauchosoft.com:/code/cvs/Gauchosoft 2 | -------------------------------------------------------------------------------- /Resources/Online Help/images/battery.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Online Help/images/battery.gif -------------------------------------------------------------------------------- /Resources/Online Help/images/cpu.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Online Help/images/cpu.gif -------------------------------------------------------------------------------- /Resources/Online Help/images/disk.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Online Help/images/disk.gif -------------------------------------------------------------------------------- /Resources/Online Help/images/mem.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Online Help/images/mem.gif -------------------------------------------------------------------------------- /Resources/Online Help/images/net.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Online Help/images/net.gif -------------------------------------------------------------------------------- /Resources/Online Help/images/prefs_color.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Online Help/images/prefs_color.gif -------------------------------------------------------------------------------- /Resources/Online Help/images/prefs_cpu.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Online Help/images/prefs_cpu.gif -------------------------------------------------------------------------------- /Resources/Online Help/images/prefs_disk.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Online Help/images/prefs_disk.gif -------------------------------------------------------------------------------- /Resources/Online Help/images/prefs_general.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Online Help/images/prefs_general.gif -------------------------------------------------------------------------------- /Resources/Online Help/images/prefs_memory.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Online Help/images/prefs_memory.gif -------------------------------------------------------------------------------- /Resources/Online Help/images/prefs_network.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Online Help/images/prefs_network.gif -------------------------------------------------------------------------------- /Resources/Online Help/images/prefs_stock.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Online Help/images/prefs_stock.gif -------------------------------------------------------------------------------- /Resources/Online Help/images/prefs_temperature.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Online Help/images/prefs_temperature.jpg -------------------------------------------------------------------------------- /Resources/Online Help/images/prefs_weather.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Online Help/images/prefs_weather.gif -------------------------------------------------------------------------------- /Resources/Online Help/images/stock.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Online Help/images/stock.gif -------------------------------------------------------------------------------- /Resources/Online Help/images/temperature.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Online Help/images/temperature.gif -------------------------------------------------------------------------------- /Resources/Online Help/images/weather.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Online Help/images/weather.gif -------------------------------------------------------------------------------- /Resources/Online Help/images/xrg_icon3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Online Help/images/xrg_icon3.jpg -------------------------------------------------------------------------------- /Resources/Online Help/images/xrg_icon4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Online Help/images/xrg_icon4.png -------------------------------------------------------------------------------- /Resources/Online Help/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | XRG Help 6 | 13 | 14 | 15 | 16 | 17 | 20 | 23 | 24 |
18 | 19 | 21 |

XRG: X Resource Graph Help

22 |
25 |

Welcome to XRG Help.

26 |

There are two areas to this help system. One explains what is being displayed in each XRG Graph Module. The other explains the options available in the Preferences Panel.

27 | XRG Graph Module Help
28 | XRG Preferences Help
29 | 30 | 31 | -------------------------------------------------------------------------------- /Resources/Preferences-Appearance.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Preferences-Appearance.tiff -------------------------------------------------------------------------------- /Resources/Preferences-CPU.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Preferences-CPU.tiff -------------------------------------------------------------------------------- /Resources/Preferences-Disk.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Preferences-Disk.tiff -------------------------------------------------------------------------------- /Resources/Preferences-General.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Preferences-General.tiff -------------------------------------------------------------------------------- /Resources/Preferences-Memory.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Preferences-Memory.tiff -------------------------------------------------------------------------------- /Resources/Preferences-Network.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Preferences-Network.tiff -------------------------------------------------------------------------------- /Resources/Preferences-Stocks.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Preferences-Stocks.tiff -------------------------------------------------------------------------------- /Resources/Preferences-Temperature.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Preferences-Temperature.tiff -------------------------------------------------------------------------------- /Resources/Preferences-Weather.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Preferences-Weather.tiff -------------------------------------------------------------------------------- /Resources/Preferences.nib/keyedobjects-101300.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Preferences.nib/keyedobjects-101300.nib -------------------------------------------------------------------------------- /Resources/Preferences.nib/keyedobjects.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/Preferences.nib/keyedobjects.nib -------------------------------------------------------------------------------- /Resources/SMCSensorNames.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | T* 6 | Temperature 7 | V* 8 | Voltage 9 | I* 10 | Intensity (current) 11 | P* 12 | Power (watts) 13 | ALV0 14 | Ambient Light Left 15 | ALV1 16 | Ambient Light Right 17 | dBA? 18 | Noise near Fan 19 | dBAH 20 | Noise near HD 21 | dBAT 22 | Total Noise 23 | F?Ac 24 | Fan 25 | F?Mn 26 | Fan Minimum Speed 27 | F?Mt 28 | Fan Maximum Target 29 | F?Mx 30 | Fan Maximum Speed 31 | F?Sf 32 | Fan Safe Speed 33 | F?Tg 34 | Fan Target Speed 35 | FS! 36 | Fan Forced Speed 37 | MOCN 38 | Motion 39 | MO_X 40 | Motion-X 41 | MO_Y 42 | Motion-Y 43 | MO_Z 44 | Motion-Z 45 | MSLD 46 | Clamshell 47 | TA?V 48 | Ambient 49 | TH?F 50 | SSD 51 | TI?P 52 | Thunderbolt 53 | TMA? 54 | DIMM A 55 | TMB? 56 | DIMM B 57 | TCXC 58 | PECI CPU 59 | TCXc 60 | PECI CPU 61 | TC?P 62 | CPU Proximity 63 | TC?H 64 | CPU Heatsink 65 | TC?D 66 | CPU Package 67 | TC?E 68 | CPU 69 | TC?F 70 | CPU 71 | TC?C 72 | CPU Core 73 | TCAC 74 | CPU A ° Below MaxT 75 | TCBC 76 | CPU B ° Below MaxT 77 | TCSC 78 | PECI SA 79 | TCSc 80 | PECI SA 81 | TCSA 82 | PECI SA 83 | TCGC 84 | PECI GPU 85 | TCGc 86 | PECI GPU 87 | TG?P 88 | GPU Proximity 89 | TGDD 90 | dGPU Die 91 | TG?D 92 | GPU Die 93 | TG?H 94 | GPU Heatsink 95 | Tg0? 96 | GPU Cluster 97 | Ts0S 98 | Memory Proximity 99 | TM?P 100 | Mem Bank 101 | TM?S 102 | Mem Module 103 | Tm0? 104 | Mem Bank 105 | Tp0? 106 | CPU Core 107 | TN0D 108 | Northbridge Die 109 | TN?P 110 | Northbridge Proximity 111 | TN0C 112 | MCH Die 113 | TN0H 114 | MCH Heatsink 115 | TP0D 116 | PCH Die 117 | TPCD 118 | PCH Die 119 | TP0P 120 | PCH Proximity 121 | TA?P 122 | Airflow 123 | Th?H 124 | Heatpipe 125 | Ts0P 126 | Palm Rest 127 | Tb0P 128 | BLC Proximity 129 | TL0P 130 | LCD Proximity 131 | TW0P 132 | Airport Proximity 133 | TH?P 134 | HDD Bay 135 | TO0P 136 | Optical Drive 137 | TB0T 138 | Battery TS_MAX 139 | TB1T 140 | Battery 1 141 | TB2T 142 | Battery 2 143 | TB3T 144 | Battery 145 | TS0C 146 | Expansion Slots 147 | TA?S 148 | PCI Position 149 | VC?C 150 | CPU Core 151 | VV1R 152 | CPU VTT 153 | VG0C 154 | GPU Core 155 | VM0R 156 | Memory 157 | VN1R 158 | PCH 159 | VN0C 160 | MCH 161 | VD0R 162 | Mainboard S0 Rail 163 | VD5R 164 | Mainboard S5 Rail 165 | VP0R 166 | 12V Rail 167 | Vp0C 168 | 12V Vcc 169 | VV2S 170 | Main 3V 171 | VR3R 172 | Main 3.3V 173 | VV1S 174 | Main 5V 175 | VH05 176 | Main 5V 177 | VV9S 178 | Main 12V 179 | VD2R 180 | Main 12V 181 | VV7S 182 | Auxiliary 3V 183 | VV3S 184 | Standby 3V 185 | VV8S 186 | Standby 5V 187 | VeES 188 | PCIe 12V 189 | VBAT 190 | Battery 191 | Vb0R 192 | CMOS Battery 193 | IC0C 194 | CPU Core 195 | IC1C 196 | CPU VccIO 197 | IC2C 198 | CPU VccSA 199 | IC0R 200 | CPU Rail 201 | IC5R 202 | CPU DRAM 203 | IC8R 204 | CPU PLL 205 | IC0G 206 | CPU GFX 207 | IC0M 208 | CPU Memory 209 | IG0C 210 | GPU Rail 211 | IM0C 212 | Memory Controller 213 | IM0R 214 | Memory Rail 215 | IN0C 216 | MCH 217 | ID0R 218 | Mainboard S0 Rail 219 | ID5R 220 | Mainboard S5 Rail 221 | IO0R 222 | Misc. Rail 223 | IB0R 224 | Battery Rail 225 | IPBR 226 | Charger BMON 227 | PC?C 228 | CPU Core 229 | PCPC 230 | CPU Cores 231 | PCPG 232 | CPU GFX 233 | PCPD 234 | CPU DRAM 235 | PCTR 236 | CPU Total 237 | PCPL 238 | CPU Total 239 | PC1R 240 | CPU Rail 241 | PC5R 242 | CPU S0 Rail 243 | PGTR 244 | GPU Total 245 | PG0R 246 | GPU Rail 247 | PM0R 248 | Memory Rail 249 | PN0C 250 | MCH 251 | PN1R 252 | PCH Rail 253 | PC0R 254 | Mainboard S0 Rail 255 | PD0R 256 | Mainboard S0 Rail 257 | PD5R 258 | Mainboard S5 Rail 259 | PH02 260 | Main 3.3V Rail 261 | PH05 262 | Main 5V Rail 263 | Pp0R 264 | 12V Rail 265 | PD2R 266 | Main 12V Rail 267 | PO0R 268 | Misc. Rail 269 | PBLC 270 | Battery Rail 271 | PB0R 272 | Battery Rail 273 | PDTR 274 | DC In Total 275 | PSTR 276 | System Total 277 | 278 | 279 | -------------------------------------------------------------------------------- /Resources/icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/icon.icns -------------------------------------------------------------------------------- /Resources/xtf.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikepj/XRG/0fca322068f8d70c64eb51237e65d2a8988fa242/Resources/xtf.icns -------------------------------------------------------------------------------- /Utility/NSStringUtil.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // NSStringUtil.h 25 | // 26 | 27 | #import "Foundation/NSString.h" 28 | 29 | @interface NSString (NSStringUtil) 30 | 31 | @property (readonly) BOOL boolValue; 32 | @property (readonly, copy) NSString *stringWithoutXMLTags; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /Utility/NSStringUtil.m: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // NSStringUtil.m 25 | // 26 | 27 | #import "NSStringUtil.h" 28 | 29 | @implementation NSString (NSStringUtil) 30 | 31 | - (BOOL)boolValue { 32 | if ([self isEqualToString:@""] || [self isEqualToString:@"0"] || [[self lowercaseString] isEqualToString:@"no"]) 33 | return NO; 34 | else 35 | return YES; 36 | } 37 | 38 | - (NSString *) stringWithoutXMLTags { 39 | NSInteger openIndex; 40 | NSInteger lastStringLength = [self length] + 1; 41 | 42 | if ([self length] == 0) return self; 43 | 44 | NSMutableString *newString = [NSMutableString stringWithCapacity:[self length]]; 45 | [newString appendString:self]; 46 | 47 | while ([newString length] < lastStringLength) { 48 | lastStringLength = [newString length]; 49 | 50 | openIndex = [newString rangeOfString:@"<"].location; 51 | if (openIndex == NSNotFound) break; 52 | 53 | NSInteger tagLength = [[newString substringFromIndex:openIndex] rangeOfString:@">"].location; 54 | if (tagLength == NSNotFound || tagLength <= 0) break; 55 | tagLength++; 56 | 57 | if (openIndex + tagLength <= lastStringLength) 58 | [newString replaceCharactersInRange:NSMakeRange(openIndex, tagLength) withString:@""]; 59 | else 60 | break; 61 | } 62 | 63 | return newString; 64 | } 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /Utility/XRGCommon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGCommon.h 25 | // 26 | 27 | #import 28 | 29 | @interface XRGCommon : NSObject 30 | 31 | /*! Calculates a damped max value using the previous max value, the current max value, and a base number the max should never fall below. 32 | * @param previousMax: The last max value. 33 | * @param currentMax: The current max value. 34 | * @param baseMax: The lowest max that should be returned. 35 | */ 36 | + (CGFloat)dampedMaxUsingPreviousMax:(CGFloat)previousMax currentMax:(CGFloat)currentMax baseMax:(CGFloat)baseMax; 37 | 38 | /*! Calculates a damped value using the previous value and the current value. 39 | * @param previousValue: The last value. 40 | * @param currentValue: The current value. 41 | */ 42 | + (CGFloat)dampedValueUsingPreviousValue:(CGFloat)previousValue currentValue:(CGFloat)currentValue; 43 | 44 | /*! Calculates a damped value using the previous value and the current value. 45 | * @param previousValue: The last value. 46 | * @param currentValue: The current value. 47 | * @param dampingCoefficient: The coefficient to use (between 0 and 1) that will dictate how much of a factor the previous value will have in the calculation. 48 | */ 49 | + (CGFloat)dampedValueUsingPreviousValue:(CGFloat)previousValue currentValue:(CGFloat)currentValue dampingCoefficient:(CGFloat)dampingCoefficient; 50 | 51 | + (NSString *)formattedStringForBytes:(double)bytes; 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /Utility/XRGCommon.m: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGCommon.m 25 | // 26 | 27 | #import "XRGCommon.h" 28 | 29 | @implementation XRGCommon 30 | 31 | + (CGFloat)dampedMaxUsingPreviousMax:(CGFloat)previousMax currentMax:(CGFloat)currentMax baseMax:(CGFloat)baseMax { 32 | return MAX(baseMax, [XRGCommon dampedValueUsingPreviousValue:previousMax currentValue:currentMax dampingCoefficient:0.95]); 33 | } 34 | 35 | + (CGFloat)dampedValueUsingPreviousValue:(CGFloat)previousValue currentValue:(CGFloat)currentValue { 36 | return [XRGCommon dampedValueUsingPreviousValue:previousValue currentValue:currentValue dampingCoefficient:0.8]; 37 | } 38 | 39 | + (CGFloat)dampedValueUsingPreviousValue:(CGFloat)previousValue currentValue:(CGFloat)currentValue dampingCoefficient:(CGFloat)dampingCoefficient { 40 | return (previousValue * dampingCoefficient) + (currentValue * (1 - dampingCoefficient)); 41 | } 42 | 43 | + (NSString *)formattedStringForBytes:(double)bytes { 44 | if (bytes >= 112589990684262400.) 45 | return [NSString stringWithFormat:@"%.1fP", (bytes / 1125899906842624.)]; 46 | else if (bytes >= 1125899906842624.) 47 | return [NSString stringWithFormat:@"%.2fP", (bytes / 1125899906842624.)]; 48 | else if (bytes >= 109951162777600.) 49 | return [NSString stringWithFormat:@"%.1fT", (bytes / 1099511627776.)]; 50 | else if (bytes >= 1099511627776.) 51 | return [NSString stringWithFormat:@"%.2fT", (bytes / 1099511627776.)]; 52 | else if (bytes >= 107374182400.) 53 | return [NSString stringWithFormat:@"%.1fG", (bytes / 1073741824.)]; 54 | else if (bytes >= 1073741824.) 55 | return [NSString stringWithFormat:@"%.2fG", (bytes / 1073741824.)]; 56 | else if (bytes >= 104857600.) 57 | return [NSString stringWithFormat:@"%.1fM", (bytes / 1048576.)]; 58 | else if (bytes >= 1048576.) 59 | return [NSString stringWithFormat:@"%.2fM", (bytes / 1048576.)]; 60 | else if (bytes >= 102400.) 61 | return [NSString stringWithFormat:@"%.0fK", (bytes / 1024.)]; 62 | else if (bytes >= 1024.) 63 | return [NSString stringWithFormat:@"%.1fK", (bytes / 1024.)]; 64 | else 65 | return [NSString stringWithFormat:@"%ldB", (long)bytes]; 66 | } 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /Utility/XRGDataSet.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGDataSet.h 25 | // 26 | 27 | #import 28 | 29 | @interface XRGDataSet : NSObject 30 | 31 | @property (nonatomic, assign) CGFloat *values; 32 | @property (nonatomic, assign) size_t numValues; 33 | @property (nonatomic, assign) NSInteger currentIndex; 34 | 35 | @property (nonatomic, assign) CGFloat min; 36 | @property (nonatomic, assign) CGFloat max; 37 | @property (nonatomic, assign) CGFloat sum; 38 | 39 | - (id) initWithContentsOfOtherDataSet:(XRGDataSet *)otherDataSet; 40 | 41 | - (CGFloat) average; 42 | - (CGFloat) currentValue; 43 | - (void) valuesInOrder:(CGFloat *)destinationArray; 44 | 45 | - (void) reset; 46 | - (void) resize:(size_t)newNumValues; 47 | - (void) setNextValue:(CGFloat)nextVal; 48 | - (void) setAllValues:(CGFloat)value; 49 | - (void) addOtherDataSetValues:(XRGDataSet *)otherDataSet; 50 | - (void) subtractOtherDataSetValues:(XRGDataSet *)otherDataSet; 51 | - (void) divideAllValuesBy:(CGFloat)dividend; 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /Utility/XRGFlippedView.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGFlippedView.h 25 | // 26 | 27 | #import 28 | 29 | NS_ASSUME_NONNULL_BEGIN 30 | 31 | @interface XRGFlippedView : NSView 32 | 33 | @end 34 | 35 | NS_ASSUME_NONNULL_END 36 | -------------------------------------------------------------------------------- /Utility/XRGFlippedView.m: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGFlippedView.m 25 | // 26 | 27 | #import "XRGFlippedView.h" 28 | 29 | @implementation XRGFlippedView 30 | 31 | - (BOOL)isFlipped { 32 | return YES; 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Utility/XRGModule.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGModule.h 25 | // 26 | 27 | 28 | #import 29 | 30 | @class XRGGenericView; 31 | 32 | @interface XRGModule : NSObject 33 | // Identifying variables 34 | @property (nonatomic) NSString *name; 35 | @property (nonatomic) XRGGenericView *reference; 36 | 37 | // Display variables 38 | @property (nonatomic) BOOL isDisplayed; 39 | @property (nonatomic) NSInteger displayOrder; 40 | 41 | // Size variables 42 | @property (nonatomic) CGFloat maxHeight; 43 | @property (nonatomic) CGFloat minHeight; 44 | @property (nonatomic) CGFloat minWidth; // none of the modules have a max width 45 | @property (nonatomic) NSSize currentSize; 46 | 47 | // Update variables 48 | @property (nonatomic) BOOL doesMin30Update; 49 | @property (nonatomic) BOOL doesMin5Update; 50 | @property (nonatomic) BOOL doesGraphUpdate; 51 | @property (nonatomic) BOOL doesFastUpdate; 52 | @property (nonatomic) BOOL alwaysDoesGraphUpdate; 53 | 54 | @property BOOL isEmptyModule; 55 | 56 | + (void) saveSizeForModule:(XRGModule *)module; 57 | + (NSSize) savedSizeForModule:(XRGModule *)module; 58 | 59 | - (XRGModule *)initWithName:(NSString *)n; 60 | - (XRGModule *)initWithName:(NSString *)n andReference:(XRGGenericView *)r; 61 | 62 | - (void)setName:(NSString *)n; 63 | - (void)setReference:(XRGGenericView *)r; 64 | 65 | - (void)setIsDisplayed:(BOOL)d; 66 | - (void)setDisplayOrder:(NSInteger)order; 67 | 68 | - (void)setMaxHeight:(CGFloat)h; 69 | - (void)setMinHeight:(CGFloat)h; 70 | - (void)setMinWidth:(CGFloat)w; 71 | - (void)setCurrentSize:(NSSize)newSize; 72 | 73 | - (void)setDoesMin30Update:(BOOL)yesNo; 74 | - (void)setDoesMin5Update:(BOOL)yesNo; 75 | - (void)setDoesGraphUpdate:(BOOL)yesNo; 76 | - (void)setDoesFastUpdate:(BOOL)yesNo; 77 | - (void)setAlwaysDoesGraphUpdate:(BOOL)yesNo; 78 | 79 | @end 80 | -------------------------------------------------------------------------------- /Utility/XRGModule.m: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGModule.m 25 | // 26 | 27 | 28 | #import "XRGModule.h" 29 | #import "XRGGenericView.h" 30 | 31 | @implementation XRGModule 32 | 33 | + (void) saveSizeForModule:(XRGModule *)module { 34 | if ([module name] == nil) return; 35 | 36 | NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 37 | [defaults setFloat:[module currentSize].width forKey:[NSString stringWithFormat:@"XRGModule_%@_width", [module name]]]; 38 | [defaults setFloat:[module currentSize].height forKey:[NSString stringWithFormat:@"XRGModule_%@_height", [module name]]]; 39 | [defaults synchronize]; 40 | } 41 | 42 | + (NSSize) savedSizeForModule:(XRGModule *)module { 43 | if ([module name] == nil) return NSMakeSize(55.0f, 65.0f); 44 | 45 | NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 46 | 47 | float width = [defaults floatForKey:[NSString stringWithFormat:@"XRGModule_%@_width", [module name]]]; 48 | if (width == 0 || !isfinite(width)) width = 55.f; 49 | 50 | float height = [defaults floatForKey:[NSString stringWithFormat:@"XRGModule_%@_height", [module name]]]; 51 | if (height == 0 || !isfinite(height)) height = 65.f; 52 | 53 | return NSMakeSize(width, height); 54 | } 55 | 56 | - (XRGModule *)init { 57 | if (self = [super init]) { 58 | self.name = nil; 59 | self.reference = nil; 60 | 61 | self.isDisplayed = YES; 62 | self.displayOrder = -1; 63 | 64 | self.maxHeight = 1000.0f; 65 | self.minHeight = 30.0f; 66 | self.minWidth = 30.0f; 67 | self.currentSize = [XRGModule savedSizeForModule:nil]; 68 | 69 | self.doesMin30Update = NO; 70 | self.doesMin5Update = NO; 71 | self.doesGraphUpdate = YES; 72 | self.doesFastUpdate = NO; 73 | self.alwaysDoesGraphUpdate = NO; 74 | 75 | self.isEmptyModule = YES; 76 | } 77 | 78 | return self; 79 | } 80 | 81 | - (XRGModule *)initWithName:(NSString *)n { 82 | if (self = [self init]) { 83 | self.name = n; 84 | self.currentSize = [XRGModule savedSizeForModule:self]; 85 | self.isEmptyModule = NO; 86 | } 87 | 88 | return self; 89 | } 90 | 91 | - (XRGModule *)initWithName:(NSString *)n andReference:(XRGGenericView *)r { 92 | if (self = [self init]) { 93 | self.name = n; 94 | self.reference = r; 95 | self.currentSize = [XRGModule savedSizeForModule:self]; 96 | self.isEmptyModule = NO; 97 | } 98 | 99 | return self; 100 | } 101 | 102 | - (void)setName:(NSString *)n { 103 | _name = n; 104 | if (_name) self.isEmptyModule = NO; 105 | } 106 | 107 | - (void)setReference:(XRGGenericView *)r { 108 | _reference = r; 109 | if (_reference) self.isEmptyModule = NO; 110 | } 111 | 112 | - (void)setIsDisplayed:(BOOL)d { 113 | _isDisplayed = d; 114 | self.isEmptyModule = NO; 115 | } 116 | 117 | - (void)setDisplayOrder:(NSInteger)order { 118 | _displayOrder = order; 119 | self.isEmptyModule = NO; 120 | } 121 | 122 | - (void)setMaxHeight:(CGFloat)h { 123 | _maxHeight = h; 124 | self.isEmptyModule = NO; 125 | } 126 | 127 | - (void)setMinHeight:(CGFloat)h { 128 | _minHeight = h; 129 | self.isEmptyModule = NO; 130 | } 131 | 132 | - (void)setMinWidth:(CGFloat)w { 133 | _minWidth = w; 134 | self.isEmptyModule = NO; 135 | } 136 | 137 | - (void)setCurrentSize:(NSSize)newSize { 138 | _currentSize = newSize; 139 | [XRGModule saveSizeForModule:self]; 140 | self.isEmptyModule = NO; 141 | } 142 | 143 | - (void)setDoesMin30Update:(BOOL)yesNo { 144 | _doesMin30Update = yesNo; 145 | self.isEmptyModule = NO; 146 | } 147 | 148 | - (void)setDoesMin5Update:(BOOL)yesNo { 149 | _doesMin5Update = yesNo; 150 | self.isEmptyModule = NO; 151 | } 152 | 153 | - (void)setDoesGraphUpdate:(BOOL)yesNo { 154 | _doesGraphUpdate = yesNo; 155 | self.isEmptyModule = NO; 156 | } 157 | 158 | - (void)setDoesFastUpdate:(BOOL)yesNo { 159 | _doesFastUpdate = yesNo; 160 | self.isEmptyModule = NO; 161 | } 162 | 163 | - (void)setAlwaysDoesGraphUpdate:(BOOL)yesNo { 164 | _alwaysDoesGraphUpdate = yesNo; 165 | self.isEmptyModule = NO; 166 | } 167 | 168 | @end 169 | -------------------------------------------------------------------------------- /Utility/XRGModuleManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGModuleManager.h 25 | // 26 | 27 | 28 | #import 29 | #import "XRGModule.h" 30 | 31 | @class XRGGraphWindow; 32 | 33 | @interface XRGModuleManager : NSObject { 34 | NSMutableArray *allModules; 35 | NSMutableArray *displayModules; 36 | NSMutableArray *alwaysUpdateModules; 37 | XRGGraphWindow *myWindow; 38 | } 39 | 40 | @property BOOL graphOrientationVertical; 41 | @property CGFloat moduleSeparatorWidth; 42 | 43 | - (XRGModuleManager *)initWithWindow:(XRGGraphWindow *)gw; 44 | 45 | - (void)addModule:(XRGModule *)m; 46 | - (void)updateModule:(XRGModule *)m; 47 | - (void)updateModuleWithName:(NSString *)name toReference:(id)graphView; 48 | - (void)setModule:(NSString *)name isDisplayed:(bool)yesNo; 49 | - (XRGModule *)getModuleByName:(NSString *)name; 50 | - (XRGModule *)getModuleByReference:(id)reference; 51 | - (NSArray *)moduleList; 52 | - (NSArray *)displayList; 53 | - (int)numModulesDisplayed; 54 | 55 | - (NSSize)getMinSize; 56 | - (void)redisplayModules; 57 | - (void)windowChangedToSize:(NSSize)newSize; 58 | - (void)graphFontChanged; 59 | 60 | - (void)min30Update; 61 | - (void)min5Update; 62 | - (void)graphUpdate; 63 | - (void)fastUpdate; 64 | 65 | - (float) resizeModuleNumber:(int)index byDelta:(float)delta; 66 | - (NSArray *) resizeRects; 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /Utility/XRGNonInteractableTextField.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGNonInteractableTextField.h 25 | // 26 | 27 | #import 28 | 29 | NS_ASSUME_NONNULL_BEGIN 30 | 31 | @interface XRGNonInteractableTextField : NSTextField 32 | 33 | @end 34 | 35 | NS_ASSUME_NONNULL_END 36 | -------------------------------------------------------------------------------- /Utility/XRGNonInteractableTextField.m: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGNonInteractableTextField.m 25 | // 26 | 27 | #import "XRGNonInteractableTextField.h" 28 | 29 | @implementation XRGNonInteractableTextField 30 | 31 | - (NSView *)hitTest:(NSPoint)point { 32 | return nil; 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Utility/XRGSettings.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGSettings.h 25 | // 26 | 27 | #import 28 | 29 | typedef NS_ENUM(NSInteger, XRGTemperatureUnits) { 30 | XRGTemperatureUnitsF = 0, 31 | XRGTemperatureUnitsC 32 | }; 33 | 34 | @interface XRGSettings : NSObject 35 | 36 | // Colors 37 | @property (nonatomic) NSColor *backgroundColor; 38 | @property (nonatomic) NSColor *graphBGColor; 39 | @property (nonatomic) NSColor *graphFG1Color; 40 | @property (nonatomic) NSColor *graphFG2Color; 41 | @property (nonatomic) NSColor *graphFG3Color; 42 | @property (nonatomic) NSColor *borderColor; 43 | @property (nonatomic) NSColor *textColor; 44 | 45 | // Transparencies 46 | @property (nonatomic) CGFloat backgroundTransparency; 47 | @property (nonatomic) CGFloat graphBGTransparency; 48 | @property (nonatomic) CGFloat graphFG1Transparency; 49 | @property (nonatomic) CGFloat graphFG2Transparency; 50 | @property (nonatomic) CGFloat graphFG3Transparency; 51 | @property (nonatomic) CGFloat borderTransparency; 52 | @property (nonatomic) CGFloat textTransparency; 53 | 54 | // Text attributes 55 | @property (nonatomic) NSFont *graphFont; 56 | @property CGFloat textRectHeight; 57 | @property NSMutableParagraphStyle *alignRight; 58 | @property NSMutableParagraphStyle *alignLeft; 59 | @property NSMutableParagraphStyle *alignCenter; 60 | @property NSMutableDictionary *alignRightAttributes; 61 | @property NSMutableDictionary *alignLeftAttributes; 62 | @property NSMutableDictionary *alignCenterAttributes; 63 | 64 | // Other user defined settings 65 | @property BOOL fastCPUUsage; 66 | @property BOOL separateCPUColor; 67 | @property BOOL showCPUTemperature; 68 | @property NSInteger cpuTemperatureUnits; 69 | @property BOOL antiAliasing; 70 | @property NSString *ICAO; 71 | @property NSInteger secondaryWeatherGraph; 72 | @property NSInteger temperatureUnits; 73 | @property NSInteger distanceUnits; 74 | @property NSInteger pressureUnits; 75 | @property BOOL showMemoryPagingGraph; 76 | @property BOOL memoryShowWired; 77 | @property BOOL memoryShowActive; 78 | @property BOOL memoryShowInactive; 79 | @property BOOL memoryShowFree; 80 | @property BOOL memoryShowCache; 81 | @property BOOL memoryShowPage; 82 | @property CGFloat graphRefresh; 83 | @property BOOL showLoadAverage; 84 | @property NSInteger netMinGraphScale; 85 | @property NSString *stockSymbols; 86 | @property NSInteger stockGraphTimeFrame; 87 | @property BOOL stockShowChange; 88 | @property BOOL showDJIA; 89 | @property NSInteger windowLevel; 90 | @property BOOL stickyWindow; 91 | @property BOOL checkForUpdates; 92 | @property NSInteger netGraphMode; 93 | @property NSInteger diskGraphMode; 94 | @property BOOL dropShadow; 95 | @property BOOL showTotalBandwidthSinceBoot; 96 | @property BOOL showTotalBandwidthSinceLoad; 97 | @property NSString *networkInterface; 98 | @property NSString *windowTitle; 99 | @property BOOL autoExpandGraph; 100 | @property BOOL foregroundWhenExpanding; 101 | @property BOOL showSummary; 102 | @property NSInteger minimizeUpDown; 103 | @property BOOL cpuShowAverageUsage; 104 | @property BOOL cpuShowUptime; 105 | @property XRGTemperatureUnits tempUnits; 106 | @property NSString *tempFG1Location; 107 | @property NSString *tempFG2Location; 108 | @property NSString *tempFG3Location; 109 | @property BOOL isDockIconHidden; 110 | 111 | - (void) readXTFDictionary:(NSDictionary *)xtfD; 112 | 113 | @end 114 | -------------------------------------------------------------------------------- /Utility/XRGStatsManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGStatsManager.h 25 | // 26 | 27 | #import 28 | #import "XRGDataSet.h" 29 | 30 | typedef NS_ENUM(NSInteger, XRGStatsModule) { 31 | XRGStatsModuleNameCPU, 32 | XRGStatsModuleNameGPU, 33 | XRGStatsModuleNameMemory, 34 | XRGStatsModuleNameTemperature, 35 | XRGStatsModuleNameBattery, 36 | XRGStatsModuleNameDisk, 37 | XRGStatsModuleNameNetwork, 38 | XRGStatsModuleNameWeather, 39 | XRGStatsModuleNameStock 40 | }; 41 | 42 | NS_ASSUME_NONNULL_BEGIN 43 | 44 | #pragma mark - XRGStatsContentItem 45 | @interface XRGStatsContentItem: NSObject 46 | 47 | @property NSString *key; 48 | 49 | @property double last; 50 | @property double min; 51 | @property double max; 52 | @property double average; 53 | 54 | - (instancetype)initWithKey:(NSString *)key initialValue:(double)initialValue; 55 | - (void)observeStat:(double)value; 56 | 57 | @end 58 | 59 | 60 | #pragma mark - XRGStatsModuleContent 61 | @interface XRGStatsModuleContent: NSObject 62 | 63 | - (NSArray *)keys; 64 | 65 | - (nullable XRGStatsContentItem *)statsForKey:(NSString *)key; 66 | - (void)observeStat:(double)value forKey:(NSString *)key; 67 | 68 | @end 69 | 70 | 71 | #pragma mark - XRGStatsManager 72 | @interface XRGStatsManager : NSObject 73 | 74 | + (instancetype)shared; 75 | 76 | - (void)clearHistory; 77 | - (void)clearHistoryForModule:(XRGStatsModule)module; 78 | 79 | - (nullable XRGStatsContentItem *)statForKey:(NSString *)key inModule:(XRGStatsModule)module; 80 | - (void)observeStat:(double)value forKey:(NSString *)key inModule:(XRGStatsModule)module; 81 | 82 | @end 83 | 84 | NS_ASSUME_NONNULL_END 85 | -------------------------------------------------------------------------------- /Utility/XRGStatsManager.m: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGStatsManager.m 25 | // 26 | 27 | #import "XRGStatsManager.h" 28 | 29 | #pragma mark - XRGStatsManager 30 | @interface XRGStatsManager () 31 | 32 | @property NSDictionary *modulesContent; 33 | 34 | @end 35 | 36 | @implementation XRGStatsManager 37 | 38 | + (NSString *)nameOfModule:(XRGStatsModule)module { 39 | switch (module) { 40 | case XRGStatsModuleNameCPU: 41 | return @"XRG_CPU"; 42 | 43 | case XRGStatsModuleNameGPU: 44 | return @"XRG_GPU"; 45 | 46 | case XRGStatsModuleNameMemory: 47 | return @"XRG_Memory"; 48 | 49 | case XRGStatsModuleNameTemperature: 50 | return @"XRG_Temperature"; 51 | 52 | case XRGStatsModuleNameBattery: 53 | return @"XRG_Battery"; 54 | 55 | case XRGStatsModuleNameDisk: 56 | return @"XRG_Disk"; 57 | 58 | case XRGStatsModuleNameNetwork: 59 | return @"XRG_Network"; 60 | 61 | case XRGStatsModuleNameWeather: 62 | return @"XRG_Weather"; 63 | 64 | case XRGStatsModuleNameStock: 65 | return @"XRG_Stock"; 66 | 67 | } 68 | } 69 | 70 | + (instancetype)shared { 71 | static XRGStatsManager *sharedManager = nil; 72 | 73 | static dispatch_once_t onceToken; 74 | dispatch_once(&onceToken, ^{ 75 | sharedManager = [[XRGStatsManager alloc] init]; 76 | }); 77 | 78 | return sharedManager; 79 | } 80 | 81 | - (instancetype)init { 82 | self = [super init]; 83 | if (self) { 84 | self.modulesContent = [NSDictionary dictionary]; 85 | } 86 | return self; 87 | } 88 | 89 | - (void)clearHistory { 90 | self.modulesContent = [NSDictionary dictionary]; 91 | } 92 | 93 | - (void)clearHistoryForModule:(XRGStatsModule)module { 94 | NSString *moduleName = [XRGStatsManager nameOfModule:module]; 95 | 96 | NSMutableDictionary *newStats = [self.modulesContent mutableCopy]; 97 | [newStats removeObjectForKey:moduleName]; 98 | self.modulesContent = newStats; 99 | } 100 | 101 | - (XRGStatsContentItem *)statForKey:(NSString *)key inModule:(XRGStatsModule)module { 102 | return [[self contentForModule:module] statsForKey:key]; 103 | } 104 | 105 | - (void)observeStat:(double)value forKey:(NSString *)key inModule:(XRGStatsModule)module { 106 | [[self contentForModule:module] observeStat:value forKey:key]; 107 | } 108 | 109 | - (XRGStatsModuleContent *)contentForModule:(XRGStatsModule)module { 110 | NSString *moduleName = [XRGStatsManager nameOfModule:module]; 111 | 112 | XRGStatsModuleContent *content = self.modulesContent[moduleName]; 113 | if (content) return content; 114 | 115 | XRGStatsModuleContent *newContent = [[XRGStatsModuleContent alloc] init]; 116 | 117 | NSMutableDictionary *newModulesContent = [self.modulesContent mutableCopy]; 118 | newModulesContent[moduleName] = newContent; 119 | self.modulesContent = newModulesContent; 120 | 121 | return newContent; 122 | } 123 | 124 | @end 125 | 126 | 127 | #pragma mark - XRGStatsModuleContent 128 | @interface XRGStatsModuleContent () 129 | 130 | @property NSDictionary *items; 131 | 132 | @end 133 | 134 | @implementation XRGStatsModuleContent: NSObject 135 | 136 | - (instancetype)init { 137 | self = [super init]; 138 | if (self) { 139 | self.items = [NSDictionary dictionary]; 140 | } 141 | return self; 142 | } 143 | 144 | - (NSArray *)keys { 145 | return self.items.allKeys; 146 | } 147 | 148 | - (nullable XRGStatsContentItem *)statsForKey:(NSString *)key { 149 | return self.items[key]; 150 | } 151 | 152 | - (void)observeStat:(double)value forKey:(NSString *)key { 153 | XRGStatsContentItem *item = [self statItemForKey:key initialValue:value]; 154 | 155 | [item observeStat:value]; 156 | } 157 | 158 | #pragma mark Private 159 | - (XRGStatsContentItem *)statItemForKey:(NSString *)key initialValue:(double)initialValue { 160 | XRGStatsContentItem *existingItem = self.items[key]; 161 | if (existingItem) return existingItem; 162 | 163 | XRGStatsContentItem *newItem = [[XRGStatsContentItem alloc] initWithKey:key initialValue:initialValue]; 164 | 165 | NSMutableDictionary *newItems = [self.items mutableCopy]; 166 | newItems[key] = newItem; 167 | self.items = newItems; 168 | 169 | return newItem; 170 | } 171 | 172 | @end 173 | 174 | 175 | #pragma mark - XRGStatsContentItem 176 | @interface XRGStatsContentItem () 177 | @property NSUInteger statsObservedCount; 178 | @end 179 | 180 | @implementation XRGStatsContentItem 181 | 182 | - (instancetype)initWithKey:(NSString *)key initialValue:(double)initialValue { 183 | self = [super init]; 184 | if (self) { 185 | self.key = key; 186 | self.last = initialValue; 187 | self.min = initialValue; 188 | self.max = initialValue; 189 | self.average = initialValue; 190 | self.statsObservedCount = 1; 191 | } 192 | return self; 193 | } 194 | 195 | - (void)observeStat:(double)value { 196 | if (value < self.min) { 197 | self.min = value; 198 | } 199 | if (value > self.max) { 200 | self.max = value; 201 | } 202 | 203 | self.average = (self.average * self.statsObservedCount + value) / (self.statsObservedCount + 1); 204 | self.statsObservedCount++; 205 | 206 | self.last = value; 207 | } 208 | 209 | @end 210 | -------------------------------------------------------------------------------- /Utility/XRGStock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGStock.h 25 | // 26 | 27 | #import 28 | #import "XRGURL.h" 29 | 30 | @interface XRGStock : NSObject 31 | 32 | @property (nullable,readonly) NSString *label; 33 | @property (nullable,nonatomic) NSString *symbol; 34 | 35 | @property (nullable) NSURL *sURL; 36 | @property (nullable) NSURL *immediateURL; 37 | 38 | @property CGFloat currentPrice; 39 | @property CGFloat lastChange; 40 | /// 52 week high 41 | @property CGFloat highWeekPrice; 42 | /// 52 week low 43 | @property CGFloat lowWeekPrice; 44 | 45 | @property BOOL gettingData; 46 | @property BOOL haveGoodURL; 47 | @property BOOL haveGoodStockArray; 48 | @property BOOL haveGoodDisplayData; 49 | 50 | @property (nullable) NSArray *closingPrices; 51 | 52 | - (void)resetData; 53 | - (void)loadData; 54 | 55 | - (nullable NSArray *)get1MonthValues; 56 | - (nullable NSArray *)get3MonthValues; 57 | - (nullable NSArray *)get6MonthValues; 58 | - (nullable NSArray *)get12MonthValues; 59 | - (nullable NSArray *)getCurrentPriceAndChange; 60 | 61 | - (nonnull NSString *)priceString; 62 | - (nonnull NSString *)changeString; 63 | 64 | - (BOOL)errorOccurred; 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /Utility/XRGURL.h: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGURL.h 25 | // 26 | 27 | #import 28 | 29 | enum { 30 | XRGURLCacheIgnore, // Ignore the cache and force a reload. 31 | XRGURLCacheUse, // Use the cache, but if not available load from online. 32 | XRGURLCacheOnly // Try the cache, and do not attempt to load from online. 33 | }; 34 | typedef int XRGURLCacheMode; 35 | 36 | @interface XRGURL : NSObject 37 | @property NSURLConnection *urlConnection; 38 | @property (setter=setURL:) NSURL *url; 39 | @property (nonatomic,setter=setURLString:) NSString *urlString; 40 | @property (getter=getData) NSMutableData *urlData; 41 | 42 | @property BOOL isLoading; 43 | @property (getter=isDataReady) BOOL dataReady; 44 | @property (getter=didErrorOccur) BOOL errorOccurred; 45 | 46 | @property XRGURLCacheMode cacheMode; 47 | 48 | - (id) initWithURLString:(NSString *)urlS; 49 | 50 | #pragma mark Getter/Setters 51 | - (NSString *) urlString; 52 | - (void) setURLString:(NSString *)newString; 53 | + (NSString *) userAgent; 54 | + (void) setUserAgent:(NSString *)newAgent; 55 | - (void) setCacheMode:(XRGURLCacheMode)mode; 56 | - (NSMutableData *) getData; 57 | - (void) setData:(NSData *)newData; 58 | - (void) appendData:(NSData *)appendData; 59 | 60 | - (void) setURLConnection:(NSURLConnection *)newConnection; 61 | - (void) setUserAgentForRequest:(NSMutableURLRequest *)request; 62 | 63 | #pragma mark Action Methods 64 | - (void) loadURLInForeground; 65 | - (void) loadURLInBackground; 66 | - (BOOL) prepareForURLLoad; 67 | - (void) cancelLoading; 68 | 69 | #pragma mark Status Methods 70 | - (BOOL) haveGoodURL; 71 | 72 | #pragma mark Notifications 73 | 74 | @end 75 | -------------------------------------------------------------------------------- /Utility/XRGURL.m: -------------------------------------------------------------------------------- 1 | /* 2 | * XRG (X Resource Graph): A system resource grapher for Mac OS X. 3 | * Copyright (C) 2002-2022 Gaucho Software, LLC. 4 | * You can view the complete license in the LICENSE file in the root 5 | * of the source tree. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | */ 22 | 23 | // 24 | // XRGURL.m 25 | // 26 | 27 | #import "XRGURL.h" 28 | 29 | NSString *userAgent = nil; 30 | 31 | @implementation XRGURL 32 | - (instancetype) init { 33 | if (self = [super init]) { 34 | _urlConnection = nil; 35 | _url = nil; 36 | _urlString = nil; 37 | _urlData = nil; 38 | _isLoading = NO; 39 | _dataReady = NO; 40 | _errorOccurred = NO; 41 | _cacheMode = XRGURLCacheIgnore; 42 | } 43 | 44 | return self; 45 | } 46 | 47 | - (instancetype) initWithURLString:(NSString *)urlS { 48 | if (self = [self init]) { 49 | [self setURLString:urlS]; 50 | } 51 | 52 | return self; 53 | } 54 | 55 | - (void) dealloc { 56 | [self setURL:nil]; 57 | [self setData:nil]; 58 | [self setURLString:nil]; 59 | [self setURLConnection:nil]; 60 | } 61 | 62 | #pragma mark Getter/Setters 63 | - (void) setURLString:(NSString *)newString { 64 | if (newString != _urlString) { 65 | _urlString = newString; 66 | 67 | // Need to reset our URL object now. 68 | if ([_urlString length] > 0) { 69 | [self setURL:[NSURL URLWithString:_urlString]]; 70 | } 71 | else { 72 | [self setURL:nil]; 73 | } 74 | } 75 | } 76 | 77 | + (NSString *) userAgent { 78 | return userAgent; 79 | } 80 | 81 | + (void) setUserAgent:(NSString *)newAgent { 82 | userAgent = newAgent; 83 | } 84 | 85 | - (void) setData:(NSData *)newData { 86 | NSMutableData *newMutableData = newData ? [NSMutableData dataWithData:newData] : nil; 87 | 88 | _urlData = newMutableData; 89 | } 90 | 91 | - (void) appendData:(NSData *)appendData { 92 | if (_urlData != nil) { 93 | [_urlData appendData:appendData]; 94 | } 95 | else { 96 | [self setData:[NSMutableData dataWithLength:0]]; 97 | [_urlData appendData:appendData]; 98 | } 99 | } 100 | 101 | - (void) setURLConnection:(NSURLConnection *)newConnection { 102 | if (_urlConnection != newConnection) { 103 | if (_urlConnection) { 104 | [_urlConnection cancel]; 105 | } 106 | _urlConnection = newConnection; 107 | } 108 | } 109 | 110 | - (void) setUserAgentForRequest:(NSMutableURLRequest *)request { 111 | if ([XRGURL userAgent] != nil) { 112 | [request setValue:[XRGURL userAgent] forHTTPHeaderField:@"User-Agent"]; 113 | } 114 | } 115 | 116 | #pragma mark Action Methods 117 | - (void) loadURLInForeground { 118 | if (![self prepareForURLLoad]) { 119 | self.errorOccurred = YES; 120 | return; 121 | } 122 | 123 | #ifdef XRG_DEBUG 124 | NSLog(@"[XRGURL loadURLInForeground] Loading URL: %@", urlString); 125 | #endif 126 | 127 | if (self.cacheMode == XRGURLCacheIgnore) { 128 | NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:self.url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60]; 129 | [self setUserAgentForRequest:request]; 130 | [self setData:[NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]]; 131 | } 132 | else if (self.cacheMode == XRGURLCacheUse) { 133 | NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:self.url cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:60]; 134 | [self setUserAgentForRequest:request]; 135 | [self setData:[NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]]; 136 | } 137 | else if (self.cacheMode == XRGURLCacheOnly) { 138 | NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:self.url cachePolicy:NSURLRequestReturnCacheDataDontLoad timeoutInterval:60]; 139 | [self setUserAgentForRequest:request]; 140 | [self setData:[NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]]; 141 | } 142 | 143 | if (_urlData == nil) self.errorOccurred = YES; 144 | 145 | #ifdef XRG_DEBUG 146 | NSLog(@"[XRGURL loadURLInForeground] Finished loading URL: %@", urlString); 147 | #endif 148 | 149 | self.dataReady = YES; 150 | } 151 | 152 | - (void) loadURLInBackground { 153 | if (![self prepareForURLLoad]) { 154 | self.errorOccurred = YES; 155 | return; 156 | } 157 | 158 | #ifdef XRG_DEBUG 159 | NSLog(@"[XRGURL] Started Background Loading %@", urlString); 160 | #endif 161 | 162 | self.isLoading = YES; 163 | 164 | if (self.cacheMode == XRGURLCacheIgnore) { 165 | NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:self.url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60]; 166 | [self setUserAgentForRequest:request]; 167 | 168 | NSURLConnection *connection = [NSURLConnection connectionWithRequest:request delegate:self]; 169 | [self setURLConnection:connection]; 170 | } 171 | else if (self.cacheMode == XRGURLCacheUse) { 172 | NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:self.url cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:60]; 173 | [self setUserAgentForRequest:request]; 174 | 175 | NSURLConnection *connection = [NSURLConnection connectionWithRequest:request delegate:self]; 176 | [self setURLConnection:connection]; 177 | } 178 | else if (self.cacheMode == XRGURLCacheOnly) { 179 | // Do a cache-only request. 180 | NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:self.url cachePolicy:NSURLRequestReturnCacheDataDontLoad timeoutInterval:60]; 181 | [self setUserAgentForRequest:request]; 182 | 183 | NSURLConnection *connection = [NSURLConnection connectionWithRequest:request delegate:self]; 184 | [self setURLConnection:connection]; 185 | } 186 | } 187 | 188 | // Returns whether or not the URL is ready to load. 189 | - (BOOL) prepareForURLLoad { 190 | // Check to make sure we have a valid NSURL object. 191 | if (self.urlString == nil) { 192 | #ifdef XRG_DEBUG 193 | NSLog(@"[XRGURL prepareForURLLoad] Error: Attempted to load URL with empty URL String."); 194 | #endif 195 | return NO; 196 | } 197 | 198 | if (self.url == nil) { 199 | [self setURL:[NSURL URLWithString:self.urlString]]; 200 | 201 | if (self.url == nil) { 202 | #ifdef XRG_DEBUG 203 | NSLog(@"[XRGURL prepareForURLLoad] Error: Failed to initialize NSURL with urlString: %@.", urlString); 204 | #endif 205 | return NO; 206 | } 207 | } 208 | 209 | // Clear out the old data. 210 | self.dataReady = NO; 211 | self.errorOccurred = NO; 212 | [self setData:nil]; 213 | 214 | return YES; 215 | } 216 | 217 | - (void) cancelLoading { 218 | if (self.urlConnection != nil) [self.urlConnection cancel]; 219 | 220 | [self setData:nil]; 221 | 222 | self.errorOccurred = NO; 223 | self.dataReady = NO; 224 | self.isLoading = NO; 225 | } 226 | 227 | #pragma mark Status Methods 228 | - (BOOL) haveGoodURL { 229 | return (self.url != nil); 230 | } 231 | 232 | #pragma mark Notifications 233 | - (void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { 234 | if (self.urlConnection == connection) { 235 | [self appendData:data]; 236 | } 237 | else { 238 | #ifdef XRG_DEBUG 239 | NSLog(@"[XRGURL] Hmm, we got data but the connections didn't match"); 240 | #endif 241 | } 242 | } 243 | 244 | -(void) connectionDidFinishLoading:(NSURLConnection *)connection { 245 | if (self.urlConnection == connection) { 246 | self.dataReady = YES; 247 | self.isLoading = NO; 248 | 249 | #ifdef XRG_DEBUG 250 | NSLog(@"[XRGURL] Finished Loading %@", urlString); 251 | #endif 252 | } 253 | else { 254 | #ifdef XRG_DEBUG 255 | NSLog(@"[XRGURL] Hmm, we finished loading but the connections didn't match"); 256 | #endif 257 | } 258 | } 259 | 260 | - (void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { 261 | #ifdef XRG_DEBUG 262 | NSLog(@"[XRGURL] Failed Loading %@: %@", urlString, [error localizedDescription]); 263 | #endif 264 | 265 | self.isLoading = NO; 266 | self.errorOccurred = YES; 267 | } 268 | 269 | // Request got redirected. 270 | - (NSURLRequest *) connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse { 271 | #ifdef XRG_DEBUG 272 | NSLog(@"[XRGURL] Connection is redirecting."); 273 | #endif 274 | 275 | return request; 276 | } 277 | 278 | @end 279 | -------------------------------------------------------------------------------- /XRG-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDocumentTypes 8 | 9 | 10 | CFBundleTypeExtensions 11 | 12 | xtf 13 | 14 | CFBundleTypeIconFile 15 | xtf 16 | CFBundleTypeName 17 | XRGThemeFile 18 | CFBundleTypeRole 19 | Editor 20 | 21 | 22 | CFBundleExecutable 23 | ${EXECUTABLE_NAME} 24 | CFBundleHelpBookFolder 25 | Online Help 26 | CFBundleHelpBookName 27 | XRG Help 28 | CFBundleIconFile 29 | icon.icns 30 | CFBundleIdentifier 31 | $(PRODUCT_BUNDLE_IDENTIFIER) 32 | CFBundleInfoDictionaryVersion 33 | 6.0 34 | CFBundleName 35 | ${PRODUCT_NAME} 36 | CFBundlePackageType 37 | APPL 38 | CFBundleShortVersionString 39 | $(MARKETING_VERSION) 40 | CFBundleSignature 41 | ???? 42 | CFBundleVersion 43 | $(CURRENT_PROJECT_VERSION) 44 | LSApplicationCategoryType 45 | public.app-category.utilities 46 | LSMinimumSystemVersion 47 | ${MACOSX_DEPLOYMENT_TARGET} 48 | LSUIElement 49 | 50 | NSAppTransportSecurity 51 | 52 | NSAllowsArbitraryLoads 53 | 54 | 55 | NSHumanReadableCopyright 56 | Copyright © 2002-2023 Gaucho Software, LLC. All rights reserved. 57 | NSMainNibFile 58 | MainMenu 59 | NSPrincipalClass 60 | NSApplication 61 | 62 | 63 | -------------------------------------------------------------------------------- /XRG.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | --------------------------------------------------------------------------------