diff options
| author | Marcelo Lira <setanta@gmail.com> | 2025-03-02 06:04:17 -0300 |
|---|---|---|
| committer | Marcelo Lira <setanta@gmail.com> | 2025-03-03 16:12:29 -0300 |
| commit | aaabc50e3267871d1619bfe4f565187f08524a1f (patch) | |
| tree | 6d58934e399e6a7bf51762c710696ef25173a9bb /x.c | |
| parent | 5d8c9d1f5183e56a8563fc93eba8d7d4a8f842dd (diff) | |
workingdir
This patch allows user to specify the initial path st should use as WD (working directory).
https://st.suckless.org/patches/workingdir/
Diffstat (limited to 'x.c')
| -rw-r--r-- | x.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -270,6 +270,7 @@ static char *opt_io = NULL; static char *opt_line = NULL; static char *opt_name = NULL; static char *opt_title = NULL; +static char *opt_dir = NULL; static uint buttons; /* bit field of pressed buttons */ static int cursorblinks = 0; @@ -2727,12 +2728,12 @@ reload(int sig) void usage(void) { - die("usage: %s [-aiv] [-c class] [-f font] [-g geometry]" - " [-n name] [-o file]\n" + die("usage: %s [-aiv] [-c class] [-d path] [-f font]" + " [-g geometry] [-n name] [-o file]\n" " [-T title] [-t title] [-w windowid]" " [[-e] command [args ...]]\n" - " %s [-aiv] [-c class] [-f font] [-g geometry]" - " [-n name] [-o file]\n" + " %s [-aiv] [-c class] [-d path] [-f font]" + " [-g geometry] [-n name] [-o file]\n" " [-T title] [-t title] [-w windowid] -l line" " [stty_args ...]\n", argv0, argv0); } @@ -2793,6 +2794,9 @@ main(int argc, char *argv[]) if (!(defaultfontsize > 0)) usage(); break; + case 'd': + opt_dir = EARGF(usage()); + break; default: usage(); } ARGEND; @@ -2804,6 +2808,9 @@ run: if (!opt_title) opt_title = (opt_line || !opt_cmd) ? "st" : opt_cmd[0]; + if (opt_dir && chdir(opt_dir) != 0) + die("can't change into directory %s\n", opt_dir); + setlocale(LC_CTYPE, ""); XSetLocaleModifiers(""); xrdb_load(); |
