fix(bspwm): Look for socket path in env variable
Fixes jaagr/lemonbuddy#29
This commit is contained in:
parent
3ad583b8d0
commit
99f97b07eb
@ -498,6 +498,9 @@ The configuration syntax is based on the `ini` file format.
|
|||||||
|
|
||||||
|
|
||||||
#### Module `internal/bspwm`
|
#### Module `internal/bspwm`
|
||||||
|
|
||||||
|
To specify a custom path to the bspwm socket, you can set the environment variable `$BSPWM_SOCKET`.
|
||||||
|
|
||||||
~~~ ini
|
~~~ ini
|
||||||
[module/bspwm]
|
[module/bspwm]
|
||||||
type = internal/bspwm
|
type = internal/bspwm
|
||||||
|
@ -18,6 +18,15 @@ using namespace bspwm;
|
|||||||
#define DEFAULT_WS_ICON "workspace_icon-default"
|
#define DEFAULT_WS_ICON "workspace_icon-default"
|
||||||
#define DEFAULT_WS_LABEL "%icon% %name%"
|
#define DEFAULT_WS_LABEL "%icon% %name%"
|
||||||
|
|
||||||
|
std::string get_socket_path()
|
||||||
|
{
|
||||||
|
std::string socket_path = BSPWM_SOCKET_PATH;
|
||||||
|
const char *env_bs = std::getenv("BSPWM_SOCKET");
|
||||||
|
if (env_bs != nullptr)
|
||||||
|
socket_path = std::string(env_bs);
|
||||||
|
return socket_path;
|
||||||
|
}
|
||||||
|
|
||||||
bspwm::payload_t generate_payload(std::string command)
|
bspwm::payload_t generate_payload(std::string command)
|
||||||
{
|
{
|
||||||
bspwm::payload_t payload;
|
bspwm::payload_t payload;
|
||||||
@ -41,11 +50,13 @@ bool send_payload(int fd, bspwm::payload_t payload)
|
|||||||
|
|
||||||
int create_subscriber()
|
int create_subscriber()
|
||||||
{
|
{
|
||||||
int socket_fd;
|
int socket_fd = -1;
|
||||||
if ((socket_fd = io::socket::open(BSPWM_SOCKET_PATH)) == -1)
|
std::string socket_path = get_socket_path();
|
||||||
throw ModuleError("Could not connect to socket");
|
|
||||||
|
if ((socket_fd = io::socket::open(socket_path)) == -1)
|
||||||
|
throw ModuleError("bspwm: Could not connect to socket: "+ socket_path);
|
||||||
if (!send_payload(socket_fd, generate_payload("subscribe report")))
|
if (!send_payload(socket_fd, generate_payload("subscribe report")))
|
||||||
throw ModuleError("Failed to subscribe to bspwm changes");
|
throw ModuleError("bspwm: Failed to subscribe to bspwm changes");
|
||||||
return socket_fd;
|
return socket_fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,9 +280,10 @@ bool BspwmModule::handle_command(std::string cmd)
|
|||||||
<< std::atoi(cmd.substr(std::strlen(EVENT_CLICK)).c_str());
|
<< std::atoi(cmd.substr(std::strlen(EVENT_CLICK)).c_str());
|
||||||
|
|
||||||
int payload_fd;
|
int payload_fd;
|
||||||
|
std::string socket_path = get_socket_path();
|
||||||
|
|
||||||
if ((payload_fd = io::socket::open(BSPWM_SOCKET_PATH)) == -1)
|
if ((payload_fd = io::socket::open(socket_path)) == -1)
|
||||||
this->logger->error("bspwm: Failed to open socket");
|
this->logger->error("bspwm: Failed to open socket: "+ socket_path);
|
||||||
else if (!send_payload(payload_fd, generate_payload(payload_s.str())))
|
else if (!send_payload(payload_fd, generate_payload(payload_s.str())))
|
||||||
this->logger->error("bspwm: Failed to change desktop");
|
this->logger->error("bspwm: Failed to change desktop");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user