Skip to content
This repository has been archived by the owner on May 8, 2018. It is now read-only.

Commit

Permalink
Fixed Issue #27
Browse files Browse the repository at this point in the history
  • Loading branch information
Eun committed May 26, 2015
1 parent 5022489 commit 0b14b42
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Easily disable, enable or change the resolution of a monitor!

![](https://raw.githubusercontent.com/Eun/DisableMonitor/res/screenshot1.png)

[![Download](https://raw.githubusercontent.com/Eun/DisableMonitor/res/download.png)] (https://github.com/Eun/DisableMonitor/releases/)
[![Download](https://raw.githubusercontent.com/Eun/DisableMonitor/res/download.png)](https://github.com/Eun/DisableMonitor/releases/)

Console Usage
============
Expand Down Expand Up @@ -43,9 +43,17 @@ Contribution
You can contribute to this project! Just create a fork, do the changes and do a pull request.
Add new features, languages or what ever you think could enhance the app.

Building
========

Building requires the [OSX 10.6 Framework](https://github.com/Eun/Mac_OSX_SDKs)

Changelog
=========

1.92:
* Issue #27 Fixed

1.9:
* Automatic update checks
* Code cleaning
Expand Down
2 changes: 1 addition & 1 deletion main.m
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/** * DisableMonitor, Disable Monitors on Mac * * Copyright (C) 2014 Tobias Salzmann * * DisableMonitor is free software: you can redistribute it and/or modify it under the terms of the * GNU General Public License as published by the Free Software Foundation, either version 2 of the * License, or (at your option) any later version. * * DisableMonitor is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. You should have received a copy of the GNU * General Public License along with DisableMonitor. If not, see <http://www.gnu.org/licenses/>. * * Authors: Tobias Salzmann */#import <Cocoa/Cocoa.h>#import "MonitorDataSource.h"#import "DisableMonitorAppDelegate.h"#import "DisplayIDAndName.h"void cmd_list(NSString* arg){ NSMutableArray *dict = [MonitorDataSource GetSortedDisplays]; if (dict == nil) { printf("No Displays found"); } else { printf(" ID Name\n"); printf("----------- -----------------\n"); for (DisplayIDAndName* idAndName in dict) { printf(" %-10u %s\n", [idAndName id], [[idAndName name] UTF8String]); } printf("----------- -----------------\n"); [dict release]; }}void cmd_disable(NSString *arg){ if ([arg length] < 2) return; CGDirectDisplayID displayID = [[NSUserDefaults standardUserDefaults] integerForKey:[arg substringFromIndex:1]]; if (CGDisplayIsOnline(displayID) && CGDisplayIsActive(displayID)) { [DisableMonitorAppDelegate toggleMonitor:displayID enabled:NO]; }}void cmd_enable(NSString *arg){ if ([arg length] < 2) return; CGDirectDisplayID displayID = [[NSUserDefaults standardUserDefaults] integerForKey:[arg substringFromIndex:1]]; if (CGDisplayIsOnline(displayID) && !CGDisplayIsActive(displayID)) [DisableMonitorAppDelegate toggleMonitor:displayID enabled:YES]; }void cmd_help(NSString *arg){ printf( "usage: DisableMonitor [options]\n" \ "Options:\n" \ "-l, --list list all attached monitors\n" \ "-d, --disable ID disable monitor with specified id\n" \ "-e, --enable ID enable monitor with specified id\n" \ "-h, --help show this help\n");}int main(int argc, char *argv[]){ NSArray *arguments = [[NSProcessInfo processInfo] arguments]; for (NSString* arg in arguments) { if ([arg caseInsensitiveCompare:@"--list"] == NSOrderedSame || [arg caseInsensitiveCompare:@"-list"] == NSOrderedSame || [arg caseInsensitiveCompare:@"-l"] == NSOrderedSame) { cmd_list(arg); return 0; } else if ([arg caseInsensitiveCompare:@"--disable"] == NSOrderedSame || [arg caseInsensitiveCompare:@"-disable"] == NSOrderedSame || [arg caseInsensitiveCompare:@"-d"] == NSOrderedSame) { cmd_disable(arg); return 0; } else if ([arg caseInsensitiveCompare:@"--enable"] == NSOrderedSame || [arg caseInsensitiveCompare:@"-enable"] == NSOrderedSame || [arg caseInsensitiveCompare:@"-e"] == NSOrderedSame) { cmd_enable(arg); return 0; } else if ([arg caseInsensitiveCompare:@"--help"] == NSOrderedSame || [arg caseInsensitiveCompare:@"-help"] == NSOrderedSame || [arg caseInsensitiveCompare:@"-h"] == NSOrderedSame) { cmd_help(arg); return 0; } } return NSApplicationMain(argc, (const char **) argv);}
/** * DisableMonitor, Disable Monitors on Mac * * Copyright (C) 2014 Tobias Salzmann * * DisableMonitor is free software: you can redistribute it and/or modify it under the terms of the * GNU General Public License as published by the Free Software Foundation, either version 2 of the * License, or (at your option) any later version. * * DisableMonitor is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. You should have received a copy of the GNU * General Public License along with DisableMonitor. If not, see <http://www.gnu.org/licenses/>. * * Authors: Tobias Salzmann */#import <Cocoa/Cocoa.h>#import "MonitorDataSource.h"#import "DisableMonitorAppDelegate.h"#import "DisplayIDAndName.h"int cmd_list(NSString* arg){ NSMutableArray *dict = [MonitorDataSource GetSortedDisplays]; if (dict == nil) { printf("No Displays found"); } else { printf(" ID Name\n"); printf("----------- -----------------\n"); for (DisplayIDAndName* idAndName in dict) { printf(" %-10u %s\n", [idAndName id], [[idAndName name] UTF8String]); } printf("----------- -----------------\n"); [dict release]; } return 0;}int cmd_disable(NSString *arg){ if ([arg length] < 2) return 1; CGDisplayCount nDisplays = 0; CGDirectDisplayID displayList[0x10]; CGDisplayErr err = CGSGetDisplayList(0x10, displayList, &nDisplays); CGDirectDisplayID displayID = [[NSUserDefaults standardUserDefaults] integerForKey:[arg substringFromIndex:1]]; if (err == 0 && nDisplays > 0) { for (int i = 0; i < nDisplays; i++) { if (displayList[i] == displayID) { if (CGDisplayIsOnline(displayID) && CGDisplayIsActive(displayID)) { [DisableMonitorAppDelegate toggleMonitor:displayID enabled:NO]; return 1; } } } } printf("Could not find display %u!\n", displayID); return 0;}int cmd_enable(NSString *arg){ if ([arg length] < 2) return 1; CGDisplayCount nDisplays = 0; CGDirectDisplayID displayList[0x10]; CGDisplayErr err = CGSGetDisplayList(0x10, displayList, &nDisplays); CGDirectDisplayID displayID = [[NSUserDefaults standardUserDefaults] integerForKey:[arg substringFromIndex:1]]; if (err == 0 && nDisplays > 0) { for (int i = 0; i < nDisplays; i++) { if (displayList[i] == displayID) { if (CGDisplayIsOnline(displayID) && !CGDisplayIsActive(displayID)) { [DisableMonitorAppDelegate toggleMonitor:displayID enabled:YES]; return 0; } } } } printf("Could not find display %u!\n", displayID); return 1; }int cmd_help(NSString *arg){ printf( "usage: DisableMonitor [options]\n" \ "Options:\n" \ "-l, --list list all attached monitors\n" \ "-d, --disable ID disable monitor with specified id\n" \ "-e, --enable ID enable monitor with specified id\n" \ "-h, --help show this help\n"); return 0;}int main(int argc, char *argv[]){ NSArray *arguments = [[NSProcessInfo processInfo] arguments]; for (NSString* arg in arguments) { if ([arg caseInsensitiveCompare:@"--list"] == NSOrderedSame || [arg caseInsensitiveCompare:@"-list"] == NSOrderedSame || [arg caseInsensitiveCompare:@"-l"] == NSOrderedSame) { return cmd_list(arg); return 0; } else if ([arg caseInsensitiveCompare:@"--disable"] == NSOrderedSame || [arg caseInsensitiveCompare:@"-disable"] == NSOrderedSame || [arg caseInsensitiveCompare:@"-d"] == NSOrderedSame) { return cmd_disable(arg); } else if ([arg caseInsensitiveCompare:@"--enable"] == NSOrderedSame || [arg caseInsensitiveCompare:@"-enable"] == NSOrderedSame || [arg caseInsensitiveCompare:@"-e"] == NSOrderedSame) { return cmd_enable(arg); } else if ([arg caseInsensitiveCompare:@"--help"] == NSOrderedSame || [arg caseInsensitiveCompare:@"-help"] == NSOrderedSame || [arg caseInsensitiveCompare:@"-h"] == NSOrderedSame) { return cmd_help(arg); } } return NSApplicationMain(argc, (const char **) argv);}
Expand Down

0 comments on commit 0b14b42

Please sign in to comment.