diff --git a/layouts.c b/layouts.c index 30dc043..0a5655e 100644 --- a/layouts.c +++ b/layouts.c @@ -1320,11 +1320,15 @@ custom(Monitor *m) struct s_recur_analyze_ret ret = s_recur_analyze(&clients, s_layout_scheme); + int oh, ov, ih, iv; + unsigned int n; + getgaps(m, &oh, &ov, &ih, &iv, &n); + struct frame_t frame; - frame.x = m->wx; - frame.y = m->wy; - frame.w = m->ww; - frame.h = m->wh; + frame.x = m->wx + ov; + frame.y = m->wy + oh; + frame.w = m->ww - 2 * ov; + frame.h = m->wh - 2 * oh; s_recur_resize(ret.head, frame); @@ -1626,46 +1630,36 @@ node_t* parse_sexp(string_token_t **token) *token = t; return head; } - -void -set_s_layout(const Arg *arg) +#define SXP_HISTORY ".dwm_sxp_history" +void set_s_layout(const Arg *arg) { FILE *pp, *hf; char pathbuf[1024]; char *home = getenv("HOME"); if (home != NULL) { - snprintf(pathbuf, 1023, "%s/", customhistfile, home); + snprintf(pathbuf, 1023, "%s/" SXP_HISTORY, home); pathbuf[1023] = '\0'; - /* make sure the history file exists */ - hf = fopen(customhistfile, "a"); fclose(hf); - if (!system("sort" customhistfile " | uniq > " customhistfile "~")) - return; + // make sure the history file exists + hf = fopen(SXP_HISTORY, "a"); fclose(hf); + system("sort " SXP_HISTORY " | uniq > " SXP_HISTORY "~"); + system("mv " SXP_HISTORY "~ " SXP_HISTORY); - if (!system("mv " customhistfile "~ " customhistfile)) - return; - - pp = popen(customprompt customhistfile, "r"); + pp = popen("dmenu -i -l 10 -p 'sxp>' <" SXP_HISTORY, "r"); } else { - pp = popen(customprompt, "r"); + pp = popen("dmenu -i -l 10 -p 'sxp>'", "r"); } - - if (!pp) - return; - - char buf[2048]; - buf[2048] = '\0'; - - if (!fgets(buf, 1024, pp)) - return; - + if (!pp) return; + char buf[1024 + 1]; + buf[1024] = '\0'; + fgets(buf, 1024, pp); fclose(pp); - if (buf[0] == '\0') - return; + if (buf[0] == '\0') return; - hf = fopen(customhistfile, "a"); + // Write to history file + hf = fopen(SXP_HISTORY, "a"); fprintf(hf, "%s", buf); fclose(hf); @@ -1679,7 +1673,9 @@ set_s_layout(const Arg *arg) s_layout_scheme = parse_sexp(&token); - /* Free the token list */ + setlayout(arg); + + // Free the token list while (token_root != NULL) { token = token_root->next; free(token_root);