implemented specialWorkspaceMap
This commit is contained in:
parent
93598400a3
commit
0166b32872
5 changed files with 69 additions and 130 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
scripts/clients/build/
|
||||
scripts/clients/build/
|
||||
.vscode/
|
85
.vscode/settings.json
vendored
85
.vscode/settings.json
vendored
|
@ -1,85 +0,0 @@
|
|||
{
|
||||
"files.associations": {
|
||||
"cctype": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cstring": "cpp",
|
||||
"ctime": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"any": "cpp",
|
||||
"array": "cpp",
|
||||
"atomic": "cpp",
|
||||
"hash_map": "cpp",
|
||||
"bit": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"bitset": "cpp",
|
||||
"charconv": "cpp",
|
||||
"chrono": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"codecvt": "cpp",
|
||||
"compare": "cpp",
|
||||
"complex": "cpp",
|
||||
"concepts": "cpp",
|
||||
"condition_variable": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"deque": "cpp",
|
||||
"forward_list": "cpp",
|
||||
"list": "cpp",
|
||||
"map": "cpp",
|
||||
"set": "cpp",
|
||||
"string": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"unordered_set": "cpp",
|
||||
"vector": "cpp",
|
||||
"exception": "cpp",
|
||||
"algorithm": "cpp",
|
||||
"functional": "cpp",
|
||||
"iterator": "cpp",
|
||||
"memory": "cpp",
|
||||
"memory_resource": "cpp",
|
||||
"numeric": "cpp",
|
||||
"optional": "cpp",
|
||||
"random": "cpp",
|
||||
"ratio": "cpp",
|
||||
"source_location": "cpp",
|
||||
"string_view": "cpp",
|
||||
"system_error": "cpp",
|
||||
"tuple": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"utility": "cpp",
|
||||
"hash_set": "cpp",
|
||||
"format": "cpp",
|
||||
"fstream": "cpp",
|
||||
"future": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iomanip": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"iostream": "cpp",
|
||||
"istream": "cpp",
|
||||
"limits": "cpp",
|
||||
"mutex": "cpp",
|
||||
"new": "cpp",
|
||||
"numbers": "cpp",
|
||||
"ostream": "cpp",
|
||||
"ranges": "cpp",
|
||||
"semaphore": "cpp",
|
||||
"shared_mutex": "cpp",
|
||||
"span": "cpp",
|
||||
"sstream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"stdfloat": "cpp",
|
||||
"stop_token": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"thread": "cpp",
|
||||
"cfenv": "cpp",
|
||||
"typeindex": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"valarray": "cpp",
|
||||
"variant": "cpp"
|
||||
}
|
||||
}
|
0
bar.yuck
0
bar.yuck
20
eww.yuck
20
eww.yuck
|
@ -190,15 +190,27 @@
|
|||
:id {workspaces[0].special.id}
|
||||
:icon {workspaces[0].special.icon}
|
||||
:monitor {monitor})
|
||||
(seperator)
|
||||
(normalWorkspaces
|
||||
:monitor {monitor})
|
||||
(seperator)
|
||||
(workspace
|
||||
:activeOn {workspaces[1].special.activeOn}
|
||||
:occupied {workspaces[1].special.occupied}
|
||||
:id {workspaces[1].special.id}
|
||||
:icon {workspaces[1].special.icon}
|
||||
:monitor {monitor})
|
||||
(seperator)
|
||||
(normalWorkspaces
|
||||
:monitor {monitor})
|
||||
(seperator)
|
||||
(workspace
|
||||
:activeOn {workspaces[2].special.activeOn}
|
||||
:occupied {workspaces[2].special.occupied}
|
||||
:id {workspaces[2].special.id}
|
||||
:icon {workspaces[2].special.icon}
|
||||
:monitor {monitor})
|
||||
(workspace
|
||||
:activeOn {workspaces[3].special.activeOn}
|
||||
:occupied {workspaces[3].special.occupied}
|
||||
:id {workspaces[3].special.id}
|
||||
:icon {workspaces[3].special.icon}
|
||||
:monitor {monitor})))
|
||||
|
||||
(defwidget end []
|
||||
|
|
|
@ -21,11 +21,11 @@ json workspacesOutput;
|
|||
std::map<std::string, std::string> iconMap;
|
||||
std::map<int, std::string> monitorMap;
|
||||
|
||||
const std::map<std::string, int> specialWorkspaceMap = {
|
||||
{"special:super", 0},
|
||||
{"special:ctrl", 1},
|
||||
{"special:alt", 2},
|
||||
{"special:gr", 3}
|
||||
std::map<std::string, int> specialWorkspaceMap = {
|
||||
{"special:ctrl", 0},
|
||||
{"special:alt", 1},
|
||||
{"special:altgr", 2},
|
||||
{"special:strg", 3}
|
||||
};
|
||||
|
||||
|
||||
|
@ -155,7 +155,7 @@ void getAllWorkspaces()
|
|||
{
|
||||
json workspacesInput = json::parse(command("hyprctl workspaces -j"));
|
||||
|
||||
int specialIndex = 0;
|
||||
int specialIndex = 4; //next index after specialWorkspaceMap
|
||||
|
||||
for(const auto& workspace : workspacesInput)
|
||||
{
|
||||
|
@ -168,10 +168,21 @@ void getAllWorkspaces()
|
|||
}
|
||||
else if (std::string(workspace["name"]).find("special:") == 0)
|
||||
{
|
||||
workspacesOutput[specialIndex]["special"].clear();
|
||||
workspacesOutput[specialIndex]["special"] = getWorkspace(workspace);
|
||||
std::string name = workspace["name"];
|
||||
|
||||
specialIndex++;
|
||||
int currentIndex;
|
||||
|
||||
if (specialWorkspaceMap.contains(name))
|
||||
{
|
||||
currentIndex = specialWorkspaceMap[name];
|
||||
}
|
||||
else
|
||||
{
|
||||
currentIndex = specialIndex;
|
||||
specialIndex++;
|
||||
}
|
||||
workspacesOutput[currentIndex]["special"].clear();
|
||||
workspacesOutput[currentIndex]["special"] = getWorkspace(workspace);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -237,47 +248,47 @@ int main(int argc, char const *argv[])
|
|||
|
||||
|
||||
// Create a socket
|
||||
int sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (sockfd == -1) {
|
||||
std::cerr << "Error: Failed to create socket\n";
|
||||
return 1;
|
||||
}
|
||||
int sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (sockfd == -1) {
|
||||
std::cerr << "Error: Failed to create socket\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Define the address of the IPC socket
|
||||
struct sockaddr_un addr;
|
||||
// Define the address of the IPC socket
|
||||
struct sockaddr_un addr;
|
||||
addr.sun_family = AF_UNIX;
|
||||
strncpy(addr.sun_path, socketPath.c_str(), sizeof(addr.sun_path) - 1);
|
||||
strncpy(addr.sun_path, socketPath.c_str(), sizeof(addr.sun_path) - 1);
|
||||
|
||||
// Connect to the IPC socket
|
||||
if (connect(sockfd, (struct sockaddr*)&addr, sizeof(addr)) == -1) {
|
||||
std::cerr << "Error: Failed to connect to IPC socket\n";
|
||||
close(sockfd);
|
||||
return 1;
|
||||
}
|
||||
// Connect to the IPC socket
|
||||
if (connect(sockfd, (struct sockaddr*)&addr, sizeof(addr)) == -1) {
|
||||
std::cerr << "Error: Failed to connect to IPC socket\n";
|
||||
close(sockfd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Receive and print messages from the IPC socket
|
||||
char buffer[1024];
|
||||
ssize_t bytes_received;
|
||||
while ((bytes_received = recv(sockfd, buffer, sizeof(buffer), 0)) > 0) {
|
||||
// Receive and print messages from the IPC socket
|
||||
char buffer[1024];
|
||||
ssize_t bytes_received;
|
||||
while ((bytes_received = recv(sockfd, buffer, sizeof(buffer), 0)) > 0) {
|
||||
|
||||
std::string message = std::string(buffer, bytes_received);
|
||||
std::string message = std::string(buffer, bytes_received);
|
||||
|
||||
std::istringstream iss(message);
|
||||
std::string messageLine;
|
||||
std::istringstream iss(message);
|
||||
std::string messageLine;
|
||||
|
||||
while(std::getline(iss, messageLine)){
|
||||
handle(messageLine);
|
||||
}
|
||||
while(std::getline(iss, messageLine)){
|
||||
handle(messageLine);
|
||||
}
|
||||
|
||||
}
|
||||
if (bytes_received == -1) {
|
||||
std::cerr << "Error: Failed to receive message\n";
|
||||
}
|
||||
}
|
||||
if (bytes_received == -1) {
|
||||
std::cerr << "Error: Failed to receive message\n";
|
||||
}
|
||||
|
||||
// Close the socket
|
||||
close(sockfd);
|
||||
// Close the socket
|
||||
close(sockfd);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Reference in a new issue