From aaabc50e3267871d1619bfe4f565187f08524a1f Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Sun, 2 Mar 2025 06:04:17 -0300 Subject: workingdir This patch allows user to specify the initial path st should use as WD (working directory). https://st.suckless.org/patches/workingdir/ --- x.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'x.c') diff --git a/x.c b/x.c index 1fda75b..e0eb263 100644 --- a/x.c +++ b/x.c @@ -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(); -- cgit v1.2.3