From 884b909e7d4c8f670785ba3fac80ec931922ab50 Mon Sep 17 00:00:00 2001 From: Benjamin Voisin Date: Thu, 9 May 2024 17:28:08 +0200 Subject: [PATCH 1/9] =?UTF-8?q?=E2=9C=A8=20add=20GtkMenu=20to=20the=20AMod?= =?UTF-8?q?ule=20class?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit You can configure what key launch the menu with the "menu" element in the config, the xml file that describes the menu with the "menu-file" element in the config, and the actions of each buttons with the "menu-actions" field. --- include/AModule.hpp | 5 +++++ src/AModule.cpp | 30 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/include/AModule.hpp b/include/AModule.hpp index 58076655..903e00b8 100644 --- a/include/AModule.hpp +++ b/include/AModule.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "IModule.hpp" @@ -52,6 +53,10 @@ class AModule : public IModule { std::vector pid_; gdouble distance_scrolled_y_; gdouble distance_scrolled_x_; + GObject* menu_; + std::map submenus_; + std::map menuActionsMap_; + static void handleGtkMenuEvent(GtkMenuItem* menuitem, gpointer data); std::map eventActionMap_; static const inline std::map, std::string> eventMap_{ {std::make_pair(1, GdkEventType::GDK_BUTTON_PRESS), "on-click"}, diff --git a/src/AModule.cpp b/src/AModule.cpp index 915c8603..709a1e38 100644 --- a/src/AModule.cpp +++ b/src/AModule.cpp @@ -27,6 +27,24 @@ AModule::AModule(const Json::Value& config, const std::string& name, const std:: else spdlog::warn("Wrong actions section configuration. See config by index: {}", it.index()); } + // If a GTKMenu is requested in the config + if (config_["menu"].isString()) { + // Create the GTKMenu widget + GtkBuilder* builder = gtk_builder_new_from_file(config_["menu-file"].asString().c_str()); + menu_ = gtk_builder_get_object(builder, "menu"); + submenus_ = std::map(); + menuActionsMap_ = std::map(); + // Linking actions to the GTKMenu based on + for (Json::Value::const_iterator it = config_["menu-actions"].begin(); it != config_["menu-actions"].end(); ++it) { + std::string key = it.key().asString(); + submenus_[key] = GTK_MENU_ITEM(gtk_builder_get_object(builder, key.c_str())); + menuActionsMap_[key] = it->asString(); + g_signal_connect(submenus_[key], "activate", G_CALLBACK(handleGtkMenuEvent), (gpointer) menuActionsMap_[key].c_str()); + + } + // Enable click + enable_click = true; + } event_box_.signal_enter_notify_event().connect(sigc::mem_fun(*this, &AModule::handleMouseEnter)); event_box_.signal_leave_notify_event().connect(sigc::mem_fun(*this, &AModule::handleMouseLeave)); @@ -66,6 +84,10 @@ AModule::AModule(const Json::Value& config, const std::string& name, const std:: } } +void AModule::handleGtkMenuEvent(GtkMenuItem* menuitem, gpointer data) { + waybar::util::command::res res = waybar::util::command::exec((char*) data, "TLP"); +} + AModule::~AModule() { for (const auto& pid : pid_) { if (pid != -1) { @@ -133,6 +155,14 @@ bool AModule::handleUserEvent(GdkEventButton* const& e) { format = rec->second; } + + // Check if the event is the one specified for the "menu" option + if (rec->second == config_["menu"].asString()) { + // Popup the menu + gtk_widget_show_all(GTK_WIDGET(menu_)); + gtk_menu_popup_at_pointer (GTK_MENU(menu_), reinterpret_cast(e)); + + } // Second call user scripts if (!format.empty()) { if (config_[format].isString()) From 3b87b830761615df7ed74b3877405dddb48255dc Mon Sep 17 00:00:00 2001 From: Benjamin Voisin Date: Thu, 9 May 2024 18:34:26 +0200 Subject: [PATCH 2/9] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20move=20GMenu=20to=20AL?= =?UTF-8?q?abel=20class?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/ALabel.hpp | 4 ++++ include/AModule.hpp | 5 +---- src/ALabel.cpp | 22 +++++++++++++++++++++- src/AModule.cpp | 22 ---------------------- 4 files changed, 26 insertions(+), 27 deletions(-) diff --git a/include/ALabel.hpp b/include/ALabel.hpp index 888c65a8..8855a3ed 100644 --- a/include/ALabel.hpp +++ b/include/ALabel.hpp @@ -27,6 +27,10 @@ class ALabel : public AModule { bool handleToggle(GdkEventButton *const &e) override; virtual std::string getState(uint8_t value, bool lesser = false); + + std::map submenus_; + std::map menuActionsMap_; + static void handleGtkMenuEvent(GtkMenuItem* menuitem, gpointer data); }; } // namespace waybar diff --git a/include/AModule.hpp b/include/AModule.hpp index 903e00b8..961f2a7f 100644 --- a/include/AModule.hpp +++ b/include/AModule.hpp @@ -45,6 +45,7 @@ class AModule : public IModule { virtual bool handleMouseLeave(GdkEventCrossing *const &ev); virtual bool handleScroll(GdkEventScroll *); virtual bool handleRelease(GdkEventButton *const &ev); + GObject* menu_; private: bool handleUserEvent(GdkEventButton *const &ev); @@ -53,10 +54,6 @@ class AModule : public IModule { std::vector pid_; gdouble distance_scrolled_y_; gdouble distance_scrolled_x_; - GObject* menu_; - std::map submenus_; - std::map menuActionsMap_; - static void handleGtkMenuEvent(GtkMenuItem* menuitem, gpointer data); std::map eventActionMap_; static const inline std::map, std::string> eventMap_{ {std::make_pair(1, GdkEventType::GDK_BUTTON_PRESS), "on-click"}, diff --git a/src/ALabel.cpp b/src/ALabel.cpp index b8d39df5..4befb5b5 100644 --- a/src/ALabel.cpp +++ b/src/ALabel.cpp @@ -9,7 +9,7 @@ namespace waybar { ALabel::ALabel(const Json::Value& config, const std::string& name, const std::string& id, const std::string& format, uint16_t interval, bool ellipsize, bool enable_click, bool enable_scroll) - : AModule(config, name, id, config["format-alt"].isString() || enable_click, enable_scroll), + : AModule(config, name, id, config["format-alt"].isString() || config["menu"].isString() || enable_click, enable_scroll), format_(config_["format"].isString() ? config_["format"].asString() : format), interval_(config_["interval"] == "once" ? std::chrono::seconds::max() @@ -51,6 +51,22 @@ ALabel::ALabel(const Json::Value& config, const std::string& name, const std::st } } + // If a GTKMenu is requested in the config + if (config_["menu"].isString()) { + // Create the GTKMenu widget + GtkBuilder* builder = gtk_builder_new_from_file(config_["menu-file"].asString().c_str()); + menu_ = gtk_builder_get_object(builder, "menu"); + submenus_ = std::map(); + menuActionsMap_ = std::map(); + // Linking actions to the GTKMenu based on + for (Json::Value::const_iterator it = config_["menu-actions"].begin(); it != config_["menu-actions"].end(); ++it) { + std::string key = it.key().asString(); + submenus_[key] = GTK_MENU_ITEM(gtk_builder_get_object(builder, key.c_str())); + menuActionsMap_[key] = it->asString(); + g_signal_connect(submenus_[key], "activate", G_CALLBACK(handleGtkMenuEvent), (gpointer) menuActionsMap_[key].c_str()); + } + } + if (config_["justify"].isString()) { auto justify_str = config_["justify"].asString(); if (justify_str == "left") { @@ -125,6 +141,10 @@ bool waybar::ALabel::handleToggle(GdkEventButton* const& e) { return AModule::handleToggle(e); } +void ALabel::handleGtkMenuEvent(GtkMenuItem* menuitem, gpointer data) { + waybar::util::command::res res = waybar::util::command::exec((char*) data, "GtkMenu"); +} + std::string ALabel::getState(uint8_t value, bool lesser) { if (!config_["states"].isObject()) { return ""; diff --git a/src/AModule.cpp b/src/AModule.cpp index 709a1e38..b2cf2fca 100644 --- a/src/AModule.cpp +++ b/src/AModule.cpp @@ -27,24 +27,6 @@ AModule::AModule(const Json::Value& config, const std::string& name, const std:: else spdlog::warn("Wrong actions section configuration. See config by index: {}", it.index()); } - // If a GTKMenu is requested in the config - if (config_["menu"].isString()) { - // Create the GTKMenu widget - GtkBuilder* builder = gtk_builder_new_from_file(config_["menu-file"].asString().c_str()); - menu_ = gtk_builder_get_object(builder, "menu"); - submenus_ = std::map(); - menuActionsMap_ = std::map(); - // Linking actions to the GTKMenu based on - for (Json::Value::const_iterator it = config_["menu-actions"].begin(); it != config_["menu-actions"].end(); ++it) { - std::string key = it.key().asString(); - submenus_[key] = GTK_MENU_ITEM(gtk_builder_get_object(builder, key.c_str())); - menuActionsMap_[key] = it->asString(); - g_signal_connect(submenus_[key], "activate", G_CALLBACK(handleGtkMenuEvent), (gpointer) menuActionsMap_[key].c_str()); - - } - // Enable click - enable_click = true; - } event_box_.signal_enter_notify_event().connect(sigc::mem_fun(*this, &AModule::handleMouseEnter)); event_box_.signal_leave_notify_event().connect(sigc::mem_fun(*this, &AModule::handleMouseLeave)); @@ -84,10 +66,6 @@ AModule::AModule(const Json::Value& config, const std::string& name, const std:: } } -void AModule::handleGtkMenuEvent(GtkMenuItem* menuitem, gpointer data) { - waybar::util::command::res res = waybar::util::command::exec((char*) data, "TLP"); -} - AModule::~AModule() { for (const auto& pid : pid_) { if (pid != -1) { From 21751b2faab327e839f3d0d24960539679220eb4 Mon Sep 17 00:00:00 2001 From: Benjamin Voisin Date: Thu, 9 May 2024 20:59:25 +0200 Subject: [PATCH 3/9] =?UTF-8?q?=F0=9F=8E=A8=20clang-tidy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/ALabel.hpp | 4 ++-- include/AModule.hpp | 4 ++-- src/ALabel.cpp | 12 ++++++++---- src/AModule.cpp | 3 +-- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/include/ALabel.hpp b/include/ALabel.hpp index 8855a3ed..a1aae9da 100644 --- a/include/ALabel.hpp +++ b/include/ALabel.hpp @@ -28,9 +28,9 @@ class ALabel : public AModule { bool handleToggle(GdkEventButton *const &e) override; virtual std::string getState(uint8_t value, bool lesser = false); - std::map submenus_; + std::map submenus_; std::map menuActionsMap_; - static void handleGtkMenuEvent(GtkMenuItem* menuitem, gpointer data); + static void handleGtkMenuEvent(GtkMenuItem *menuitem, gpointer data); }; } // namespace waybar diff --git a/include/AModule.hpp b/include/AModule.hpp index 961f2a7f..90f34187 100644 --- a/include/AModule.hpp +++ b/include/AModule.hpp @@ -2,9 +2,9 @@ #include #include +#include #include #include -#include #include "IModule.hpp" @@ -45,7 +45,7 @@ class AModule : public IModule { virtual bool handleMouseLeave(GdkEventCrossing *const &ev); virtual bool handleScroll(GdkEventScroll *); virtual bool handleRelease(GdkEventButton *const &ev); - GObject* menu_; + GObject *menu_; private: bool handleUserEvent(GdkEventButton *const &ev); diff --git a/src/ALabel.cpp b/src/ALabel.cpp index 4befb5b5..56850617 100644 --- a/src/ALabel.cpp +++ b/src/ALabel.cpp @@ -9,7 +9,9 @@ namespace waybar { ALabel::ALabel(const Json::Value& config, const std::string& name, const std::string& id, const std::string& format, uint16_t interval, bool ellipsize, bool enable_click, bool enable_scroll) - : AModule(config, name, id, config["format-alt"].isString() || config["menu"].isString() || enable_click, enable_scroll), + : AModule(config, name, id, + config["format-alt"].isString() || config["menu"].isString() || enable_click, + enable_scroll), format_(config_["format"].isString() ? config_["format"].asString() : format), interval_(config_["interval"] == "once" ? std::chrono::seconds::max() @@ -59,11 +61,13 @@ ALabel::ALabel(const Json::Value& config, const std::string& name, const std::st submenus_ = std::map(); menuActionsMap_ = std::map(); // Linking actions to the GTKMenu based on - for (Json::Value::const_iterator it = config_["menu-actions"].begin(); it != config_["menu-actions"].end(); ++it) { + for (Json::Value::const_iterator it = config_["menu-actions"].begin(); + it != config_["menu-actions"].end(); ++it) { std::string key = it.key().asString(); submenus_[key] = GTK_MENU_ITEM(gtk_builder_get_object(builder, key.c_str())); menuActionsMap_[key] = it->asString(); - g_signal_connect(submenus_[key], "activate", G_CALLBACK(handleGtkMenuEvent), (gpointer) menuActionsMap_[key].c_str()); + g_signal_connect(submenus_[key], "activate", G_CALLBACK(handleGtkMenuEvent), + (gpointer)menuActionsMap_[key].c_str()); } } @@ -142,7 +146,7 @@ bool waybar::ALabel::handleToggle(GdkEventButton* const& e) { } void ALabel::handleGtkMenuEvent(GtkMenuItem* menuitem, gpointer data) { - waybar::util::command::res res = waybar::util::command::exec((char*) data, "GtkMenu"); + waybar::util::command::res res = waybar::util::command::exec((char*)data, "GtkMenu"); } std::string ALabel::getState(uint8_t value, bool lesser) { diff --git a/src/AModule.cpp b/src/AModule.cpp index b2cf2fca..77b82cee 100644 --- a/src/AModule.cpp +++ b/src/AModule.cpp @@ -138,8 +138,7 @@ bool AModule::handleUserEvent(GdkEventButton* const& e) { if (rec->second == config_["menu"].asString()) { // Popup the menu gtk_widget_show_all(GTK_WIDGET(menu_)); - gtk_menu_popup_at_pointer (GTK_MENU(menu_), reinterpret_cast(e)); - + gtk_menu_popup_at_pointer(GTK_MENU(menu_), reinterpret_cast(e)); } // Second call user scripts if (!format.empty()) { From c3581fb66ba23f8466358ce920f9038ce7607ab2 Mon Sep 17 00:00:00 2001 From: Benjamin Voisin Date: Tue, 28 May 2024 17:20:31 +0200 Subject: [PATCH 4/9] =?UTF-8?q?=F0=9F=A5=85=20only=20check=20menu=20if=20s?= =?UTF-8?q?peciifed=20in=20the=20conf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AModule.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/AModule.cpp b/src/AModule.cpp index 77b82cee..9948edab 100644 --- a/src/AModule.cpp +++ b/src/AModule.cpp @@ -134,11 +134,14 @@ bool AModule::handleUserEvent(GdkEventButton* const& e) { format = rec->second; } - // Check if the event is the one specified for the "menu" option - if (rec->second == config_["menu"].asString()) { - // Popup the menu - gtk_widget_show_all(GTK_WIDGET(menu_)); - gtk_menu_popup_at_pointer(GTK_MENU(menu_), reinterpret_cast(e)); + // Check that a menu has been configured + if (config_["menu"].isString()) { + // Check if the event is the one specified for the "menu" option + if (rec->second == config_["menu"].asString()) { + // Popup the menu + gtk_widget_show_all(GTK_WIDGET(menu_)); + gtk_menu_popup_at_pointer(GTK_MENU(menu_), reinterpret_cast(e)); + } } // Second call user scripts if (!format.empty()) { From f3ed5ca5afe3966f1af429eb5171526388dc18a6 Mon Sep 17 00:00:00 2001 From: Benjamin Voisin Date: Tue, 28 May 2024 18:08:31 +0200 Subject: [PATCH 5/9] =?UTF-8?q?=F0=9F=8C=B1=20update=20default=20config=20?= =?UTF-8?q?with=20a=20menu=20example?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/config.jsonc | 15 ++++++++++++- resources/custom_modules/power_menu.xml | 28 +++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 resources/custom_modules/power_menu.xml diff --git a/resources/config.jsonc b/resources/config.jsonc index 329275b1..7e0771f5 100644 --- a/resources/config.jsonc +++ b/resources/config.jsonc @@ -30,7 +30,8 @@ "battery", "battery#bat2", "clock", - "tray" + "tray", + "custom/power" ], // Modules configuration // "sway/workspaces": { @@ -198,5 +199,17 @@ "escape": true, "exec": "$HOME/.config/waybar/mediaplayer.py 2> /dev/null" // Script in resources folder // "exec": "$HOME/.config/waybar/mediaplayer.py --player spotify 2> /dev/null" // Filter player based on name + }, + "custom/power": { + "format" : "⏻ ", + "tooltip": false, + "menu": "on-click", + "menu-file": "$HOME/.config/waybar/power_menu.xml", // Menu file in resources folder + "menu-actions": { + "shutdown": "shutdown", + "reboot": "reboot", + "suspend": "systemctl suspend", + "hibernate": "systemctl hibernate" + } } } diff --git a/resources/custom_modules/power_menu.xml b/resources/custom_modules/power_menu.xml new file mode 100644 index 00000000..aa2a42ca --- /dev/null +++ b/resources/custom_modules/power_menu.xml @@ -0,0 +1,28 @@ + + + + + + Suspend + + + + + Hibernate + + + + + Shutdown + + + + + + + + Reboot + + + + From 161c8c4c47e219a3c457e01a355e7b6fde029228 Mon Sep 17 00:00:00 2001 From: Benjamin Voisin Date: Tue, 28 May 2024 19:30:06 +0200 Subject: [PATCH 6/9] =?UTF-8?q?=F0=9F=A5=85=20do=20not=20crash=20when=20un?= =?UTF-8?q?able=20to=20make=20the=20menu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the menu cannot be built (file not existing, or wrongly formatted), the menu is not created and a warning with an explanaition is displayed. --- src/ALabel.cpp | 49 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/src/ALabel.cpp b/src/ALabel.cpp index 56850617..5497c62a 100644 --- a/src/ALabel.cpp +++ b/src/ALabel.cpp @@ -2,6 +2,8 @@ #include +#include +#include #include namespace waybar { @@ -56,18 +58,41 @@ ALabel::ALabel(const Json::Value& config, const std::string& name, const std::st // If a GTKMenu is requested in the config if (config_["menu"].isString()) { // Create the GTKMenu widget - GtkBuilder* builder = gtk_builder_new_from_file(config_["menu-file"].asString().c_str()); - menu_ = gtk_builder_get_object(builder, "menu"); - submenus_ = std::map(); - menuActionsMap_ = std::map(); - // Linking actions to the GTKMenu based on - for (Json::Value::const_iterator it = config_["menu-actions"].begin(); - it != config_["menu-actions"].end(); ++it) { - std::string key = it.key().asString(); - submenus_[key] = GTK_MENU_ITEM(gtk_builder_get_object(builder, key.c_str())); - menuActionsMap_[key] = it->asString(); - g_signal_connect(submenus_[key], "activate", G_CALLBACK(handleGtkMenuEvent), - (gpointer)menuActionsMap_[key].c_str()); + try { + // Check that the file exists + std::string menuFile = config_["menu-file"].asString(); + // Read the menu descriptor file + std::ifstream file(menuFile); + if (!file.is_open()) { + throw std::runtime_error("Failed to open file: " + menuFile); + } + std::stringstream fileContent; + fileContent << file.rdbuf(); + GtkBuilder* builder = gtk_builder_new(); + + // Make the GtkBuilder and check for errors in his parsing + if (!gtk_builder_add_from_string(builder, fileContent.str().c_str(), -1, nullptr)) { + throw std::runtime_error("Error found in the file " + menuFile); + } + + menu_ = gtk_builder_get_object(builder, "menu"); + if (!menu_) { + throw std::runtime_error("Failed to get 'menu' object from GtkBuilder"); + } + submenus_ = std::map(); + menuActionsMap_ = std::map(); + + // Linking actions to the GTKMenu based on + for (Json::Value::const_iterator it = config_["menu-actions"].begin(); + it != config_["menu-actions"].end(); ++it) { + std::string key = it.key().asString(); + submenus_[key] = GTK_MENU_ITEM(gtk_builder_get_object(builder, key.c_str())); + menuActionsMap_[key] = it->asString(); + g_signal_connect(submenus_[key], "activate", G_CALLBACK(handleGtkMenuEvent), + (gpointer)menuActionsMap_[key].c_str()); + } + } catch (std::runtime_error& e) { + spdlog::warn("Error while creating the menu : {}. Menu popup not activated.", e.what()); } } From d9f2e0f7d28c2107e266aeffd0dcd929a8d8bf4d Mon Sep 17 00:00:00 2001 From: Benjamin Voisin Date: Tue, 28 May 2024 20:42:12 +0200 Subject: [PATCH 7/9] =?UTF-8?q?=F0=9F=93=9D=20add=20menu=20config=20inform?= =?UTF-8?q?ations=20in=20manpages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- man/waybar-backlight.5.scd | 13 +++++++++++++ man/waybar-battery.5.scd | 13 +++++++++++++ man/waybar-bluetooth.5.scd | 13 +++++++++++++ man/waybar-cava.5.scd | 12 ++++++++++++ man/waybar-clock.5.scd | 12 ++++++++++++ man/waybar-custom.5.scd | 13 +++++++++++++ man/waybar-disk.5.scd | 13 +++++++++++++ man/waybar-hyprland-language.5.scd | 13 +++++++++++++ man/waybar-hyprland-submap.5.scd | 13 +++++++++++++ man/waybar-idle-inhibitor.5.scd | 13 +++++++++++++ man/waybar-inhibitor.5.scd | 13 +++++++++++++ man/waybar-jack.5.scd | 13 +++++++++++++ man/waybar-memory.5.scd | 13 +++++++++++++ man/waybar-mpd.5.scd | 13 +++++++++++++ man/waybar-network.5.scd | 13 +++++++++++++ man/waybar-pulseaudio.5.scd | 13 +++++++++++++ man/waybar-river-layout.5.scd | 13 +++++++++++++ man/waybar-river-mode.5.scd | 13 +++++++++++++ man/waybar-river-window.5.scd | 13 +++++++++++++ man/waybar-sndio.5.scd | 13 +++++++++++++ man/waybar-sway-language.5.scd | 13 +++++++++++++ man/waybar-sway-mode.5.scd | 13 +++++++++++++ man/waybar-sway-scratchpad.5.scd | 13 +++++++++++++ man/waybar-systemd-failed-units.5.scd | 13 +++++++++++++ man/waybar-temperature.5.scd | 13 +++++++++++++ man/waybar-upower.5.scd | 13 +++++++++++++ man/waybar-wireplumber.5.scd | 13 +++++++++++++ 27 files changed, 349 insertions(+) diff --git a/man/waybar-backlight.5.scd b/man/waybar-backlight.5.scd index b92abd12..1f674fc0 100644 --- a/man/waybar-backlight.5.scd +++ b/man/waybar-backlight.5.scd @@ -81,6 +81,19 @@ The *backlight* module displays the current backlight level. default: 1.0 ++ The speed at which to change the brightness when scrolling. +*menu*: ++ + typeof: string ++ + Action that popups the menu. + +*menu-file*: ++ + typeof: string ++ + Location of the menu descriptor file. There need to be an element of type + GtkMenu with id *menu* + +*menu-actions*: ++ + typeof: array ++ + The actions corresponding to the buttons of the menu. + # EXAMPLE: ``` diff --git a/man/waybar-battery.5.scd b/man/waybar-battery.5.scd index 25c7caca..4fe9650a 100644 --- a/man/waybar-battery.5.scd +++ b/man/waybar-battery.5.scd @@ -109,6 +109,19 @@ The *battery* module displays the current capacity and state (eg. charging) of y default: false ++ Option to enable battery compatibility if not detected. +*menu*: ++ + typeof: string ++ + Action that popups the menu. + +*menu-file*: ++ + typeof: string ++ + Location of the menu descriptor file. There need to be an element of type + GtkMenu with id *menu* + +*menu-actions*: ++ + typeof: array ++ + The actions corresponding to the buttons of the menu. + # FORMAT REPLACEMENTS *{capacity}*: Capacity in percentage diff --git a/man/waybar-bluetooth.5.scd b/man/waybar-bluetooth.5.scd index 3808e855..1783dab3 100644 --- a/man/waybar-bluetooth.5.scd +++ b/man/waybar-bluetooth.5.scd @@ -129,6 +129,19 @@ Addressed by *bluetooth* typeof: string ++ This format is used to define how each connected device should be displayed within the *device_enumerate* format replacement in the tooltip menu. +*menu*: ++ + typeof: string ++ + Action that popups the menu. + +*menu-file*: ++ + typeof: string ++ + Location of the menu descriptor file. There need to be an element of type + GtkMenu with id *menu* + +*menu-actions*: ++ + typeof: array ++ + The actions corresponding to the buttons of the menu. + # FORMAT REPLACEMENTS *{status}*: Status of the bluetooth device. diff --git a/man/waybar-cava.5.scd b/man/waybar-cava.5.scd index cf75441b..2a7e8f67 100644 --- a/man/waybar-cava.5.scd +++ b/man/waybar-cava.5.scd @@ -120,6 +120,18 @@ libcava lives in: :[ string :[ /dev/stdout :[ It's impossible to set it. Waybar sets it to = /dev/stdout for internal needs +|[ *menu* +:[ string +:[ +:[ Action that popups the menu. +|[ *menu-file* +:[ string +:[ +:[ Location of the menu descriptor file. There need to be an element of type GtkMenu with id *menu* +|[ *menu-actions* +:[ array +:[ +:[ The actions corresponding to the buttons of the menu. Configuration can be provided as: - The only cava configuration file which is provided through *cava_config*. The rest configuration can be skipped diff --git a/man/waybar-clock.5.scd b/man/waybar-clock.5.scd index e8ef7bed..40aedd15 100644 --- a/man/waybar-clock.5.scd +++ b/man/waybar-clock.5.scd @@ -84,6 +84,18 @@ $XDG_CONFIG_HOME/waybar/config ++ :[ string :[ same as format :[ Tooltip on hover +|[ *menu* +:[ string +:[ +:[ Action that popups the menu. +|[ *menu-file* +:[ string +:[ +:[ Location of the menu descriptor file. There need to be an element of type GtkMenu with id *menu* +|[ *menu-actions* +:[ array +:[ +:[ The actions corresponding to the buttons of the menu. View all valid format options in *strftime(3)* or have a look https://en.cppreference.com/w/cpp/chrono/duration/formatter diff --git a/man/waybar-custom.5.scd b/man/waybar-custom.5.scd index a62c9312..df866ae1 100644 --- a/man/waybar-custom.5.scd +++ b/man/waybar-custom.5.scd @@ -121,6 +121,19 @@ Addressed by *custom/* default: false ++ Option to enable escaping of script output. +*menu*: ++ + typeof: string ++ + Action that popups the menu. + +*menu-file*: ++ + typeof: string ++ + Location of the menu descriptor file. There need to be an element of type + GtkMenu with id *menu* + +*menu-actions*: ++ + typeof: array ++ + The actions corresponding to the buttons of the menu. + # RETURN-TYPE When *return-type* is set to *json*, Waybar expects the *exec*-script to output its data in JSON format. diff --git a/man/waybar-disk.5.scd b/man/waybar-disk.5.scd index a279718b..df9ca4e5 100644 --- a/man/waybar-disk.5.scd +++ b/man/waybar-disk.5.scd @@ -93,6 +93,19 @@ Addressed by *disk* typeof: string ++ Use with specific_free, specific_used, and specific_total to force calculation to always be in a certain unit. Accepts kB, kiB, MB, Mib, GB, GiB, TB, TiB. +*menu*: ++ + typeof: string ++ + Action that popups the menu. + +*menu-file*: ++ + typeof: string ++ + Location of the menu descriptor file. There need to be an element of type + GtkMenu with id *menu* + +*menu-actions*: ++ + typeof: array ++ + The actions corresponding to the buttons of the menu. + # FORMAT REPLACEMENTS *{percentage_used}*: Percentage of disk in use. diff --git a/man/waybar-hyprland-language.5.scd b/man/waybar-hyprland-language.5.scd index dba7dbca..33b28ae4 100644 --- a/man/waybar-hyprland-language.5.scd +++ b/man/waybar-hyprland-language.5.scd @@ -25,6 +25,19 @@ Addressed by *hyprland/language* typeof: string ++ Specifies which keyboard to use from hyprctl devices output. Using the option that begins with "at-translated-set..." is recommended. +*menu*: ++ + typeof: string ++ + Action that popups the menu. + +*menu-file*: ++ + typeof: string ++ + Location of the menu descriptor file. There need to be an element of type + GtkMenu with id *menu* + +*menu-actions*: ++ + typeof: array ++ + The actions corresponding to the buttons of the menu. + # FORMAT REPLACEMENTS diff --git a/man/waybar-hyprland-submap.5.scd b/man/waybar-hyprland-submap.5.scd index 3f23784d..64398e61 100644 --- a/man/waybar-hyprland-submap.5.scd +++ b/man/waybar-hyprland-submap.5.scd @@ -80,6 +80,19 @@ Addressed by *hyprland/submap* default: Default ++ Option to set the submap name to display when not in an active submap. +*menu*: ++ + typeof: string ++ + Action that popups the menu. + +*menu-file*: ++ + typeof: string ++ + Location of the menu descriptor file. There need to be an element of type + GtkMenu with id *menu* + +*menu-actions*: ++ + typeof: array ++ + The actions corresponding to the buttons of the menu. + # EXAMPLES diff --git a/man/waybar-idle-inhibitor.5.scd b/man/waybar-idle-inhibitor.5.scd index 71b3b30c..f7677634 100644 --- a/man/waybar-idle-inhibitor.5.scd +++ b/man/waybar-idle-inhibitor.5.scd @@ -89,6 +89,19 @@ screensaver, also known as "presentation mode". typeof: string ++ This format is used when the inhibit is deactivated. +*menu*: ++ + typeof: string ++ + Action that popups the menu. Cannot be "on-click". + +*menu-file*: ++ + typeof: string ++ + Location of the menu descriptor file. There need to be an element of type + GtkMenu with id *menu* + +*menu-actions*: ++ + typeof: array ++ + The actions corresponding to the buttons of the menu. + # FORMAT REPLACEMENTS *{status}*: status (*activated* or *deactivated*) diff --git a/man/waybar-inhibitor.5.scd b/man/waybar-inhibitor.5.scd index 47b6ffce..679a5c4b 100644 --- a/man/waybar-inhibitor.5.scd +++ b/man/waybar-inhibitor.5.scd @@ -76,6 +76,19 @@ See *systemd-inhibit*(1) for more information. default: true ++ Option to disable tooltip on hover. +*menu*: ++ + typeof: string ++ + Action that popups the menu. Cannot be "on-click". + +*menu-file*: ++ + typeof: string ++ + Location of the menu descriptor file. There need to be an element of type + GtkMenu with id *menu* + +*menu-actions*: ++ + typeof: array ++ + The actions corresponding to the buttons of the menu. + # FORMAT REPLACEMENTS *{status}*: status (*activated* or *deactivated*) diff --git a/man/waybar-jack.5.scd b/man/waybar-jack.5.scd index 87a38354..573b36c2 100644 --- a/man/waybar-jack.5.scd +++ b/man/waybar-jack.5.scd @@ -85,6 +85,19 @@ Addressed by *jack* typeof: string ++ Command to execute when the module is updated. +*menu*: ++ + typeof: string ++ + Action that popups the menu. + +*menu-file*: ++ + typeof: string ++ + Location of the menu descriptor file. There need to be an element of type + GtkMenu with id *menu* + +*menu-actions*: ++ + typeof: array ++ + The actions corresponding to the buttons of the menu. + # FORMAT REPLACEMENTS *{load}*: The current CPU load estimated by JACK. diff --git a/man/waybar-memory.5.scd b/man/waybar-memory.5.scd index e0252caf..7738c576 100644 --- a/man/waybar-memory.5.scd +++ b/man/waybar-memory.5.scd @@ -84,6 +84,19 @@ Addressed by *memory* default: true ++ Option to disable tooltip on hover. +*menu*: ++ + typeof: string ++ + Action that popups the menu. + +*menu-file*: ++ + typeof: string ++ + Location of the menu descriptor file. There need to be an element of type + GtkMenu with id *menu* + +*menu-actions*: ++ + typeof: array ++ + The actions corresponding to the buttons of the menu. + # FORMAT REPLACEMENTS *{percentage}*: Percentage of memory in use. diff --git a/man/waybar-mpd.5.scd b/man/waybar-mpd.5.scd index fe6ee5a1..2f1bdf20 100644 --- a/man/waybar-mpd.5.scd +++ b/man/waybar-mpd.5.scd @@ -162,6 +162,19 @@ Addressed by *mpd* default: {} ++ Icon to show depending on the "single" option (*{ "on": "...", "off": "..." }*) +*menu*: ++ + typeof: string ++ + Action that popups the menu. + +*menu-file*: ++ + typeof: string ++ + Location of the menu descriptor file. There need to be an element of type + GtkMenu with id *menu* + +*menu-actions*: ++ + typeof: array ++ + The actions corresponding to the buttons of the menu. + # FORMAT REPLACEMENTS ## WHEN PLAYING/PAUSED diff --git a/man/waybar-network.5.scd b/man/waybar-network.5.scd index b5580c52..cc0b470b 100644 --- a/man/waybar-network.5.scd +++ b/man/waybar-network.5.scd @@ -129,6 +129,19 @@ Addressed by *network* typeof: string ++ This format is used when the displayed interface is disabled. +*menu*: ++ + typeof: string ++ + Action that popups the menu. + +*menu-file*: ++ + typeof: string ++ + Location of the menu descriptor file. There need to be an element of type + GtkMenu with id *menu* + +*menu-actions*: ++ + typeof: array ++ + The actions corresponding to the buttons of the menu. + # FORMAT REPLACEMENTS *{ifname}*: Name of the network interface. diff --git a/man/waybar-pulseaudio.5.scd b/man/waybar-pulseaudio.5.scd index 4bc75258..8d3761c4 100644 --- a/man/waybar-pulseaudio.5.scd +++ b/man/waybar-pulseaudio.5.scd @@ -113,6 +113,19 @@ Additionally, you can control the volume by scrolling *up* or *down* while the c typeof: array ++ Sinks in this list will not be shown as active sink by Waybar. Entries should be the sink's description field. +*menu*: ++ + typeof: string ++ + Action that popups the menu. + +*menu-file*: ++ + typeof: string ++ + Location of the menu descriptor file. There need to be an element of type + GtkMenu with id *menu* + +*menu-actions*: ++ + typeof: array ++ + The actions corresponding to the buttons of the menu. + # FORMAT REPLACEMENTS *{desc}*: Pulseaudio port's description, for bluetooth it'll be the device name. diff --git a/man/waybar-river-layout.5.scd b/man/waybar-river-layout.5.scd index 1c09d6f6..4fb23085 100644 --- a/man/waybar-river-layout.5.scd +++ b/man/waybar-river-layout.5.scd @@ -51,6 +51,19 @@ Addressed by *river/layout* typeof: string ++ Command to execute when you right-click on the module. +*menu*: ++ + typeof: string ++ + Action that popups the menu. + +*menu-file*: ++ + typeof: string ++ + Location of the menu descriptor file. There need to be an element of type + GtkMenu with id *menu* + +*menu-actions*: ++ + typeof: array ++ + The actions corresponding to the buttons of the menu. + # EXAMPLE ``` diff --git a/man/waybar-river-mode.5.scd b/man/waybar-river-mode.5.scd index 2d63b5e1..5769a9a2 100644 --- a/man/waybar-river-mode.5.scd +++ b/man/waybar-river-mode.5.scd @@ -65,6 +65,19 @@ Addressed by *river/mode* typeof: double ++ Threshold to be used when scrolling. +*menu*: ++ + typeof: string ++ + Action that popups the menu. + +*menu-file*: ++ + typeof: string ++ + Location of the menu descriptor file. There need to be an element of type + GtkMenu with id *menu* + +*menu-actions*: ++ + typeof: array ++ + The actions corresponding to the buttons of the menu. + # EXAMPLES ``` diff --git a/man/waybar-river-window.5.scd b/man/waybar-river-window.5.scd index dbd9f130..7e661f43 100644 --- a/man/waybar-river-window.5.scd +++ b/man/waybar-river-window.5.scd @@ -49,6 +49,19 @@ Addressed by *river/window* typeof: string ++ Command to execute when you right-click on the module. +*menu*: ++ + typeof: string ++ + Action that popups the menu. + +*menu-file*: ++ + typeof: string ++ + Location of the menu descriptor file. There need to be an element of type + GtkMenu with id *menu* + +*menu-actions*: ++ + typeof: array ++ + The actions corresponding to the buttons of the menu. + # EXAMPLES ``` diff --git a/man/waybar-sndio.5.scd b/man/waybar-sndio.5.scd index 197aaba0..f8d1615d 100644 --- a/man/waybar-sndio.5.scd +++ b/man/waybar-sndio.5.scd @@ -74,6 +74,19 @@ cursor is over the module, and clicking on the module toggles mute. typeof: double ++ Threshold to be used when scrolling. +*menu*: ++ + typeof: string ++ + Action that popups the menu. + +*menu-file*: ++ + typeof: string ++ + Location of the menu descriptor file. There need to be an element of type + GtkMenu with id *menu* + +*menu-actions*: ++ + typeof: array ++ + The actions corresponding to the buttons of the menu. + # FORMAT REPLACEMENTS *{volume}*: Volume in percentage. diff --git a/man/waybar-sway-language.5.scd b/man/waybar-sway-language.5.scd index 1c62fd95..a1fc5d08 100644 --- a/man/waybar-sway-language.5.scd +++ b/man/waybar-sway-language.5.scd @@ -32,6 +32,19 @@ Addressed by *sway/language* default: true ++ Option to disable tooltip on hover. +*menu*: ++ + typeof: string ++ + Action that popups the menu. + +*menu-file*: ++ + typeof: string ++ + Location of the menu descriptor file. There need to be an element of type + GtkMenu with id *menu* + +*menu-actions*: ++ + typeof: array ++ + The actions corresponding to the buttons of the menu. + # FORMAT REPLACEMENTS *{short}*: Short name of layout (e.g. "us"). Equals to {}. diff --git a/man/waybar-sway-mode.5.scd b/man/waybar-sway-mode.5.scd index 44c8b81a..1fcf3cf8 100644 --- a/man/waybar-sway-mode.5.scd +++ b/man/waybar-sway-mode.5.scd @@ -70,6 +70,19 @@ Addressed by *sway/mode* default: true ++ Option to disable tooltip on hover. +*menu*: ++ + typeof: string ++ + Action that popups the menu. + +*menu-file*: ++ + typeof: string ++ + Location of the menu descriptor file. There need to be an element of type + GtkMenu with id *menu* + +*menu-actions*: ++ + typeof: array ++ + The actions corresponding to the buttons of the menu. + # EXAMPLES ``` diff --git a/man/waybar-sway-scratchpad.5.scd b/man/waybar-sway-scratchpad.5.scd index 64c43db6..5ae104bc 100644 --- a/man/waybar-sway-scratchpad.5.scd +++ b/man/waybar-sway-scratchpad.5.scd @@ -36,6 +36,19 @@ Addressed by *sway/scratchpad* default: {app}: {title} ++ The format, how information in the tooltip should be displayed. +*menu*: ++ + typeof: string ++ + Action that popups the menu. + +*menu-file*: ++ + typeof: string ++ + Location of the menu descriptor file. There need to be an element of type + GtkMenu with id *menu* + +*menu-actions*: ++ + typeof: array ++ + The actions corresponding to the buttons of the menu. + # FORMAT REPLACEMENTS *{icon}*: Icon, as defined in *format-icons*. diff --git a/man/waybar-systemd-failed-units.5.scd b/man/waybar-systemd-failed-units.5.scd index ac92c533..ada3ab8b 100644 --- a/man/waybar-systemd-failed-units.5.scd +++ b/man/waybar-systemd-failed-units.5.scd @@ -36,6 +36,19 @@ Addressed by *systemd-failed-units* default: *true* ++ Option to hide this module when there is no failing units. +*menu*: ++ + typeof: string ++ + Action that popups the menu. + +*menu-file*: ++ + typeof: string ++ + Location of the menu descriptor file. There need to be an element of type + GtkMenu with id *menu* + +*menu-actions*: ++ + typeof: array ++ + The actions corresponding to the buttons of the menu. + # FORMAT REPLACEMENTS *{nr_failed_system}*: Number of failed units from systemwide (PID=1) systemd. diff --git a/man/waybar-temperature.5.scd b/man/waybar-temperature.5.scd index ff2168ea..8b84ef6c 100644 --- a/man/waybar-temperature.5.scd +++ b/man/waybar-temperature.5.scd @@ -110,6 +110,19 @@ Addressed by *temperature* default: true ++ Option to disable tooltip on hover. +*menu*: ++ + typeof: string ++ + Action that popups the menu. + +*menu-file*: ++ + typeof: string ++ + Location of the menu descriptor file. There need to be an element of type + GtkMenu with id *menu* + +*menu-actions*: ++ + typeof: array ++ + The actions corresponding to the buttons of the menu. + # FORMAT REPLACEMENTS *{temperatureC}*: Temperature in Celsius. diff --git a/man/waybar-upower.5.scd b/man/waybar-upower.5.scd index 5e2a8eb8..5ec0222d 100644 --- a/man/waybar-upower.5.scd +++ b/man/waybar-upower.5.scd @@ -62,6 +62,19 @@ compatible devices in the tooltip. default: true ++ Option to disable battery icon. +*menu*: ++ + typeof: string ++ + Action that popups the menu. + +*menu-file*: ++ + typeof: string ++ + Location of the menu descriptor file. There need to be an element of type + GtkMenu with id *menu* + +*menu-actions*: ++ + typeof: array ++ + The actions corresponding to the buttons of the menu. + # FORMAT REPLACEMENTS *{percentage}*: The battery capacity in percentage diff --git a/man/waybar-wireplumber.5.scd b/man/waybar-wireplumber.5.scd index b08fd90f..770ff0d5 100644 --- a/man/waybar-wireplumber.5.scd +++ b/man/waybar-wireplumber.5.scd @@ -87,6 +87,19 @@ The *wireplumber* module displays the current volume reported by WirePlumber. default: 100 ++ The maximum volume that can be set, in percentage. +*menu*: ++ + typeof: string ++ + Action that popups the menu. + +*menu-file*: ++ + typeof: string ++ + Location of the menu descriptor file. There need to be an element of type + GtkMenu with id *menu* + +*menu-actions*: ++ + typeof: array ++ + The actions corresponding to the buttons of the menu. + # FORMAT REPLACEMENTS *{volume}*: Volume in percentage. From 8220dbb513fe2cf9051bb685eb19784f8e3f4f2f Mon Sep 17 00:00:00 2001 From: Benjamin Voisin Date: Tue, 28 May 2024 20:42:47 +0200 Subject: [PATCH 8/9] =?UTF-8?q?=F0=9F=93=9D=20add=20a=20wayba-menu=20entry?= =?UTF-8?q?=20for=20documenting=20popup=20menus.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- man/waybar-menu.5.scd | 111 ++++++++++++++++++++++++++++++++++++++++++ meson.build | 1 + 2 files changed, 112 insertions(+) create mode 100644 man/waybar-menu.5.scd diff --git a/man/waybar-menu.5.scd b/man/waybar-menu.5.scd new file mode 100644 index 00000000..10484e41 --- /dev/null +++ b/man/waybar-menu.5.scd @@ -0,0 +1,111 @@ +waybar-menu(5) + +# NAME + +waybar - menu property + +# OVERVIEW + + +Some modules support a 'menu', which allows to have a popup menu whan a defined +click is done over the module. + +# PROPERTIES + +A module that implements a 'menu' needs 3 properties defined in its config : + +*menu*: ++ + typeof: string ++ + Action that popups the menu. The possibles actions are : + +[- *Option* +:- *Description* +|[ *on-click* +:< When you left-click on the module +|[ *on-click-release* +:< When you release left button on the module +|[ *on-double-click* +:< When you double left click on the module +|[ *on-triple-click* +:< When you triple left click on the module +|[ *on-click-middle* +:< When you middle click on the module using mousewheel +|[ *on-click-middle-release* +:< When you release mousewheel button on the module +|[ *on-double-click-middle* +:< When you double middle click on the module +|[ *on-triple-click-middle* +:< When you triple middle click on the module +|[ *on-click-right* +:< When you right click on the module using +|[ *on-click-right-release* +:< When you release right button on the module +|[ *on-double-click-right* +:< When you double right click on the module +|[ *on-triple-click-right* +:< When you triple middle click on the module +|[ *on-click-backward* +:< When you click on the module using mouse backward button +|[ *on-click-backward-release* +:< When you release mouse backward button on the module +|[ *on-double-click-backward* +:< When you double click on the module using mouse backward button +|[ *on-triple-click-backward* +:< When you triple click on the module using mouse backawrd button +|[ *on-click-forward* +:< When you click on the module using mouse forward button +|[ *on-click-forward-release* +:< When you release mouse forward button on the module +|[ *on-double-click-forward* +:< When you double click on the module using mouse forward button +|[ *on-triple-click-forward* +:< When you triple click on the module using mouse forward button + +*menu-file*: ++ + typeof: string ++ + Location of the menu descriptor file. There need to be an element of type + GtkMenu with id *menu*. + +*menu-actions*: ++ + typeof: array ++ + The actions corresponding to the buttons of the menu. The identifiers of + each actions needs to exists as an id in the 'menu-file' for it to be linked + properly. + +# EXAMPLE + +``` +"custom/power": { + "format" : "⏻ ", + "tooltip": false, + "menu": "on-click", + "menu-file": "~/.config/waybar/power_menu.xml", + "menu-actions": { + "shutdown": "shutdown", + "reboot": "reboot", + "suspend": "systemctl suspend", + "hibernate": "systemctl hibernate", + }, +}, +``` + +# STYLING MENUS + +- *menu* + Style for the menu + +- *menuitem* + Style for items in the menu + +# EXAMPLE: + +``` +menu { + border-radius: 15px; + background: #161320; + color: #B5E8E0; +} +menuitem { + border-radius: 15px; +} +``` diff --git a/meson.build b/meson.build index a57b17f8..56b772a5 100644 --- a/meson.build +++ b/meson.build @@ -192,6 +192,7 @@ man_files = files( 'man/waybar-idle-inhibitor.5.scd', 'man/waybar-image.5.scd', 'man/waybar-states.5.scd', + 'man/waybar-menu.5.scd', 'man/waybar-temperature.5.scd', ) From 885290d907ac49b4d6289b0e35daf01faedc698a Mon Sep 17 00:00:00 2001 From: Benjamin Voisin Date: Tue, 28 May 2024 21:02:07 +0200 Subject: [PATCH 9/9] =?UTF-8?q?=F0=9F=93=9D=20improve=20waybar-menu=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- man/waybar-menu.5.scd | 62 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 10 deletions(-) diff --git a/man/waybar-menu.5.scd b/man/waybar-menu.5.scd index 10484e41..19790ed4 100644 --- a/man/waybar-menu.5.scd +++ b/man/waybar-menu.5.scd @@ -72,23 +72,65 @@ A module that implements a 'menu' needs 3 properties defined in its config : each actions needs to exists as an id in the 'menu-file' for it to be linked properly. +# MENU-FILE + +The menu-file is an `.xml` file representing a GtkBuilder. Documentation for it +can be found here : https://docs.gtk.org/gtk4/class.Builder.html + +Here, it needs to have an element of type GtkMenu with id "menu". Eeach actions +in *menu-actions* are linked to elements in the *menu-file* file by the id of +the elements. + # EXAMPLE +Module config : ``` "custom/power": { - "format" : "⏻ ", - "tooltip": false, - "menu": "on-click", - "menu-file": "~/.config/waybar/power_menu.xml", - "menu-actions": { - "shutdown": "shutdown", - "reboot": "reboot", - "suspend": "systemctl suspend", - "hibernate": "systemctl hibernate", - }, + "format" : "⏻ ", + "tooltip": false, + "menu": "on-click", + "menu-file": "~/.config/waybar/power_menu.xml", + "menu-actions": { + "shutdown": "shutdown", + "reboot": "reboot", + "suspend": "systemctl suspend", + "hibernate": "systemctl hibernate", + }, }, ``` +~/.config/waybar/power_menu.xml : +``` + + + + + + Suspend + + + + + Hibernate + + + + + Shutdown + + + + + + + + Reboot + + + + +``` + # STYLING MENUS - *menu*