apply newterm patch

This commit is contained in:
Alexander Bocken 2023-03-19 12:10:05 +01:00
parent 033298508e
commit 3240bec57c
Signed by: Alexander
GPG Key ID: 1D237BE83F9B05E8
4 changed files with 45 additions and 3 deletions

View File

@ -5,8 +5,8 @@
*
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
*/
static char *font = "mono:pixelsize=12:antialias=true:autohint=true";
static char *font2[] = { "NotoColorEmoji:pixelsize=10:antialias=true:autohint=true" };
static char *font = "monospace:pixelsize=32:antialias=true:autohint=true";
static char *font2[] = { "monospace:pixelsize=32:antialias=true:autohint=true" };
static int borderpx = 2;
/*
@ -245,6 +245,9 @@ static MouseShortcut mshortcuts[] = {
static char *openurlcmd[] = { "/bin/sh", "-c", "st-urlhandler -o", "externalpipe", NULL };
static char *copyurlcmd[] = { "/bin/sh", "-c", "st-urlhandler -c", "externalpipe", NULL };
static char *copyoutput[] = { "/bin/sh", "-c", "st-copyout", "externalpipe", NULL };
static char *copyemailcmd[] = { "/bin/sh", "-c", "st-emailhandler", "externalpipe", NULL };
static char *weechat[] = { "/bin/sh", "-c", "st-weechatlinks", "externalpipe", NULL };
static Shortcut shortcuts[] = {
/* mask keysym function argument */
@ -280,9 +283,11 @@ static Shortcut shortcuts[] = {
{ TERMMOD, XK_J, zoom, {.f = -1} },
{ TERMMOD, XK_U, zoom, {.f = +2} },
{ TERMMOD, XK_D, zoom, {.f = -2} },
{ MODKEY, XK_Return, newterm, {.i = 0} },
{ MODKEY, XK_l, externalpipe, {.v = openurlcmd } },
{ MODKEY, XK_y, externalpipe, {.v = copyurlcmd } },
{ MODKEY, XK_o, externalpipe, {.v = copyoutput } },
{ MODKEY, XK_x, externalpipe, {.v = weechat} },
};
/*

36
st.c
View File

@ -20,6 +20,8 @@
#include "st.h"
#include "win.h"
extern char *argv0;
#if defined(__linux)
#include <pty.h>
#elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__)
@ -162,6 +164,7 @@ typedef struct {
} STREscape;
static void execsh(char *, char **);
static int chdir_by_pid(pid_t pid);
static void stty(char **);
static void sigchld(int);
static void ttywriteraw(const char *, size_t);
@ -831,6 +834,7 @@ ttynew(const char *line, char *cmd, const char *out, char **args)
if (pledge("stdio rpath tty proc", NULL) == -1)
die("pledge\n");
#endif
fcntl(m, F_SETFD, FD_CLOEXEC);
close(s);
cmdfd = m;
signal(SIGCHLD, sigchld);
@ -1082,6 +1086,38 @@ tswapscreen(void)
tfulldirt();
}
void
newterm(const Arg* a)
{
int res;
switch (fork()) {
case -1:
die("fork failed: %s\n", strerror(errno));
break;
case 0:
switch (fork()) {
case -1:
die("fork failed: %s\n", strerror(errno));
break;
case 0:
chdir_by_pid(pid);
execlp("/proc/self/exe", argv0, NULL);
exit(1);
break;
default:
exit(0);
}
default:
wait(NULL);
}
}
static int chdir_by_pid(pid_t pid) {
char buf[32];
snprintf(buf, sizeof buf, "/proc/%ld/cwd", (long)pid);
return chdir(buf);
}
void
kscrolldown(const Arg* a)
{

1
st.h
View File

@ -89,6 +89,7 @@ void externalpipe(const Arg *);
void kscrolldown(const Arg *);
void kscrollup(const Arg *);
void newterm(const Arg *);
void printscreen(const Arg *);
void printsel(const Arg *);
void sendbreak(const Arg *);

2
x.c
View File

@ -834,7 +834,7 @@ xloadcolor(int i, const char *name, Color *ncolor)
void
xloadalpha(void)
{
float const usedAlpha = focused ? alpha : alphaUnfocus;
float const usedAlpha = alpha;
if (opt_alpha) alpha = strtof(opt_alpha, NULL);
dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * usedAlpha);
dc.col[defaultbg].pixel &= 0x00FFFFFF;