Patch newterm adapted for Lukes build

This commit is contained in:
Nikita Alkhovik 2021-03-01 14:15:17 +03:00
parent ebb7b6c96a
commit 1d76c5bf72
3 changed files with 26 additions and 0 deletions

View file

@ -265,6 +265,7 @@ static Shortcut shortcuts[] = {
{ TERMMOD, XK_J, zoom, {.f = -1} },
{ TERMMOD, XK_U, zoom, {.f = +2} },
{ TERMMOD, XK_D, zoom, {.f = -2} },
{ ShiftMask|ControlMask,XK_Return, newterm, {.i = 0} },
{ MODKEY, XK_l, externalpipe, {.v = openurlcmd } },
{ MODKEY, XK_y, externalpipe, {.v = copyurlcmd } },
{ MODKEY, XK_o, externalpipe, {.v = copyoutput } },
@ -539,3 +540,4 @@ static char ascii_printable[] =
" !\"#$%&'()*+,-./0123456789:;<=>?"
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
"`abcdefghijklmnopqrstuvwxyz{|}~";

22
st.c
View file

@ -153,6 +153,7 @@ typedef struct {
} STREscape;
static void execsh(char *, char **);
static char *getcwd_by_pid(pid_t pid);
static void stty(char **);
static void sigchld(int);
static void ttywriteraw(const char *, size_t);
@ -1058,6 +1059,26 @@ tswapscreen(void)
tfulldirt();
}
void
newterm(const Arg* a)
{
switch (fork()) {
case -1:
die("fork failed: %s\n", strerror(errno));
break;
case 0:
chdir(getcwd_by_pid(pid));
execlp("st", "./st", NULL);
break;
}
}
static char *getcwd_by_pid(pid_t pid) {
char buf[32];
snprintf(buf, sizeof buf, "/proc/%d/cwd", pid);
return realpath(buf, NULL);
}
void
tscrolldown(int orig, int n)
{
@ -2660,3 +2681,4 @@ redraw(void)
tfulldirt();
draw();
}

2
st.h
View file

@ -84,6 +84,7 @@ void die(const char *, ...);
void redraw(void);
void draw(void);
void newterm(const Arg *);
void externalpipe(const Arg *);
void printscreen(const Arg *);
void printsel(const Arg *);
@ -137,3 +138,4 @@ extern unsigned int defaultfg;
extern unsigned int defaultbg;
extern float alpha;
extern const int boxdraw, boxdraw_bold, boxdraw_braille;