Get socket path from env I3SOCK

- Adds support for sway
This commit is contained in:
Mike Wallio
2020-10-23 09:51:02 -04:00
parent edb1a864f0
commit 2b14cbe87a

View File

@@ -283,25 +283,7 @@ static std::shared_ptr<bar_config_t> parse_bar_config_from_json(const Json::Val
std::string get_socketpath() { std::string get_socketpath() {
std::string str; return std::getenv("I3SOCK");
{
auss_t str_buf;
FILE* in;
char buf[512] = {0};
if (!(in = popen("i3 --get-socketpath", "r"))) {
throw errno_error("Failed to get socket path");
}
while (fgets(buf, sizeof(buf), in) != nullptr) {
str_buf << buf;
}
pclose(in);
str = str_buf;
}
if (str.back() == '\n') {
str.pop_back();
}
return str;
} }