diff --git a/example/hypr.conf b/example/hypr.conf index a645ab2..3e8e95a 100644 --- a/example/hypr.conf +++ b/example/hypr.conf @@ -13,6 +13,9 @@ max_fps=60 col.active_border=0x77ff3333 col.inactive_border=0x77222222 +# status command +status_command=date +%a,\ %b\ %Y\ \ %I:%M\ %p + # animations anim.enabled=1 anim.speed=8 diff --git a/src/bar/Bar.cpp b/src/bar/Bar.cpp index acb1993..c2c7bc1 100644 --- a/src/bar/Bar.cpp +++ b/src/bar/Bar.cpp @@ -169,12 +169,15 @@ void CStatusBar::draw() { drawnWorkspaces++; } - // Draw time to the right - std::string TIME = exec("date +%I:%M\\ %p"); - TIME = TIME.substr(0, TIME.length() - 1); - xcb_image_text_8(g_pWindowManager->DisplayConnection, TIME.length(), m_iPixmap, - m_mContexts["BASETEXT"].GContext, m_vecSize.x - getTextWidth(TIME, m_mContexts["BASETEXT"].Font), (m_vecSize.y - (m_vecSize.y - 10) / 2), - TIME.c_str()); + // Draw STATUS to the right + std::string STATUS = exec(m_szStatusCommand.c_str()); + STATUS = STATUS.substr(0, (STATUS.length() > 0 ? STATUS.length() - 1 : 9999999)); + if (STATUS != "") { + xcb_image_text_8(g_pWindowManager->DisplayConnection, STATUS.length(), m_iPixmap, + m_mContexts["BASETEXT"].GContext, m_vecSize.x - getTextWidth(STATUS, m_mContexts["BASETEXT"].Font), (m_vecSize.y - (m_vecSize.y - 10) / 2), + STATUS.c_str()); + } + xcb_flush(g_pWindowManager->DisplayConnection); diff --git a/src/bar/Bar.hpp b/src/bar/Bar.hpp index 569839f..04a4fb5 100644 --- a/src/bar/Bar.hpp +++ b/src/bar/Bar.hpp @@ -15,6 +15,7 @@ public: EXPOSED_MEMBER(WindowID, xcb_window_t, i); EXPOSED_MEMBER(MonitorID, int, i); + EXPOSED_MEMBER(StatusCommand, std::string, sz); // TODO: make the bar better void draw(); void setup(int MonitorID); diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 949b939..e39d841 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -19,6 +19,8 @@ void ConfigManager::init() { configValues["bar_monitor"].intValue = 0; configValues["bar_height"].intValue = 15; + configValues["status_command"].strValue = "date +%I:%M\\ %p"; // Time + // Set Colors ARGB configValues["col.active_border"].intValue = 0x77FF3333; @@ -72,6 +74,14 @@ void handleBind(const std::string& command, const std::string& value) { KeybindManager::keybinds.push_back(Keybind(mod, KEY, COMMAND, dispatcher)); } +void handleRawExec(const std::string& command, const std::string& args) { + exec(args.c_str()); +} + +void handleStatusCommand(const std::string& command, const std::string& args) { + g_pWindowManager->statusBar.setStatusCommand(args); +} + void parseLine(std::string& line) { // first check if its not a comment const auto COMMENTSTART = line.find_first_of('#'); @@ -95,6 +105,12 @@ void parseLine(std::string& line) { if (COMMAND == "bind") { handleBind(COMMAND, VALUE); return; + } else if (COMMAND == "exec") { + handleRawExec(COMMAND, VALUE); + return; + } else if (COMMAND == "status_command") { + handleStatusCommand(COMMAND, VALUE); + return; } if (ConfigManager::configValues.find(COMMAND) == ConfigManager::configValues.end())