Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a man page for the screenresolution command. #31

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
52 changes: 51 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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\
<snip>\n\
Available Modes on Display 1\n\
<snip>\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) {
Expand Down Expand Up @@ -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 <new resolution>");
exitcode++;
}
return exitcode > 0;
Expand Down
77 changes: 77 additions & 0 deletions screenresolution.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
.\" 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 \fIhelp | list | get | set\fP
[
.B \fIargs\fP
]
.br

.B screenresolution help
.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
<snip>
Available Modes on Display 1
<snip>

.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