From 0166b32872cea270b00b10939da99cb93606ae13 Mon Sep 17 00:00:00 2001 From: willifan Date: Tue, 9 Apr 2024 18:12:55 +0200 Subject: [PATCH] implemented specialWorkspaceMap --- .gitignore | 3 +- .vscode/settings.json | 85 --------------------------------- bar.yuck | 0 eww.yuck | 20 ++++++-- scripts/clients/src/main.cpp | 91 ++++++++++++++++++++---------------- 5 files changed, 69 insertions(+), 130 deletions(-) delete mode 100644 .vscode/settings.json delete mode 100644 bar.yuck diff --git a/.gitignore b/.gitignore index 589cdfe..cdc2e32 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -scripts/clients/build/ \ No newline at end of file +scripts/clients/build/ +.vscode/ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 8f1f60b..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -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" - } -} \ No newline at end of file diff --git a/bar.yuck b/bar.yuck deleted file mode 100644 index e69de29..0000000 diff --git a/eww.yuck b/eww.yuck index 140afe6..3750e78 100644 --- a/eww.yuck +++ b/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 [] diff --git a/scripts/clients/src/main.cpp b/scripts/clients/src/main.cpp index c319be1..f381161 100644 --- a/scripts/clients/src/main.cpp +++ b/scripts/clients/src/main.cpp @@ -21,11 +21,11 @@ json workspacesOutput; std::map iconMap; std::map monitorMap; -const std::map specialWorkspaceMap = { - {"special:super", 0}, - {"special:ctrl", 1}, - {"special:alt", 2}, - {"special:gr", 3} +std::map 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; } \ No newline at end of file