diff --git a/cmake/02-opts.cmake b/cmake/02-opts.cmake index e561e025..2bd64eaf 100644 --- a/cmake/02-opts.cmake +++ b/cmake/02-opts.cmake @@ -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" diff --git a/config.cmake b/config.cmake index 407a05b3..3bee809d 100644 --- a/config.cmake +++ b/config.cmake @@ -169,6 +169,8 @@ label-urgent-padding = 2 [module/dwm] type = internal/dwm format = +; 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 diff --git a/include/modules/dwm.hpp b/include/modules/dwm.hpp index ab7ec38d..c4cb1642 100644 --- a/include/modules/dwm.hpp +++ b/include/modules/dwm.hpp @@ -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 diff --git a/include/settings.hpp.cmake b/include/settings.hpp.cmake index 844a4af6..ddbac986 100644 --- a/include/settings.hpp.cmake +++ b/include/settings.hpp.cmake @@ -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; diff --git a/src/modules/dwm.cpp b/src/modules/dwm.cpp index 5b21b1bd..e5d4fa81 100644 --- a/src/modules/dwm.cpp +++ b/src/modules/dwm.cpp @@ -16,23 +16,6 @@ namespace modules { template class module; dwm_module::dwm_module(const bar_settings& bar, string name_) : event_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() ? "" : socket_path)); - } - - try { - m_ipc = factory_util::unique(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() ? "" : m_socket_path)); + } + try { + m_ipc = factory_util::unique(m_socket_path); + m_log.info("%s: Connected to dwm socket", name()); + update_monitor_ref(); m_log.info("%s: Initialized monitors", name());