aboutsummaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
authorAurélien Aptel <aurelien.aptel@gmail.com>2010-09-02 01:37:01 +0200
committerAurélien Aptel <aurelien.aptel@gmail.com>2010-09-02 01:37:01 +0200
commit9d82bdd94708fa2daabc0b53f8b71bca2a3c6f0a (patch)
tree9ce409fcf5850c041bd56bb613d8a9ddbe8fa08a /st.c
parent97695baf4f9bc3632792a3330fb46e188ef166a2 (diff)
downloadst-9d82bdd94708fa2daabc0b53f8b71bca2a3c6f0a.tar.gz
st-9d82bdd94708fa2daabc0b53f8b71bca2a3c6f0a.zip
added -e and -t option.
Diffstat (limited to 'st.c')
-rw-r--r--st.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/st.c b/st.c
index 5633e40..f7f9de8 100644
--- a/st.c
+++ b/st.c
@@ -28,6 +28,10 @@
28 #include <libutil.h> 28 #include <libutil.h>
29#endif 29#endif
30 30
31#define USAGE \
32 "st-" VERSION ", (c) 2010 st engineers\n" \
33 "usage: st [-t title] [-e cmd] [-v]\n"
34
31/* Arbitrary sizes */ 35/* Arbitrary sizes */
32#define ESC_TITLE_SIZ 256 36#define ESC_TITLE_SIZ 256
33#define ESC_BUF_SIZ 256 37#define ESC_BUF_SIZ 256
@@ -210,6 +214,8 @@ static CSIEscape escseq;
210static int cmdfd; 214static int cmdfd;
211static pid_t pid; 215static pid_t pid;
212static Selection sel; 216static Selection sel;
217static char *opt_cmd = NULL;
218static char *opt_title = NULL;
213 219
214void 220void
215selinit(void) { 221selinit(void) {
@@ -329,9 +335,12 @@ die(const char *errstr, ...) {
329 335
330void 336void
331execsh(void) { 337execsh(void) {
332 char *args[3] = {getenv("SHELL"), "-i", NULL}; 338 char *args[] = {getenv("SHELL"), "-i", NULL};
333 DEFAULT(args[0], SHELL); /* if getenv() failed */ 339 if(opt_cmd)
334 putenv("TERM=" TNAME); 340 args[0] = opt_cmd, args[1] = NULL;
341 else
342 DEFAULT(args[0], SHELL);
343 putenv("TERM="TNAME);
335 execvp(args[0], args); 344 execvp(args[0], args);
336} 345}
337 346
@@ -1189,7 +1198,7 @@ xinit(void) {
1189 1198
1190 XMapWindow(xw.dis, xw.win); 1199 XMapWindow(xw.dis, xw.win);
1191 xhints(); 1200 xhints();
1192 XStoreName(xw.dis, xw.win, "st"); 1201 XStoreName(xw.dis, xw.win, opt_title ? opt_title : "st");
1193 XSync(xw.dis, 0); 1202 XSync(xw.dis, 0);
1194} 1203}
1195 1204
@@ -1429,10 +1438,21 @@ run(void) {
1429 1438
1430int 1439int
1431main(int argc, char *argv[]) { 1440main(int argc, char *argv[]) {
1432 if(argc == 2 && !strncmp("-v", argv[1], 3)) 1441 int i;
1433 die("st-" VERSION ", (c) 2010 st engineers\n"); 1442
1434 else if(argc != 1) 1443 for(i = 1; i < argc; i++) {
1435 die("usage: st [-v]\n"); 1444 switch(argv[i][0] != '-' || argv[i][2] ? -1 : argv[i][1]) {
1445 case 't':
1446 if(++i < argc) opt_title = argv[i];
1447 break;
1448 case 'e':
1449 if(++i < argc) opt_cmd = argv[i];
1450 break;
1451 case 'v':
1452 default:
1453 die(USAGE);
1454 }
1455 }
1436 setlocale(LC_CTYPE, ""); 1456 setlocale(LC_CTYPE, "");
1437 tnew(80, 24); 1457 tnew(80, 24);
1438 ttynew(); 1458 ttynew();