fix sexp crashing.... ..again
This commit is contained in:
parent
2455ceb60a
commit
c9dec7cd27
|
@ -476,6 +476,7 @@ Below is a list of all .Xresources values you can define.
|
||||||
- speedwm.layout.monocle.clientcount: 0
|
- speedwm.layout.monocle.clientcount: 0
|
||||||
- speedwm.layout.monocle.count: 0
|
- speedwm.layout.monocle.count: 0
|
||||||
- speedwm.layout.monocle.format: [%d/%d]
|
- speedwm.layout.monocle.format: [%d/%d]
|
||||||
|
- speedwm.layout.custom.cmd: printf '' | spmenu -i -l 10 -p 'Enter S expression:'
|
||||||
- speedwm.mfact: 0.50
|
- speedwm.mfact: 0.50
|
||||||
- speedwm.mfact.lowest: 0.05
|
- speedwm.mfact.lowest: 0.05
|
||||||
- speedwm.mouse.clicktofocus: 0
|
- speedwm.mouse.clicktofocus: 0
|
||||||
|
|
|
@ -223,6 +223,9 @@ speedwm.layout.monocle.clientcount: 0 ! Enable client count in the monocle la
|
||||||
speedwm.layout.monocle.count: 0 ! Enable focused client and number of total clients in the monocle layout (0/1)
|
speedwm.layout.monocle.count: 0 ! Enable focused client and number of total clients in the monocle layout (0/1)
|
||||||
speedwm.layout.monocle.format: [%d/%d]
|
speedwm.layout.monocle.format: [%d/%d]
|
||||||
|
|
||||||
|
!! Custom layout
|
||||||
|
speedwm.layout.custom.cmd: printf '' | spmenu -i -l 10 -p 'Enter S expression:'
|
||||||
|
|
||||||
!! mfact options
|
!! mfact options
|
||||||
speedwm.mfact: 0.50 ! Default mfact (0-1)
|
speedwm.mfact: 0.50 ! Default mfact (0-1)
|
||||||
speedwm.mfact.lowest: 0.05 ! Lowest possible mfact (0-1)
|
speedwm.mfact.lowest: 0.05 ! Lowest possible mfact (0-1)
|
||||||
|
|
48
layouts.c
48
layouts.c
|
@ -1436,7 +1436,8 @@ struct string_token_t* tokenize_string(char *str)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse s-expression to node_t structure */
|
/* Parse s-expression to node_t structure */
|
||||||
node_t* parse_sexp(string_token_t **token)
|
node_t*
|
||||||
|
parse_sexp(string_token_t **token)
|
||||||
{
|
{
|
||||||
node_t *head = NULL;
|
node_t *head = NULL;
|
||||||
node_t branch, *p = &branch;
|
node_t branch, *p = &branch;
|
||||||
|
@ -1630,42 +1631,22 @@ node_t* parse_sexp(string_token_t **token)
|
||||||
*token = t;
|
*token = t;
|
||||||
return head;
|
return head;
|
||||||
}
|
}
|
||||||
void set_s_layout(const Arg *arg)
|
|
||||||
|
void
|
||||||
|
set_s_layout(const Arg *arg)
|
||||||
{
|
{
|
||||||
FILE *pp, *hf;
|
char *cf;
|
||||||
|
//char *cmd = "printf 'CUCK' | spmenu -i -l 10 -p 'sxp>'";
|
||||||
|
FILE *pp = popen(custom_cmd, "r");
|
||||||
|
|
||||||
char pathbuf[1024];
|
if (!pp) return;
|
||||||
char *home = getenv("HOME");
|
char buf[1024] = "";
|
||||||
int sortout = 0;
|
//buf[1024+1] = '\0';
|
||||||
int histout = 0;
|
cf = fgets(buf, 1024, pp);
|
||||||
if (home != NULL) {
|
|
||||||
snprintf(pathbuf, 1023, "%s/" CUSTOM_HISTORY, home);
|
|
||||||
pathbuf[1023] = '\0';
|
|
||||||
|
|
||||||
// make sure the history file exists
|
|
||||||
hf = fopen(CUSTOM_HISTORY, "a"); fclose(hf);
|
|
||||||
|
|
||||||
sortout = system("sort " CUSTOM_HISTORY " | uniq > " CUSTOM_HISTORY "~");
|
|
||||||
histout = system("mv " CUSTOM_HISTORY "~ " CUSTOM_HISTORY);
|
|
||||||
|
|
||||||
pp = popen("dmenu -i -l 10 -p 'Enter expression:' <" CUSTOM_HISTORY, "r");
|
|
||||||
} else {
|
|
||||||
pp = popen("dmenu -i -l 10 -p 'Enter expression:'", "r");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sortout || !sortout || histout || !histout)
|
|
||||||
if (!pp) return;
|
|
||||||
|
|
||||||
char buf[1024 + 1];
|
|
||||||
buf[1024] = '\0';
|
|
||||||
if (!fgets(buf, 1024, pp)) return;
|
|
||||||
fclose(pp);
|
|
||||||
if (buf[0] == '\0') return;
|
if (buf[0] == '\0') return;
|
||||||
|
//fclose(pp);
|
||||||
|
|
||||||
// Write to history file
|
if (!cf) return;
|
||||||
hf = fopen(CUSTOM_HISTORY, "a");
|
|
||||||
fprintf(hf, "%s", buf);
|
|
||||||
fclose(hf);
|
|
||||||
|
|
||||||
if (s_layout_scheme != NULL) {
|
if (s_layout_scheme != NULL) {
|
||||||
free_node(s_layout_scheme);
|
free_node(s_layout_scheme);
|
||||||
|
@ -1675,6 +1656,7 @@ void set_s_layout(const Arg *arg)
|
||||||
struct string_token_t *token_root = tokenize_string(buf),
|
struct string_token_t *token_root = tokenize_string(buf),
|
||||||
*token = token_root;
|
*token = token_root;
|
||||||
|
|
||||||
|
if (!token_root) return;
|
||||||
s_layout_scheme = parse_sexp(&token);
|
s_layout_scheme = parse_sexp(&token);
|
||||||
|
|
||||||
setlayout(arg);
|
setlayout(arg);
|
||||||
|
|
|
@ -153,7 +153,7 @@ static int deckcount = 0; /* Display deck count in the deck layout */
|
||||||
static char deckformat[] = "[%d]"; /* Format of the deck count. deckcount must be set to 1 for this to be used. */
|
static char deckformat[] = "[%d]"; /* Format of the deck count. deckcount must be set to 1 for this to be used. */
|
||||||
|
|
||||||
/* Custom layout */
|
/* Custom layout */
|
||||||
#define CUSTOM_HISTORY ".custom_history"
|
static char *custom_cmd = "printf '' | spmenu -i -l 10 -p 'Enter S expression:'"; /* Command to run when setting S expression */
|
||||||
|
|
||||||
/* Resetting */
|
/* Resetting */
|
||||||
static int resetlayout = 0; /* Reset layout when there is only one client visible */
|
static int resetlayout = 0; /* Reset layout when there is only one client visible */
|
||||||
|
|
77
speedwm.1
77
speedwm.1
|
@ -1,4 +1,4 @@
|
||||||
.\" Automatically generated by Pandoc 2.19.2
|
.\" Automatically generated by Pandoc 3.0.1
|
||||||
.\"
|
.\"
|
||||||
.\" Define V font for inline verbatim, using C font in formats
|
.\" Define V font for inline verbatim, using C font in formats
|
||||||
.\" that render this, and otherwise B font.
|
.\" that render this, and otherwise B font.
|
||||||
|
@ -811,71 +811,71 @@ speedwm.col.windowbordersel: #eeeeee
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.col.windowborderurg: #f0e68c
|
speedwm.col.windowborderurg: #f0e68c
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.tag1.empty: \[uF8A5]
|
speedwm.text.tag1.empty:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.tag2.empty: \[uF8A8]
|
speedwm.text.tag2.empty:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.tag3.empty: \[uF8AB]
|
speedwm.text.tag3.empty:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.tag4.empty: \[uF8AE]
|
speedwm.text.tag4.empty:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.tag5.empty: \[uF8B1]
|
speedwm.text.tag5.empty:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.tag6.empty: \[uF8B4]
|
speedwm.text.tag6.empty:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.tag7.empty: \[uF8B7]
|
speedwm.text.tag7.empty:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.tag8.empty: \[uF8BA]
|
speedwm.text.tag8.empty:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.tag9.empty: \[uF8BD]
|
speedwm.text.tag9.empty:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.tag1.used: \[uF8A3]
|
speedwm.text.tag1.used:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.tag2.used: \[uF8A6]
|
speedwm.text.tag2.used:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.tag3.used: \[uF8A9]
|
speedwm.text.tag3.used:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.tag4.used: \[uF8AC]
|
speedwm.text.tag4.used:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.tag5.used: \[uF8AF]
|
speedwm.text.tag5.used:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.tag6.used: \[uF8B2]
|
speedwm.text.tag6.used:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.tag7.used: \[uF8B5]
|
speedwm.text.tag7.used:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.tag8.used: \[uF8B8]
|
speedwm.text.tag8.used:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.tag9.used: \[uF8BB]
|
speedwm.text.tag9.used:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.layout1: \[uF330]
|
speedwm.text.layout1:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.layout2: \[uF331]
|
speedwm.text.layout2:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.layout3: \[uF332]
|
speedwm.text.layout3:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.layout4: \[uF333]
|
speedwm.text.layout4:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.layout5: \[uF334]
|
speedwm.text.layout5:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.layout6: \[uF335]
|
speedwm.text.layout6:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.layout7: \[uF336]
|
speedwm.text.layout7:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.layout8: \[uF337]
|
speedwm.text.layout8:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.layout9: \[uF338]
|
speedwm.text.layout9:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.layout10: \[uF339]
|
speedwm.text.layout10:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.layout11: \[uF33A]
|
speedwm.text.layout11:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.layout12: \[uF33B]
|
speedwm.text.layout12:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.layout13: \[uF33C]
|
speedwm.text.layout13:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.layout14: \[uF33D]
|
speedwm.text.layout14:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.text.layout15: \[uF33E]
|
speedwm.text.layout15:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.color.hiddentitle: 1
|
speedwm.color.hiddentitle: 1
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
|
@ -919,6 +919,9 @@ speedwm.layout.monocle.count: 0
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.layout.monocle.format: [%d/%d]
|
speedwm.layout.monocle.format: [%d/%d]
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
|
speedwm.layout.custom.cmd: printf \[cq]\[cq] | spmenu -i -l 10 -p `Enter
|
||||||
|
S expression:'
|
||||||
|
.IP \[bu] 2
|
||||||
speedwm.mfact: 0.50
|
speedwm.mfact: 0.50
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedwm.mfact.lowest: 0.05
|
speedwm.mfact.lowest: 0.05
|
||||||
|
@ -1675,7 +1678,7 @@ Mihir Lad
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
MLquest8
|
MLquest8
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
Ond\[u0159]ej Grover
|
Ondřej Grover
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
ornx
|
ornx
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
|
@ -1691,7 +1694,7 @@ Ryan Roden-Corrent
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
sipi
|
sipi
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
S\[:o]nke Lambert
|
Sönke Lambert
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
speedie
|
speedie
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
|
@ -1703,6 +1706,6 @@ suckless.org
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
Timmy Keller
|
Timmy Keller
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
Viliam Kov\['a]\[u010D]
|
Viliam Kováč
|
||||||
.PP
|
.PP
|
||||||
See Codeberg contributions for more information.
|
See Codeberg contributions for more information.
|
||||||
|
|
|
@ -955,6 +955,7 @@ static xcb_connection_t *xcon;
|
||||||
#include "toggle/query.h"
|
#include "toggle/query.h"
|
||||||
#endif
|
#endif
|
||||||
#include "options.h" /* Include options */
|
#include "options.h" /* Include options */
|
||||||
|
#include "layouts.c" /* Enable patched layouts */
|
||||||
|
|
||||||
/* Shell command */
|
/* Shell command */
|
||||||
#define cmd( cmd ) {.v = (const char*[]){ shell, "-c", cmd, NULL } },
|
#define cmd( cmd ) {.v = (const char*[]){ shell, "-c", cmd, NULL } },
|
||||||
|
@ -6798,6 +6799,3 @@ togglewin(const Arg *arg)
|
||||||
focus(c);
|
focus(c);
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Layout code */
|
|
||||||
#include "layouts.c" /* Enable patched layouts */
|
|
||||||
|
|
|
@ -187,6 +187,7 @@ ResourcePref resources[] = {
|
||||||
{ "layout.monocle.count", INTEGER, &monoclecount },
|
{ "layout.monocle.count", INTEGER, &monoclecount },
|
||||||
{ "layout.deck.format", STRING, &deckformat },
|
{ "layout.deck.format", STRING, &deckformat },
|
||||||
{ "layout.deck.count", INTEGER, &deckcount },
|
{ "layout.deck.count", INTEGER, &deckcount },
|
||||||
|
{ "layout.custom.cmd", STRING, &custom_cmd },
|
||||||
#if USEWINICON
|
#if USEWINICON
|
||||||
{ "icon.size", INTEGER, &iconsize },
|
{ "icon.size", INTEGER, &iconsize },
|
||||||
{ "icon.spacing", INTEGER, &iconspacing },
|
{ "icon.spacing", INTEGER, &iconspacing },
|
||||||
|
|
Loading…
Reference in a new issue