gBar/src/Workspaces.h

51 lines
1.2 KiB
C
Raw Normal View History

2023-01-13 15:13:56 +00:00
#pragma once
#include "Common.h"
#include "System.h"
#include "Config.h"
2023-01-13 15:13:56 +00:00
#include <cstdint>
#include <string>
#include <cstdlib>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#ifdef WITH_WORKSPACES
namespace Workspaces
2023-01-13 15:13:56 +00:00
{
void Init();
void PollStatus(uint32_t monitorID, uint32_t numWorkspaces);
System::WorkspaceStatus GetStatus(uint32_t workspaceId);
void Shutdown();
// TODO: Use ext_workspaces for this, if applicable
2023-01-13 15:13:56 +00:00
inline void Goto(uint32_t workspace)
{
if (RuntimeConfig::Get().hasWorkspaces == false)
{
LOG("Error: Called Go to workspace, but Workspaces isn't open!");
return;
}
2023-06-14 22:23:02 +00:00
LOG("Switching workspace: hyprctl dispatch workspace " << workspace);
2023-01-13 15:13:56 +00:00
system(("hyprctl dispatch workspace " + std::to_string(workspace)).c_str());
}
// direction: + or -
inline void GotoNext(char direction)
{
char scrollOp = 'e';
if (Config::Get().workspaceScrollOnMonitor)
{
scrollOp = 'm';
}
std::string cmd = std::string("hyprctl dispatch workspace ") + scrollOp + direction + "1";
2023-06-14 22:23:02 +00:00
LOG("Switching workspace: " << cmd.c_str());
system(cmd.c_str());
}
2023-01-13 15:13:56 +00:00
}
#endif