aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/desktop/Workspace.cpp2
-rw-r--r--src/managers/KeybindManager.cpp32
-rw-r--r--src/managers/KeybindManager.hpp3
3 files changed, 23 insertions, 14 deletions
diff --git a/src/desktop/Workspace.cpp b/src/desktop/Workspace.cpp
index 35fc5727..2d92659c 100644
--- a/src/desktop/Workspace.cpp
+++ b/src/desktop/Workspace.cpp
@@ -51,7 +51,7 @@ void CWorkspace::init(PHLWORKSPACE self) {
if (self->m_bWasCreatedEmpty)
if (auto cmd = WORKSPACERULE.onCreatedEmptyRunCmd)
- g_pKeybindManager->spawn(*cmd);
+ g_pKeybindManager->spawnWithRules(*cmd, self);
g_pEventManager->postEvent({"createworkspace", m_szName});
g_pEventManager->postEvent({"createworkspacev2", std::format("{},{}", m_iID, m_szName)});
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 7ee5ae7e..2db9f375 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -34,7 +34,7 @@ using namespace Hyprutils::String;
#include <sys/consio.h>
#endif
-static std::vector<std::pair<std::string, std::string>> getHyprlandLaunchEnv() {
+static std::vector<std::pair<std::string, std::string>> getHyprlandLaunchEnv(PHLWORKSPACE pInitialWorkspace) {
static auto PINITIALWSTRACKING = CConfigValue<Hyprlang::INT>("misc:initial_workspace_tracking");
if (!*PINITIALWSTRACKING || g_pConfigManager->isLaunchingExecOnce)
@@ -46,11 +46,15 @@ static std::vector<std::pair<std::string, std::string>> getHyprlandLaunchEnv() {
std::vector<std::pair<std::string, std::string>> result;
- result.push_back(std::make_pair<>(
- "HL_INITIAL_WORKSPACE_TOKEN",
- g_pTokenManager->registerNewToken(
- SInitialWorkspaceToken{{}, PMONITOR->activeSpecialWorkspace ? PMONITOR->activeSpecialWorkspace->getConfigName() : PMONITOR->activeWorkspace->getConfigName()},
- std::chrono::months(1337))));
+ if (!pInitialWorkspace) {
+ if (PMONITOR->activeSpecialWorkspace)
+ pInitialWorkspace = PMONITOR->activeSpecialWorkspace;
+ else
+ pInitialWorkspace = PMONITOR->activeWorkspace;
+ }
+
+ result.push_back(std::make_pair<>("HL_INITIAL_WORKSPACE_TOKEN",
+ g_pTokenManager->registerNewToken(SInitialWorkspaceToken{{}, pInitialWorkspace->getConfigName()}, std::chrono::months(1337))));
return result;
}
@@ -846,8 +850,12 @@ bool CKeybindManager::handleInternalKeybinds(xkb_keysym_t keysym) {
}
// Dispatchers
-
SDispatchResult CKeybindManager::spawn(std::string args) {
+ const uint64_t PROC = spawnWithRules(args, nullptr);
+ return {.success = PROC > 0, .error = std::format("Failed to start process {}", args)};
+}
+
+uint64_t CKeybindManager::spawnWithRules(std::string args, PHLWORKSPACE pInitialWorkspace) {
args = trim(args);
@@ -859,7 +867,7 @@ SDispatchResult CKeybindManager::spawn(std::string args) {
args = args.substr(args.find_first_of(']') + 1);
}
- const uint64_t PROC = spawnRawProc(args);
+ const uint64_t PROC = spawnRawProc(args, pInitialWorkspace);
if (!RULES.empty()) {
const auto RULESLIST = CVarList(RULES, 0, ';');
@@ -871,18 +879,18 @@ SDispatchResult CKeybindManager::spawn(std::string args) {
Debug::log(LOG, "Applied {} rule arguments for exec.", RULESLIST.size());
}
- return {.success = PROC > 0, .error = std::format("Failed to start process {}", args)};
+ return PROC;
}
SDispatchResult CKeybindManager::spawnRaw(std::string args) {
- const uint64_t PROC = spawnRawProc(args);
+ const uint64_t PROC = spawnRawProc(args, nullptr);
return {.success = PROC > 0, .error = std::format("Failed to start process {}", args)};
}
-uint64_t CKeybindManager::spawnRawProc(std::string args) {
+uint64_t CKeybindManager::spawnRawProc(std::string args, PHLWORKSPACE pInitialWorkspace) {
Debug::log(LOG, "Executing {}", args);
- const auto HLENV = getHyprlandLaunchEnv();
+ const auto HLENV = getHyprlandLaunchEnv(pInitialWorkspace);
int socket[2];
if (pipe(socket) != 0) {
diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp
index d1f26c2c..bf3b049f 100644
--- a/src/managers/KeybindManager.hpp
+++ b/src/managers/KeybindManager.hpp
@@ -149,7 +149,8 @@ class CKeybindManager {
static void moveWindowOutOfGroup(PHLWINDOW pWindow, const std::string& dir = "");
static void moveWindowIntoGroup(PHLWINDOW pWindow, PHLWINDOW pWindowInDirection);
static void switchToWindow(PHLWINDOW PWINDOWTOCHANGETO);
- static uint64_t spawnRawProc(std::string);
+ static uint64_t spawnRawProc(std::string, PHLWORKSPACE pInitialWorkspace);
+ static uint64_t spawnWithRules(std::string, PHLWORKSPACE pInitialWorkspace);
// -------------- Dispatchers -------------- //
static SDispatchResult killActive(std::string);