MCPcopy Create free account
hub / github.com/Alexays/Waybar / convertWorkspaceNameToNum

Method convertWorkspaceNameToNum

src/modules/sway/workspaces.cpp:13–24  ·  view source on GitHub ↗

Helper function to assign a number to a workspace, just like sway. In fact this is taken quite verbatim from `sway/ipc-json.c`.

Source from the content-addressed store, hash-verified

11// Helper function to assign a number to a workspace, just like sway. In fact
12// this is taken quite verbatim from `sway/ipc-json.c`.
13int Workspaces::convertWorkspaceNameToNum(std::string name) {
14 if (isdigit(name[0]) != 0) {
15 errno = 0;
16 char* endptr = nullptr;
17 long long parsed_num = strtoll(name.c_str(), &endptr, 10);
18 if (errno != 0 || parsed_num > INT32_MAX || parsed_num < 0 || endptr == name.c_str()) {
19 return -1;
20 }
21 return (int)parsed_num;
22 }
23 return -1;
24}
25
26int Workspaces::windowRewritePriorityFunction(std::string const& window_rule) {
27 // Rules that match against title are prioritized

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected