Adding workingdir patch

This commit is contained in:
bakkeby 2020-03-29 16:46:38 +02:00
parent d26b46ffa7
commit 7dee587ceb
3 changed files with 31 additions and 3 deletions

View File

@ -15,7 +15,7 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the
### Changelog:
2020-03-29 - Added invert patch
2020-03-29 - Added invert and workingdir patches
2020-03-24 - Upgraded to latest (master) of st (commit 51e19ea11dd42eefed1ca136ee3f6be975f618b1 at the time of writing). Custom changes to make the altscreen mouse scollback patch working.
@ -113,6 +113,9 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the
- [visualbell](https://st.suckless.org/patches/visualbell/)
- adds visual indicators for the terminal bell event
- [workingdir](https://st.suckless.org/patches/workingdir/)
- allows user to specify the initial path st should use as the working directory
- [xresources](https://st.suckless.org/patches/xresources/)
- adds the ability to configure st via Xresources
- during startup, st will read and apply the resources named in the resources[] array in config.h

View File

@ -196,6 +196,11 @@
*/
#define VISUALBELL_3_PATCH 0
/* This patch allows user to specify the initial path st should use as the working directory.
* https://st.suckless.org/patches/workingdir/
*/
#define WORKINGDIR_PATCH 0
/* This patch adds the ability to configure st via Xresources. At startup, st will read and
* apply the resources named in the resources[] array in config.h.
* https://st.suckless.org/patches/xresources/

24
x.c
View File

@ -284,6 +284,9 @@ static char *opt_io = NULL;
static char *opt_line = NULL;
static char *opt_name = NULL;
static char *opt_title = NULL;
#if WORKINGDIR_PATCH
static char *opt_dir = NULL;
#endif // WORKINGDIR_PATCH
static int oldbutton = 3; /* button event on startup: 3 = release */
#if VISUALBELL_1_PATCH && !VISUALBELL_2_PATCH && !VISUALBELL_3_PATCH
@ -2410,11 +2413,19 @@ run(void)
void
usage(void)
{
die("usage: %s [-aiv] [-c class] [-f font] [-g geometry]"
die("usage: %s [-aiv] [-c class]"
#if WORKINGDIR_PATCH
" [-d path]"
#endif // WORKINGDIR_PATCH
" [-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]"
" %s [-aiv] [-c class]"
#if WORKINGDIR_PATCH
" [-d path]"
#endif // WORKINGDIR_PATCH
" [-f font] [-g geometry]"
" [-n name] [-o file]\n"
" [-T title] [-t title] [-w windowid] -l line"
" [stty_args ...]\n", argv0, argv0);
@ -2439,6 +2450,11 @@ main(int argc, char *argv[])
case 'c':
opt_class = EARGF(usage());
break;
#if WORKINGDIR_PATCH
case 'd':
opt_dir = EARGF(usage());
break;
#endif // WORKINGDIR_PATCH
case 'e':
if (argc > 0)
--argc, ++argv;
@ -2497,6 +2513,10 @@ run:
xinit(cols, rows);
xsetenv();
selinit();
#if WORKINGDIR_PATCH
if (opt_dir && chdir(opt_dir))
die("Can't change to working directory %s\n", opt_dir);
#endif // WORKINGDIR_PATCH
run();
return 0;