From ff42b9bd865e677492709babdf05b30f81c26a8a Mon Sep 17 00:00:00 2001 From: Sam Hoffman Date: Thu, 1 Jan 2026 15:07:12 -0500 Subject: [PATCH] patch: open-selected --- config.def.h | 1 + st.c | 10 ++++++++++ x.c | 16 ++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/config.def.h b/config.def.h index 6627444..ca79b08 100644 --- a/config.def.h +++ b/config.def.h @@ -176,6 +176,7 @@ static uint forcemousemod = ShiftMask; */ static MouseShortcut mshortcuts[] = { /* mask button function argument release */ + { ControlMask, Button2, selopen, {.i = 0}, 1 }, { XK_ANY_MOD, Button4, kscrollup, {.i = 1}, 0, /* !alt */ -1 }, { XK_ANY_MOD, Button5, kscrolldown, {.i = 1}, 0, /* !alt */ -1 }, { XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 }, diff --git a/st.c b/st.c index c2af9d9..01b876f 100644 --- a/st.c +++ b/st.c @@ -1887,6 +1887,16 @@ csihandle(void) term.c.y+1, term.c.x+1); ttywrite(buf, len, 0); break; + case 7: + if (strstr(strescseq.args[1], "file://") != strescseq.args[1]) { + fprintf(stderr, "erresc: dir %s must have prefix 'file://'\n", + strescseq.args[1]); + return; + } + if (chdir(strescseq.args[1] + 7) != 0) /* +7 to remove prefix */ + fprintf(stderr, "erresc: invalid directory %s\n", + strescseq.args[1]); + return; default: goto unknown; } diff --git a/x.c b/x.c index d002d84..be4936c 100644 --- a/x.c +++ b/x.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -56,6 +57,7 @@ static void clipcopy(const Arg *); static void clippaste(const Arg *); static void numlock(const Arg *); static void selpaste(const Arg *); +static void selopen(const Arg *); static void zoom(const Arg *); static void zoomabs(const Arg *); static void zoomreset(const Arg *); @@ -289,6 +291,20 @@ selpaste(const Arg *dummy) xw.win, CurrentTime); } +void +selopen(const Arg *dummy) +{ + pid_t chpid; + + if ((chpid = fork()) == 0) { + if (fork() == 0) + execlp("xdg-open", "xdg-open", getsel(), NULL); + exit(1); + } + if (chpid > 0) + waitpid(chpid, NULL, 0); +} + void numlock(const Arg *dummy) {