Skip to content

Commit

Permalink
Merge pull request #18 from LauraAubin/decrease-NI-with-button
Browse files Browse the repository at this point in the history
Create button and functions for decreasing NI
  • Loading branch information
LauraAubin authored Apr 1, 2018
2 parents f2b5dbc + d132eb1 commit 03c9aa4
Show file tree
Hide file tree
Showing 10 changed files with 165 additions and 16 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Fuji/ProcessController.m"
timestampString = "544147462.202255"
timestampString = "544246808.67404"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "14"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0920"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "77E620B8205F519C00DBBFED"
BuildableName = "Fuji.app"
BlueprintName = "Fuji"
ReferencedContainer = "container:Fuji.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "77E620CB205F519C00DBBFED"
BuildableName = "FujiTests.xctest"
BlueprintName = "FujiTests"
ReferencedContainer = "container:Fuji.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "77E620D6205F519C00DBBFED"
BuildableName = "FujiUITests.xctest"
BlueprintName = "FujiUITests"
ReferencedContainer = "container:Fuji.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "77E620B8205F519C00DBBFED"
BuildableName = "Fuji.app"
BlueprintName = "Fuji"
ReferencedContainer = "container:Fuji.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "77E620B8205F519C00DBBFED"
BuildableName = "Fuji.app"
BlueprintName = "Fuji"
ReferencedContainer = "container:Fuji.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "77E620B8205F519C00DBBFED"
BuildableName = "Fuji.app"
BlueprintName = "Fuji"
ReferencedContainer = "container:Fuji.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,23 @@
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>77E620B8205F519C00DBBFED</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>77E620CB205F519C00DBBFED</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>77E620D6205F519C00DBBFED</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
12 changes: 12 additions & 0 deletions Fuji/Fuji/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
</customObject>
<customObject id="Ce5-pz-z4z" customClass="ViewController">
<connections>
<outlet property="decreasingProcessPriorityDisplay" destination="jqx-Of-MSA" id="5eS-uG-LE7"/>
<outlet property="increasingProcessPriorityDisplay" destination="jqx-Of-MSA" id="VQf-tB-qBz"/>
</connections>
</customObject>
Expand Down Expand Up @@ -815,6 +816,17 @@
<action selector="increaseSelectedNI:" target="Ce5-pz-z4z" id="bnN-2D-pKB"/>
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="5aE-YY-SuQ">
<rect key="frame" x="237" y="83" width="84" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Decrease" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Iai-lg-MpB">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="decreaseSelectedNI:" target="Ce5-pz-z4z" id="o9m-iq-OGR"/>
</connections>
</button>
</subviews>
</view>
<point key="canvasLocation" x="139" y="541"/>
Expand Down
7 changes: 1 addition & 6 deletions Fuji/Fuji/Fuji.entitlements
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
</dict>
<dict/>
</plist>
4 changes: 1 addition & 3 deletions Fuji/Fuji/ProcessController.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
#import <Foundation/Foundation.h>
#import "ProcessController.h"
#import <Cocoa/Cocoa.h>
#include <sys/time.h>
#include <sys/resource.h>

extern int CurrentlySelectedProcessID; // access the global variable declared in main

Expand All @@ -18,7 +16,7 @@ @implementation ProcessController
- (void)applicationDidBecomeActive:(NSNotification *)notification
{
[self.arrayOfRunningProcesses rearrangeObjects];
// NSLog(@"Array: %@", _arrayOfRunningProcesses);
// NSLog(@"Array: %@", _arrayOfRunningProcesses);
}

- (NSWorkspace *)workspace;
Expand Down
2 changes: 2 additions & 0 deletions Fuji/Fuji/ViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@

@interface ViewController : NSViewController
- (IBAction)increaseSelectedNI:(id)sender;
- (IBAction)decreaseSelectedNI:(id)sender;

@property (strong) IBOutlet NSTextField *increasingProcessPriorityDisplay;
@property (strong) IBOutlet NSTextField *decreasingProcessPriorityDisplay;

- (int)getCurrentProcessPriority;
@end
Expand Down
22 changes: 17 additions & 5 deletions Fuji/Fuji/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,35 @@
#import "ProcessController.h"
#import "ViewController.h"
#import <Cocoa/Cocoa.h>
#include <sys/time.h>
#include <sys/resource.h>

extern int CurrentlySelectedProcessID;

//@synthesize *currentProcessNiceness;

@implementation ViewController

- (IBAction)increaseSelectedNI:(id)sender {
int increasedPriority = [self getCurrentProcessPriority] + 1;

setpriority(PRIO_PROCESS, CurrentlySelectedProcessID, increasedPriority);

// convert an int to a string
NSString *currentProcessPriorityString = [NSString stringWithFormat:@"%d", [self getCurrentProcessPriority]];

_increasingProcessPriorityDisplay.stringValue = currentProcessPriorityString;
}

- (IBAction)decreaseSelectedNI:(id)sender {
int decreasedPriority = [self getCurrentProcessPriority] - 1;

setpriority(PRIO_PROCESS, CurrentlySelectedProcessID, decreasedPriority);

// convert an int to a string
NSString *currentProcessPriorityString = [NSString stringWithFormat:@"%d", [self getCurrentProcessPriority]];

_decreasingProcessPriorityDisplay.stringValue = currentProcessPriorityString;
}

- (int)getCurrentProcessPriority; {
return getpriority(PRIO_PROCESS, CurrentlySelectedProcessID);
}
Expand Down
1 change: 0 additions & 1 deletion Fuji/Fuji/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
int CurrentlySelectedProcessID = 0;

int main(int argc, const char * argv[]) {

ProcessController* processControllerInstance = [[ProcessController alloc] init];

NSWorkspace* workspaceInstance = [processControllerInstance workspace];
Expand Down

0 comments on commit 03c9aa4

Please sign in to comment.