Skip to content

Commit

Permalink
feat: add keybinding actions for workspace movement
Browse files Browse the repository at this point in the history
  • Loading branch information
jasper-clarke committed Nov 11, 2024
1 parent 0a08b6b commit d39a67e
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
44 changes: 44 additions & 0 deletions actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,50 @@ void executeKeybinding(Keybinding *kb) {
toggleWindowFloating(&arg);
break;

case ACTION_VIEWWORKSPACE:
// Convert workspace name to index
for (size_t i = 0; i < cfg.workspaceCount; i++) {
if (strcasecmp(kb->value, cfg.workspaces[i].name) == 0) {
arg.ui = 1 << i;
break;
}
}
viewWorkspace(&arg);
break;

case ACTION_MOVETOWORKSPACE:
// Convert workspace name to index
for (size_t i = 0; i < cfg.workspaceCount; i++) {
if (strcasecmp(kb->value, cfg.workspaces[i].name) == 0) {
arg.ui = 1 << i;
break;
}
}
moveToWorkspace(&arg);
break;

case ACTION_DUPLICATETOWORKSPACE:
// Convert workspace name to index
for (size_t i = 0; i < cfg.workspaceCount; i++) {
if (strcasecmp(kb->value, cfg.workspaces[i].name) == 0) {
arg.ui = 1 << i;
break;
}
}
duplicateToWorkspace(&arg);
break;

case ACTION_TOGGLEWORKSPACE:
// Convert workspace name to index
for (size_t i = 0; i < cfg.workspaceCount; i++) {
if (strcasecmp(kb->value, cfg.workspaces[i].name) == 0) {
arg.ui = 1 << i;
break;
}
}
toggleWorkspace(&arg);
break;

case ACTION_QUIT:
quit(&arg);
break;
Expand Down
4 changes: 4 additions & 0 deletions atlas.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ typedef enum {
ACTION_TOGGLEFLOATING,
ACTION_FOCUSMONITOR,
ACTION_MOVETOMONITOR,
ACTION_VIEWWORKSPACE,
ACTION_MOVETOWORKSPACE,
ACTION_DUPLICATETOWORKSPACE,
ACTION_TOGGLEWORKSPACE,
ACTION_QUIT,
ACTION_UNKNOWN
} ActionType;
Expand Down
4 changes: 4 additions & 0 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ refresh_rate = 144
"Super+h" = { action = "focusmonitor", value = "prev", desc = "Focus previous monitor" }
"Super+Shift+l" = { action = "movetomonitor", value = "next", desc = "Move window to next monitor" }
"Super+Shift+h" = { action = "movetomonitor", value = "prev", desc = "Move window to previous monitor" }
"Super+1" = { action = "viewworkspace", value = "web", desc = "View web workspace" }
"Super+2" = { action = "viewworkspace", value = "code", desc = "View code workspace " }
"Super+Shift+1" = { action = "movetoworkspace", value = "web", desc = "View web wor kspace" }
"Super+Shift+2" = { action = "movetoworkspace", value = "code", desc = "View code w orkspace" }
4 changes: 4 additions & 0 deletions configurer.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ static const struct {
{"togglefloating", ACTION_TOGGLEFLOATING},
{"focusmonitor", ACTION_FOCUSMONITOR},
{"movetomonitor", ACTION_MOVETOMONITOR},
{"viewworkspace", ACTION_VIEWWORKSPACE},
{"movetoworkspace", ACTION_MOVETOWORKSPACE},
{"duplicatetoworkspace", ACTION_DUPLICATETOWORKSPACE},
{"toggleworkspace", ACTION_TOGGLEWORKSPACE},
{"quit", ACTION_QUIT},
{NULL, ACTION_UNKNOWN}};

Expand Down

0 comments on commit d39a67e

Please sign in to comment.