summaryrefslogtreecommitdiff
path: root/src/parser.c
diff options
context:
space:
mode:
authorAbhinav <abhinav.prsai@gmail.com>2025-06-24 00:20:36 +0100
committerAbhinav <abhinav.prsai@gmail.com>2025-06-24 00:20:36 +0100
commitcc234a66f020256ca2cd2a0a189fda00195bb8f0 (patch)
treeef27eafe15154ef42f9f773fae96d52ad3d969b2 /src/parser.c
parentd0862b78106c9bdd4c286b2e165cec9b582e04f1 (diff)
add scratchpads
there are now i3 like scratchpads. all default binds added, mans updated
Diffstat (limited to 'src/parser.c')
-rw-r--r--src/parser.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/src/parser.c b/src/parser.c
index c8f748d..b230fa6 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -368,17 +368,58 @@ found:
int n;
if (sscanf(act, "move %d", &n) == 1 && n >= 1 && n <= NUM_WORKSPACES) {
- b->type = TYPE_CWKSP;
+ b->type = TYPE_WS_CHANGE;
b->action.ws = n - 1;
}
else if (sscanf(act, "swap %d", &n) == 1 && n >= 1 && n <= NUM_WORKSPACES) {
- b->type = TYPE_MWKSP;
+ b->type = TYPE_WS_MOVE;
b->action.ws = n - 1;
}
else {
fprintf(stderr, "sxwmrc:%d: invalid workspace action '%s'\n", lineno, act);
}
}
+ else if (!strcmp(key, "scratchpad")) {
+ char *mid = strchr(rest, ':');
+ if (!mid) {
+ fprintf(stderr, "sxwmrc:%d: scratchpad missing action\n", lineno);
+ continue;
+ }
+ *mid = '\0';
+ char *combo = strip(rest);
+ char *act = strip(mid + 1);
+
+ KeySym ks;
+ unsigned mods = parse_combo(combo, cfg, &ks);
+ if (ks == NoSymbol) {
+ fprintf(stderr, "sxwmrc:%d: bad key in '%s'\n", lineno, combo);
+ continue;
+ }
+
+ Binding *b = alloc_bind(cfg, mods, ks);
+ if (!b) {
+ fputs("sxwm: too many binds\n", stderr);
+ goto cleanup_file;
+ }
+
+ int padnum = -1;
+
+ if (sscanf(act, "create %d", &padnum) == 1 && padnum >= 1 && padnum <= MAX_SCRATCHPADS) {
+ b->type = TYPE_SP_CREATE;
+ b->action.sp = padnum - 1;
+ }
+ else if (sscanf(act, "toggle %d", &padnum) == 1 && padnum >= 1 && padnum <= MAX_SCRATCHPADS) {
+ b->type = TYPE_SP_TOGGLE;
+ b->action.sp = padnum - 1;
+ }
+ else if (sscanf(act, "remove %d", &padnum) == 1 && padnum >= 1 && padnum <= MAX_SCRATCHPADS) {
+ b->type = TYPE_SP_REMOVE;
+ b->action.sp = padnum - 1;
+ }
+ else {
+ fprintf(stderr, "sxwmrc:%d: invalid scratchpad action '%s'\n", lineno, act);
+ }
+ }
else if (!strcmp(key, "exec")) {
if (torun >= 256) {
fprintf(stderr, "sxwmrc:%d: too many exec commands\n", lineno);