Add -c option to override the default window class

This commit is contained in:
Gregor Best 2010-11-19 17:13:13 +01:00
parent 70464e2080
commit b61afd24be
2 changed files with 10 additions and 2 deletions

4
st.1
View file

@ -4,6 +4,7 @@ st \- simple terminal
.SH SYNOPSIS .SH SYNOPSIS
.B st .B st
.RB [ \-e " <cmd>"] .RB [ \-e " <cmd>"]
.RB [ \-c " <class>"]
.RB [ \-t " <title>"] .RB [ \-t " <title>"]
.RB [ \-v ] .RB [ \-v ]
.SH DESCRIPTION .SH DESCRIPTION
@ -17,5 +18,8 @@ Execute cmd instead of the shell
.B \-t <title> .B \-t <title>
Overrides the default title (st) Overrides the default title (st)
.TP .TP
.B \-c <class>
Overrides the default class ($TERM)
.TP
.BI \-v .BI \-v
Prints version information to standard output, then exits. Prints version information to standard output, then exits.

8
st.c
View file

@ -31,7 +31,7 @@
#define USAGE \ #define USAGE \
"st-" VERSION ", (c) 2010 st engineers\n" \ "st-" VERSION ", (c) 2010 st engineers\n" \
"usage: st [-t title] [-e cmd] [-v]\n" "usage: st [-t title] [-c class] [-e cmd] [-v]\n"
/* Arbitrary sizes */ /* Arbitrary sizes */
#define ESC_TITLE_SIZ 256 #define ESC_TITLE_SIZ 256
@ -252,6 +252,7 @@ static pid_t pid;
static Selection sel; static Selection sel;
static char *opt_cmd = NULL; static char *opt_cmd = NULL;
static char *opt_title = NULL; static char *opt_title = NULL;
static char *opt_class = NULL;
/* UTF-8 decode */ /* UTF-8 decode */
static int stou(char *s, long *u) { static int stou(char *s, long *u) {
@ -1443,7 +1444,7 @@ xclear(int x1, int y1, int x2, int y2) {
void void
xhints(void) xhints(void)
{ {
XClassHint class = {TNAME, TNAME}; XClassHint class = {opt_class ? opt_class : TNAME, TNAME};
XWMHints wm = {.flags = InputHint, .input = 1}; XWMHints wm = {.flags = InputHint, .input = 1};
XSizeHints size = { XSizeHints size = {
.flags = PSize | PResizeInc | PBaseSize, .flags = PSize | PResizeInc | PBaseSize,
@ -1838,6 +1839,9 @@ main(int argc, char *argv[]) {
case 't': case 't':
if(++i < argc) opt_title = argv[i]; if(++i < argc) opt_title = argv[i];
break; break;
case 'c':
if(++i < argc) opt_class = argv[i];
break;
case 'e': case 'e':
if(++i < argc) opt_cmd = argv[i]; if(++i < argc) opt_cmd = argv[i];
break; break;