mirror of
https://github.com/hyprwm/Hypr.git
synced 2024-11-26 06:45:58 +01:00
added a status command
This commit is contained in:
parent
c8553387bb
commit
a7f53b5dfa
4 changed files with 29 additions and 6 deletions
|
@ -13,6 +13,9 @@ max_fps=60
|
||||||
col.active_border=0x77ff3333
|
col.active_border=0x77ff3333
|
||||||
col.inactive_border=0x77222222
|
col.inactive_border=0x77222222
|
||||||
|
|
||||||
|
# status command
|
||||||
|
status_command=date +%a,\ %b\ %Y\ \ %I:%M\ %p
|
||||||
|
|
||||||
# animations
|
# animations
|
||||||
anim.enabled=1
|
anim.enabled=1
|
||||||
anim.speed=8
|
anim.speed=8
|
||||||
|
|
|
@ -169,12 +169,15 @@ void CStatusBar::draw() {
|
||||||
drawnWorkspaces++;
|
drawnWorkspaces++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw time to the right
|
// Draw STATUS to the right
|
||||||
std::string TIME = exec("date +%I:%M\\ %p");
|
std::string STATUS = exec(m_szStatusCommand.c_str());
|
||||||
TIME = TIME.substr(0, TIME.length() - 1);
|
STATUS = STATUS.substr(0, (STATUS.length() > 0 ? STATUS.length() - 1 : 9999999));
|
||||||
xcb_image_text_8(g_pWindowManager->DisplayConnection, TIME.length(), m_iPixmap,
|
if (STATUS != "") {
|
||||||
m_mContexts["BASETEXT"].GContext, m_vecSize.x - getTextWidth(TIME, m_mContexts["BASETEXT"].Font), (m_vecSize.y - (m_vecSize.y - 10) / 2),
|
xcb_image_text_8(g_pWindowManager->DisplayConnection, STATUS.length(), m_iPixmap,
|
||||||
TIME.c_str());
|
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);
|
xcb_flush(g_pWindowManager->DisplayConnection);
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ public:
|
||||||
|
|
||||||
EXPOSED_MEMBER(WindowID, xcb_window_t, i);
|
EXPOSED_MEMBER(WindowID, xcb_window_t, i);
|
||||||
EXPOSED_MEMBER(MonitorID, int, i);
|
EXPOSED_MEMBER(MonitorID, int, i);
|
||||||
|
EXPOSED_MEMBER(StatusCommand, std::string, sz); // TODO: make the bar better
|
||||||
|
|
||||||
void draw();
|
void draw();
|
||||||
void setup(int MonitorID);
|
void setup(int MonitorID);
|
||||||
|
|
|
@ -19,6 +19,8 @@ void ConfigManager::init() {
|
||||||
configValues["bar_monitor"].intValue = 0;
|
configValues["bar_monitor"].intValue = 0;
|
||||||
configValues["bar_height"].intValue = 15;
|
configValues["bar_height"].intValue = 15;
|
||||||
|
|
||||||
|
configValues["status_command"].strValue = "date +%I:%M\\ %p"; // Time
|
||||||
|
|
||||||
|
|
||||||
// Set Colors ARGB
|
// Set Colors ARGB
|
||||||
configValues["col.active_border"].intValue = 0x77FF3333;
|
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));
|
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) {
|
void parseLine(std::string& line) {
|
||||||
// first check if its not a comment
|
// first check if its not a comment
|
||||||
const auto COMMENTSTART = line.find_first_of('#');
|
const auto COMMENTSTART = line.find_first_of('#');
|
||||||
|
@ -95,6 +105,12 @@ void parseLine(std::string& line) {
|
||||||
if (COMMAND == "bind") {
|
if (COMMAND == "bind") {
|
||||||
handleBind(COMMAND, VALUE);
|
handleBind(COMMAND, VALUE);
|
||||||
return;
|
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())
|
if (ConfigManager::configValues.find(COMMAND) == ConfigManager::configValues.end())
|
||||||
|
|
Loading…
Reference in a new issue