From b6c5563b0b37013468e9f38fdf9111101e0880c3 Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Fri, 21 Apr 2017 18:15:18 +0200 Subject: [PATCH] feat(ipc): Add visibility commands --- doc/zsh/_polybar_msg | 2 +- include/components/bar.hpp | 6 ++++ src/components/bar.cpp | 60 +++++++++++++++++++++++++++++++++-- src/components/controller.cpp | 6 ++++ 4 files changed, 70 insertions(+), 4 deletions(-) diff --git a/doc/zsh/_polybar_msg b/doc/zsh/_polybar_msg index 80611e80..c6cb54ad 100644 --- a/doc/zsh/_polybar_msg +++ b/doc/zsh/_polybar_msg @@ -16,7 +16,7 @@ _polybar_msg() { case $words[1] in hook) _arguments ':module name:' ':hook index:'; ret=0 ;; action) _arguments ':action payload:'; ret=0 ;; - cmd) _arguments ':command payload:'; ret=0 ;; + cmd) _arguments ':command payload:(show hide toggle restart quit)'; ret=0 ;; esac ;; esac diff --git a/include/components/bar.hpp b/include/components/bar.hpp index ceeb6e61..616ecdcc 100644 --- a/include/components/bar.hpp +++ b/include/components/bar.hpp @@ -41,6 +41,10 @@ class bar : public xpp::event::sinkmap_state == XCB_MAP_STATE_UNVIEWABLE) { - m_sig.emit(visibility_change{move(false)}); + m_sig.emit(visibility_change{false}); } else if (attr->map_state == XCB_MAP_STATE_UNMAPPED) { - m_sig.emit(visibility_change{move(false)}); + m_sig.emit(visibility_change{false}); } else { - m_sig.emit(visibility_change{move(true)}); + m_sig.emit(visibility_change{true}); } } diff --git a/src/components/controller.cpp b/src/components/controller.cpp index eeab009a..0632fa7f 100644 --- a/src/components/controller.cpp +++ b/src/components/controller.cpp @@ -636,6 +636,12 @@ bool controller::on(const signals::ipc::command& evt) { enqueue(make_quit_evt(false)); } else if (command == "restart") { enqueue(make_quit_evt(true)); + } else if (command == "hide") { + m_bar->hide(); + } else if (command == "show") { + m_bar->show(); + } else if (command == "toggle") { + m_bar->toggle(); } else { m_log.warn("\"%s\" is not a valid ipc command", command); }