dwm: Get socket path from config, not env or cmake
Don't get the socket path from cmake or from an environment variable. Instead, get it from the polybar config. If it's not specified, the default is /tmp/dwm.sock which is default for the IPC patch. This way is easier for the user to configure.
This commit is contained in:
parent
a0fa04d6a6
commit
de3748122f
@ -64,8 +64,6 @@ set(SETTING_ALSA_SOUNDCARD "default"
|
||||
CACHE STRING "Name of the ALSA soundcard driver")
|
||||
set(SETTING_BSPWM_SOCKET_PATH "/tmp/bspwm_0_0-socket"
|
||||
CACHE STRING "Path to bspwm socket")
|
||||
set(SETTING_DWM_SOCKET_PATH "/tmp/dwm.sock"
|
||||
CACHE STRING "Path to dwm socket")
|
||||
set(SETTING_BSPWM_STATUS_PREFIX "W"
|
||||
CACHE STRING "Prefix prepended to the bspwm status line")
|
||||
set(SETTING_CONNECTION_TEST_IP "8.8.8.8"
|
||||
|
@ -169,6 +169,8 @@ label-urgent-padding = 2
|
||||
[module/dwm]
|
||||
type = internal/dwm
|
||||
format = <label-tags> <label-layout> <label-floating> <label-title>
|
||||
; Path to dwm socket (default: /tmp/dwm.sock)
|
||||
; socket-path = /tmp/dwm.sock
|
||||
|
||||
; Left-click to view tag, right-click to toggle tag view
|
||||
enable-tags-click = false
|
||||
|
@ -290,6 +290,11 @@ namespace modules {
|
||||
*/
|
||||
string m_secondary_layout_symbol{"[M]"};
|
||||
|
||||
/**
|
||||
* DWM socket path. Can be overriden by config.
|
||||
*/
|
||||
string m_socket_path{"/tmp/dwm.sock"};
|
||||
|
||||
/**
|
||||
* Holds the address to the secondary layout specified by the secondary
|
||||
* layout symbol
|
||||
|
@ -61,7 +61,6 @@ extern const char* const ALSA_SOUNDCARD;
|
||||
extern const char* const BSPWM_SOCKET_PATH;
|
||||
extern const char* const BSPWM_STATUS_PREFIX;
|
||||
extern const char* const CONNECTION_TEST_IP;
|
||||
extern const char* const DWM_SOCKET_PATH;
|
||||
extern const char* const PATH_ADAPTER;
|
||||
extern const char* const PATH_BACKLIGHT;
|
||||
extern const char* const PATH_BATTERY;
|
||||
|
@ -16,23 +16,6 @@ namespace modules {
|
||||
template class module<dwm_module>;
|
||||
|
||||
dwm_module::dwm_module(const bar_settings& bar, string name_) : event_module<dwm_module>(bar, move(name_)) {
|
||||
string socket_path = env_util::get("DWM_SOCKET");
|
||||
if (socket_path.empty()) {
|
||||
// Defined by cmake
|
||||
socket_path = DWM_SOCKET_PATH;
|
||||
}
|
||||
|
||||
if (!file_util::exists(socket_path)) {
|
||||
throw module_error("Could not find socket: " + (socket_path.empty() ? "<empty>" : socket_path));
|
||||
}
|
||||
|
||||
try {
|
||||
m_ipc = factory_util::unique<dwmipc::Connection>(socket_path);
|
||||
} catch (const dwmipc::IPCError& err) {
|
||||
throw module_error(err.what());
|
||||
}
|
||||
m_log.info("%s: Connected to dwm socket", name());
|
||||
|
||||
// Load configuration
|
||||
m_formatter->add(
|
||||
DEFAULT_FORMAT, DEFAULT_FORMAT_TAGS, {TAG_LABEL_TAGS, TAG_LABEL_LAYOUT, TAG_LABEL_FLOATING, TAG_LABEL_TITLE});
|
||||
@ -71,10 +54,18 @@ namespace modules {
|
||||
m_layout_wrap = m_conf.get(name(), "layout-scroll-wrap", m_layout_wrap);
|
||||
m_layout_reverse = m_conf.get(name(), "layout-scroll-reverse", m_layout_reverse);
|
||||
m_secondary_layout_symbol = m_conf.get(name(), "secondary-layout-symbol", m_secondary_layout_symbol);
|
||||
|
||||
m_socket_path = m_conf.get(name(), "socket-path", m_socket_path);
|
||||
m_log.info("%s: Initialized formatter and labels", name());
|
||||
|
||||
|
||||
if (!file_util::exists(m_socket_path)) {
|
||||
throw module_error("Could not find socket: " + (m_socket_path.empty() ? "<empty>" : m_socket_path));
|
||||
}
|
||||
|
||||
try {
|
||||
m_ipc = factory_util::unique<dwmipc::Connection>(m_socket_path);
|
||||
m_log.info("%s: Connected to dwm socket", name());
|
||||
|
||||
update_monitor_ref();
|
||||
m_log.info("%s: Initialized monitors", name());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user