From ed3fe136017372c165178e084c56ec83db3887fa Mon Sep 17 00:00:00 2001 From: Barry Nelson Date: Tue, 2 Apr 2019 13:32:07 -0400 Subject: [PATCH 1/3] Added a man page for the screenresolution command. Copy screenresolution.1 to /usr/local/share/man/man1 to install the man page. Type: man screenresolution to view the man page. --- screenresolution.1 | 74 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 screenresolution.1 diff --git a/screenresolution.1 b/screenresolution.1 new file mode 100644 index 0000000..d4cc080 --- /dev/null +++ b/screenresolution.1 @@ -0,0 +1,74 @@ +.\" vi:set wm=5 +.TH SCREENRESOLUTION 1 "Apr 2019" +.if n .ds Q \&" +.if n .ds U \&" +.if t .ds Q `` +.if t .ds U '' +.UC 4 +.SH NAME +screenresolution \- screen resolution manager + + +.SH SYNOPSIS +.B screenresolution +.B \fIlist | get | set\fP +[ +.B \fIargs\fP +] +.br +.B screenresolution list +.br +.B screenresolution get +.br +.B screenresolution set +\fIresolution +.ta .5i 1.8i + +.SH DESCRIPTION +.I Screenresolution +is a screen resolution manager that sets the current graphics resolution. There are three commands that this program supports: get, list and set. All three modes operate on active displays. + +.SH "COMMAND-LINE OPTIONS" +Screenresolution has the following command-line options: +.TP 5 +.B get +The get mode will show you the resolution of all active displays + + $ screenresolution get + Display 0: 1920x1200x32 + Display 1: 1920x1200x32 +.TP 5 +.B set +The set command takes a list of modes. It will apply the modes in the list of modes to the list of displays, starting with 0. Modes in excess of the number of active displays will be ignored. If you wish to set a monitor but not the lower numbered displays, there is a keyword 'skip' which can be subsituted for a resolution. This keyword will cause the first display to be skipped. If you specify more resolutions than you have active screens, the extra +resolutions will be ignored. +.TP 5 +.B list +The list mode will show you to the available resolutions of all active displays, seperated by various whitespace. + + Available Modes on Display 0 + 1920x1200x8 1920x1200x16 1920x1200x32 960x600x8 + 960x600x16 960x600x32 1680x1050x8 1680x1050x16 + + Available Modes on Display 1 + + +.SH EXAMPLES +Example 1: + This example works with one or more screens + $ screenresolution set 800x600x32 +Result 1: + The main display will change to 800x600x32, second screen + will not be changed + +Example 2: + This example assumes two screens + $ screenresolution set 800x600x32 800x600x32 +Result 2: + The first and second monitor on the system will be set to + 800x600x32 + +Example 3: + This example assumes two screens + $ screen resolution set skip 800x600x32 + This will not touch the first screen but will set the second + screen to 800x600x32 From 775ce013adaf41f294990de3d6f35e09510b086a Mon Sep 17 00:00:00 2001 From: Barry Nelson Date: Tue, 2 Apr 2019 13:43:11 -0400 Subject: [PATCH 2/3] Updated Makefile to install man page. --- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Makefile b/Makefile index e9fc71f..343b4fc 100644 --- a/Makefile +++ b/Makefile @@ -72,11 +72,19 @@ install: screenresolution mkdir -p $(DESTDIR)/$(PREFIX)/bin install -s -m 0755 screenresolution \ $(DESTDIR)/$(PREFIX)/bin/ + mkdir -p \ + $(DESTDIR)/$(PREFIX)/share/man/man1/ + install -m 0644 screenresolution.1 \ + $(DESTDIR)/$(PREFIX)/share/man/man1/ pkg: screenresolution mkdir -p pkgroot/$(PREFIX)/bin install -s -m 0755 screenresolution \ pkgroot/$(PREFIX)/bin + mkdir -p \ + pkgroot/$(PREFIX)/share/man/man1 + install -m 0644 screenresolution.1 \ + pkgroot/$(PREFIX)/share/man/man1 $(PACKAGE_BUILD) --root pkgroot/ --identifier com.johnhford.screenresolution \ --version $(VERSION) "screenresolution-$(VERSION).pkg" rm -f screenresolution.pkg From efb6d152d8dba0c408322cdfd364eb3b9e759ee3 Mon Sep 17 00:00:00 2001 From: Barry Nelson Date: Tue, 2 Apr 2019 16:48:10 -0400 Subject: [PATCH 3/3] Added -? and help command line options. Also, updated the man page. --- main.c | 52 +++++++++++++++++++++++++++++++++++++++++++++- screenresolution.1 | 5 ++++- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index c4cecc6..56a4a4b 100644 --- a/main.c +++ b/main.c @@ -71,6 +71,56 @@ int main(int argc, const char *argv[]) { return 1; } + if (strcmp(argv[1], "help") == 0 || strcmp(argv[1], "-?") == 0) { + printf("There are three commands that this program supports: get, list and set.\n\ +All three modes operate on active displays.\n\ +\n\ +The get mode will show you the resolution of all active displays\n\ +\n\ + $ screenresolution get\n\ + Display 0: 1920x1200x32\n\ + Display 1: 1920x1200x32\n\ +\n\ +The list mode will show you to the available resolutions of all active\n\ +displays, seperated by various whitespace.\n\ +\n\ + Available Modes on Display 0\n\ + 1920x1200x8 1920x1200x16 1920x1200x32 960x600x8\n\ + 960x600x16 960x600x32 1680x1050x8 1680x1050x16\n\ + \n\ + Available Modes on Display 1\n\ + \n\ +\n\ +The set command takes a list of modes. It will apply the modes\n\ +in the list of modes to the list of displays, starting with 0.\n\ +Modes in excess of the number of active displays will be ignored.\n\ +If you wish to set a monitor but not the lower numbered displays,\n\ +there is a keyword 'skip' which can be subsituted for a resolution.\n\ +This keyword will cause the first display to be skipped. If you\n\ +specify more resolutions than you have active screens, the extra\n\ +resolutions will be ignored.\n\ +\n\ +Example 1:\n\ + This example works with one or more screens\n\ + $ screenresolution set 800x600x32\n\ +Result 1:\n\ + The main display will change to 800x600x32, second screen\n\ + will not be changed\n\ +\n\ +Example 2:\n\ + This example assumes two screens\n\ + $ screenresolution set 800x600x32 800x600x32\n\ +Result 2:\n\ + The first and second monitor on the system will be set to\n\ + 800x600x32\n\ +\n\ +Example 3:\n\ + This example assumes two screens\n\ + $ screen resolution set skip 800x600x32\n\ + This will not touch the first screen but will set the second\n\ + screen to 800x600x32\n"); + return(0); + } // This loop should probably be in another function. for (d = 0; d < displayCount && keepgoing; d++) { if (strcmp(argv[1], "get") == 0) { @@ -108,7 +158,7 @@ int main(int argc, const char *argv[]) { free(activeDisplays); activeDisplays = NULL; } else { - NSLog(CFSTR("%s"), "Incorrect command line"); + NSLog(CFSTR("%s"), "Incorrect command line.\nUsage: screenresolution help|list|get|set "); exitcode++; } return exitcode > 0; diff --git a/screenresolution.1 b/screenresolution.1 index d4cc080..37a629a 100644 --- a/screenresolution.1 +++ b/screenresolution.1 @@ -11,11 +11,14 @@ screenresolution \- screen resolution manager .SH SYNOPSIS .B screenresolution -.B \fIlist | get | set\fP +.B \fIhelp | list | get | set\fP [ .B \fIargs\fP ] .br + +.B screenresolution help +.br .B screenresolution list .br .B screenresolution get