diff --git a/actions.c b/actions.c index bed1686..41d1fc4 100644 --- a/actions.c +++ b/actions.c @@ -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; diff --git a/atlas.h b/atlas.h index a85525c..bd075b6 100644 --- a/atlas.h +++ b/atlas.h @@ -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; diff --git a/config.example.toml b/config.example.toml index 07b01b9..a6a4156 100644 --- a/config.example.toml +++ b/config.example.toml @@ -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" } diff --git a/configurer.c b/configurer.c index 0f0420a..0dd6d43 100644 --- a/configurer.c +++ b/configurer.c @@ -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}};