diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 2020-06-17 16:54:32 -0400 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 2020-06-17 16:54:32 -0400 |
commit | 54461320a78cb69b2a5fa3c3d27dd69d9cdd31da (patch) | |
tree | b69aa4013b18b2004ff121e69304ff57e49b094e | |
parent | b356cd5684a2e6a3a8987390ceb99c67c2a91b5e (diff) | |
parent | 46e7ae05d6fdd700364cb48e27f57e249e958f95 (diff) |
Merge branch 'master' into dickey
-rw-r--r-- | man/twm.man | 53 | ||||
-rw-r--r-- | src/twm.c | 87 |
2 files changed, 96 insertions, 44 deletions
diff --git a/man/twm.man b/man/twm.man index 35ea30f..c54e38e 100644 --- a/man/twm.man +++ b/man/twm.man @@ -43,8 +43,7 @@ .SH NAME twm \- Tab Window Manager for the X Window System .SH SYNTAX -\fBtwm \fP[ \fB\-display\fP \fIdpy\fP ] [ \fB\-s\fP ] -[ \fB\-f\fP \fIinitfile\fP ] [ \fB\-v\fP ] +\fBtwm \fP[ \fIoptions\fP ] .SH DESCRIPTION \fITwm\fP is a window manager for the X Window System. It provides @@ -108,29 +107,53 @@ Clicking pointer Button3 (usually the right pointer button) will give the window its current position but attempt to make it long enough to touch the bottom the screen. .SH OPTIONS -\fITwm\fP accepts the following command line options: +\fITwm\fP accepts several command line options, +which may be abbreviated, e.g., +\*(``\fB\-d\fP\*('' for +\*(``\fB\-display\fP\*('' +(but upper/lower-case are different): +.TP 8 +.B \-clientId \fIID\fP +Each time \fItwm\fP starts, it calls +\fBSmcOpenConnection\fP +to establish a new session. +It can be told to restart from a previous session by giving the previous +session's client-identifier. .TP 8 .B \-display \fIdpy\fP -This option specifies the X server to use. +Specify the X server to use. +.TP 8 +.B \-file \fIfilename\fP +Specify the name of the startup file to use. +By default, +\fItwm\fP will look in the user's home directory for files +named \fI.twmrc.num\fP (where \fInum\fP is a screen number) or \fI.twmrc\fP. +.TP 8 +.B \-quiet +Tells \fItwm\fP that it should not print error messages when +it receives unexpected X Error events. .TP 8 -.B \-s -This option indicates that only the default screen (as specified by +.B \-restore \fIfilename\fP +When \fItwm\fP's session is stopped, it attempts to save the current +window configuration. +Use this option to tell \fItwm\fP to read this file for that information +when starting (or restarting) a session. +.TP 8 +.B \-single +Tells \fItwm\fP that only the default screen (as specified by \fB\-display\fP or by the \fBDISPLAY\fP environment variable) should be managed. By default, \fItwm\fP will attempt to manage all screens on the display. .TP 8 -.B \-f \fIfilename\fP -This option specifies the name of the startup file to use. -By default, -\fItwm\fP will look in the user's home directory for files -named \fI.twmrc.num\fP (where \fInum\fP is a screen number) or \fI.twmrc\fP. -.TP 8 -.B \-v -This option indicates that \fItwm\fP should print error messages whenever -an unexpected X Error event is received. +.B \-verbose +Tells \fItwm\fP that it should print error messages whenever +it receives an unexpected X Error event. This can be useful when debugging applications but can be distracting in regular use. +.TP 8 +.B \-V +Tell \fItwm\fP to print its version to the standard output, and exit. .SH CUSTOMIZATION Much of \fItwm\fP's appearance and behavior can be controlled by providing a startup file in one of the following locations (searched in order for @@ -75,6 +75,7 @@ in this Software without prior written authorization from The Open Group. #include "screen.h" #include "parse.h" #include "session.h" +#include "version.h" #include <X11/Xproto.h> #include <X11/Xatom.h> #include <X11/SM/SMlib.h> @@ -181,8 +182,7 @@ static char *atom_names[11] = { #ifdef XPRINT /* |hasExtension()| and |IsPrintScreen()| have been stolen from * xc/programs/xdpyinfo/xdpyinfo.c */ -static - Bool +static Bool hasExtension(Display *dpy, char *extname) { int num_extensions, i; @@ -195,8 +195,7 @@ hasExtension(Display *dpy, char *extname) return i != num_extensions; } -static - Bool +static Bool IsPrintScreen(Screen *s) { Display *dpy = XDisplayOfScreen(s); @@ -219,6 +218,31 @@ IsPrintScreen(Screen *s) } #endif /* XPRINT */ +static void +usage(void) +{ + fprintf(stderr, "usage: %s [-display dpy] [-f file] [-s] [-q] [-v] [-V]" +#ifdef XPRINT + " [-noprint]" +#endif /* XPRINT */ + " [-clientId id] [-restore file]\n", ProgramName); + exit(EXIT_FAILURE); +} + +static Bool +brief_opt(const char *param, const char *option) +{ + size_t have = strlen(++param); + size_t want = strlen(option); + Bool result = False; + + if (have <= want) { + if (!strncmp(param, option, have)) + result = True; + } + return result; +} + /*********************************************************************** * * Procedure: @@ -249,57 +273,62 @@ main(int argc, char *argv[]) for (i = 1; i < argc; i++) { if (argv[i][0] == '-') { switch (argv[i][1]) { + case 'V': + printf("%s %s\n", ProgramName, Version); + exit(EXIT_SUCCESS); case 'd': /* -display dpy */ - if (strcmp(&argv[i][1], "display")) - goto usage; + if (!brief_opt(argv[i], "display")) + usage(); if (++i >= argc) - goto usage; + usage(); display_name = argv[i]; continue; case 's': /* -single */ + if (!brief_opt(argv[i], "single")) + usage(); MultiScreen = FALSE; continue; #ifdef XPRINT case 'n': /* -noprint */ - if (strcmp(&argv[i][1], "noprint")) - goto usage; + if (!brief_opt(argv[i], "noprint")) + usage(); NoPrintscreens = True; continue; #endif /* XPRINT */ case 'f': /* -file twmrcfilename */ + if (!brief_opt(argv[i], "file")) + usage(); if (++i >= argc) - goto usage; + usage(); InitFile = argv[i]; continue; case 'v': /* -verbose */ + if (!brief_opt(argv[i], "verbose")) + usage(); PrintErrorMessages = True; continue; case 'c': /* -clientId */ - if (strcmp(&argv[i][1], "clientId")) - goto usage; + if (!brief_opt(argv[i], "clientId")) + usage(); if (++i >= argc) - goto usage; + usage(); client_id = argv[i]; continue; case 'r': /* -restore */ - if (strcmp(&argv[i][1], "restore")) - goto usage; + if (!brief_opt(argv[i], "restore")) + usage(); if (++i >= argc) - goto usage; + usage(); restore_filename = argv[i]; continue; case 'q': /* -quiet */ + if (!brief_opt(argv[i], "quiet")) + usage(); PrintErrorMessages = False; continue; } } - usage: - fprintf(stderr, "usage: %s [-display dpy] [-f file] [-s] [-q] [-v]" -#ifdef XPRINT - " [-noprint]" -#endif /* XPRINT */ - " [-clientId id] [-restore file]\n", ProgramName); - exit(1); + usage(); } loc = setlocale(LC_ALL, ""); @@ -352,14 +381,14 @@ main(int argc, char *argv[]) NULL, 0, &zero, NULL))) { fprintf(stderr, "%s: unable to open display \"%s\"\n", ProgramName, XDisplayName(display_name)); - exit(1); + exit(EXIT_FAILURE); } if (fcntl(ConnectionNumber(dpy), F_SETFD, 1) == -1) { fprintf(stderr, "%s: unable to mark display connection as close-on-exec\n", ProgramName); - exit(1); + exit(EXIT_FAILURE); } if (restore_filename) @@ -399,7 +428,7 @@ main(int argc, char *argv[]) fprintf(stderr, "%s: Unable to allocate memory for screen list, exiting.\n", ProgramName); - exit(1); + exit(EXIT_FAILURE); } numManaged = 0; PreviousScreen = DefaultScreen(dpy); @@ -680,7 +709,7 @@ main(int argc, char *argv[]) if (MultiScreen && NumScreens > 0) fprintf(stderr, "%s: unable to find any unmanaged %sscreens.\n", ProgramName, NoPrintscreens ? "" : "video "); - exit(1); + exit(EXIT_FAILURE); } (void) ConnectToSessionManager(client_id); @@ -689,7 +718,7 @@ main(int argc, char *argv[]) HandlingEvents = TRUE; InitEvents(); HandleEvents(); - exit(0); + exit(EXIT_SUCCESS); } /** @@ -945,7 +974,7 @@ Done(XtPointer client_data _X_UNUSED, XtSignalId *si2 _X_UNUSED) Reborder(CurrentTime); XCloseDisplay(dpy); } - exit(0); + exit(EXIT_SUCCESS); } /* |