summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md4
-rw-r--r--config.h4
-rw-r--r--st.15
-rw-r--r--st.c53
-rw-r--r--st.h1
5 files changed, 66 insertions, 1 deletions
diff --git a/README.md b/README.md
index b3587c8..35b7bac 100644
--- a/README.md
+++ b/README.md
@@ -8,6 +8,8 @@ The [suckless terminal (st)](https://st.suckless.org/) with some additional feat
+ Default font is system "mono" at 16pt, meaning the font will match your system font.
+ Very useful keybinds including:
+ Copy is alt-c, paste is alt-v or alt-p pastes from primary selection
+ + Alt-l feeds all urls on screen to dmenu, so they user can choose and
+ follow one (requires xurls and dmenu installed).
+ Zoom in/out or increase font size with Alt+Shift+k/j or u/d for larger intervals.
+ Hold alt and press either ↑/↓ or the vim keys k/j to move up/down in the terminal.
+ Shift+Mouse wheel do the same.
@@ -61,7 +63,7 @@ The `alpha` value (for transparency) goes from `0` (transparent) to `255`
To be clear about the color settings:
-- This build will use colorized colors by default and as a fallback.
+- This build will use gruvbox colors by default and as a fallback.
- If there are Xresources colors defined, those will take priority.
- But if `wal` has run in your session, its colors will take priority.
diff --git a/config.h b/config.h
index c4a112e..ba29ff4 100644
--- a/config.h
+++ b/config.h
@@ -207,6 +207,9 @@ MouseKey mkeys[] = {
{ Button5, MODKEY|ShiftMask, zoom, {.f = -1} },
};
+static char *openurlcmd[] = { "/bin/sh", "-c",
+ "xurls | dmenu -l 10 | xargs -r xdg-open",
+ "externalpipe", NULL };
static Shortcut shortcuts[] = {
/* mask keysym function argument */
@@ -239,6 +242,7 @@ static Shortcut shortcuts[] = {
{ MODKEY|ShiftMask, XK_J, zoom, {.f = -1} },
{ MODKEY|ShiftMask, XK_U, zoom, {.f = +2} },
{ MODKEY|ShiftMask, XK_D, zoom, {.f = -2} },
+ { MODKEY, XK_l, externalpipe, { .v = openurlcmd } },
};
/*
diff --git a/st.1 b/st.1
index b3f63b6..8323401 100644
--- a/st.1
+++ b/st.1
@@ -146,6 +146,11 @@ Copy to clipboard.
.B Alt-p
Paste/input primary selection.
.TP
+.B Alt-l
+Show dmenu menu of all URLs on screen and choose one to open.
+.I Note:
+Requires xurls installed.
+.TP
.B Break
Send a break in the serial line.
Break key is obtained in PC keyboards
diff --git a/st.c b/st.c
index 45d2544..a6310f7 100644
--- a/st.c
+++ b/st.c
@@ -2030,6 +2030,59 @@ tprinter(char *s, size_t len)
}
void
+externalpipe(const Arg *arg)
+{
+ int to[2];
+ char buf[UTF_SIZ];
+ void (*oldsigpipe)(int);
+ Glyph *bp, *end;
+ int lastpos, n, newline;
+
+ if (pipe(to) == -1)
+ return;
+
+ switch (fork()) {
+ case -1:
+ close(to[0]);
+ close(to[1]);
+ return;
+ case 0:
+ dup2(to[0], STDIN_FILENO);
+ close(to[0]);
+ close(to[1]);
+ execvp(((char **)arg->v)[0], (char **)arg->v);
+ fprintf(stderr, "st: execvp %s\n", ((char **)arg->v)[0]);
+ perror("failed");
+ exit(0);
+ }
+
+ close(to[0]);
+ /* ignore sigpipe for now, in case child exists early */
+ oldsigpipe = signal(SIGPIPE, SIG_IGN);
+ newline = 0;
+ for (n = 0; n < term.row; n++) {
+ bp = term.line[n];
+ lastpos = MIN(tlinelen(n) + 1, term.col) - 1;
+ if (lastpos < 0)
+ break;
+ end = &bp[lastpos + 1];
+ for (; bp < end; ++bp)
+ if (xwrite(to[1], buf, utf8encode(bp->u, buf)) < 0)
+ break;
+ if ((newline = term.line[n][lastpos].mode & ATTR_WRAP))
+ continue;
+ if (xwrite(to[1], "\n", 1) < 0)
+ break;
+ newline = 0;
+ }
+ if (newline)
+ (void)xwrite(to[1], "\n", 1);
+ close(to[1]);
+ /* restore */
+ signal(SIGPIPE, oldsigpipe);
+}
+
+void
iso14755(const Arg *arg)
{
FILE *p;
diff --git a/st.h b/st.h
index 850c5f0..01cad23 100644
--- a/st.h
+++ b/st.h
@@ -92,6 +92,7 @@ void die(const char *, ...);
void redraw(void);
void draw(void);
+void externalpipe(const Arg *);
void iso14755(const Arg *);
void printscreen(const Arg *);
void printsel(const Arg *);