diff --git a/include/client.hpp b/include/client.hpp index 65a814fc..39b6ae3b 100644 --- a/include/client.hpp +++ b/include/client.hpp @@ -30,12 +30,12 @@ class Client { const std::string &style) const; void bindInterfaces(); const std::string getValidPath(const std::vector &paths) const; - void handleOutput(std::unique_ptr &output); - bool isValidOutput(const Json::Value &config, std::unique_ptr &output); + void handleOutput(struct waybar_output &output); + bool isValidOutput(const Json::Value &config, struct waybar_output &output); auto setupConfig(const std::string &config_file) -> void; auto setupCss(const std::string &css_file) -> void; - std::unique_ptr &getOutput(void *); - std::vector getOutputConfigs(std::unique_ptr &output); + struct waybar_output &getOutput(void *); + std::vector getOutputConfigs(struct waybar_output &output); static void handleGlobal(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version); @@ -44,10 +44,10 @@ class Client { void handleMonitorAdded(Glib::RefPtr monitor); void handleMonitorRemoved(Glib::RefPtr monitor); - Json::Value config_; - Glib::RefPtr style_context_; - Glib::RefPtr css_provider_; - std::vector> outputs_; + Json::Value config_; + Glib::RefPtr style_context_; + Glib::RefPtr css_provider_; + std::list outputs_; }; } // namespace waybar diff --git a/include/modules/mpd.hpp b/include/modules/mpd.hpp index d69618a9..d08b28b2 100644 --- a/include/modules/mpd.hpp +++ b/include/modules/mpd.hpp @@ -36,6 +36,7 @@ class MPD : public ALabel { bool stopped(); bool playing(); + bool paused(); const std::string module_name_; diff --git a/include/modules/pulseaudio.hpp b/include/modules/pulseaudio.hpp index d575f627..ba5a2aaf 100644 --- a/include/modules/pulseaudio.hpp +++ b/include/modules/pulseaudio.hpp @@ -34,6 +34,7 @@ class Pulseaudio : public ALabel { pa_cvolume pa_volume_; bool muted_; std::string port_name_; + std::string form_factor_; std::string desc_; std::string monitor_; // SOURCE diff --git a/man/waybar-backlight.5.scd b/man/waybar-backlight.5.scd index 2d971997..5f2bb82b 100644 --- a/man/waybar-backlight.5.scd +++ b/man/waybar-backlight.5.scd @@ -36,6 +36,10 @@ The *backlight* module displays the current backlight level. typeof: string ++ Command to execute when the module is clicked. +*on-click-middle*: ++ + typeof: string ++ + Command to execute when middle-clicked on the module using mousewheel. + *on-click-right* ++ typeof: string ++ Command to execute when the module is right clicked. diff --git a/man/waybar-battery.5.scd b/man/waybar-battery.5.scd index 94a99e4f..f96f85cb 100644 --- a/man/waybar-battery.5.scd +++ b/man/waybar-battery.5.scd @@ -37,32 +37,36 @@ The *battery* module displays the current capacity and state (eg. charging) of y default: {H} h {M} min ++ The format, how the time should be displayed. -*format-icons* - typeof: array/object +*format-icons*: ++ + typeof: array/object ++ Based on the current capacity, the corresponding icon gets selected. ++ The order is *low* to *high*. Or by the state if it is an object. -*max-length* ++ +*max-length*: ++ typeof: integer++ The maximum length in character the module should display. -*rotate* ++ +*rotate*: ++ typeof: integer++ Positive value to rotate the text label. -*on-click* ++ +*on-click*: ++ typeof: string ++ Command to execute when clicked on the module. +*on-click-middle*: ++ + typeof: string ++ + Command to execute when middle-clicked on the module using mousewheel. + *on-click-right* ++ typeof: string ++ Command to execute when you right clicked on the module. -*on-scroll-up* ++ +*on-scroll-up*: ++ typeof: string ++ Command to execute when scrolling up on the module. -*on-scroll-down* ++ +*on-scroll-down*: ++ typeof: string ++ Command to execute when scrolling down on the module. diff --git a/man/waybar-clock.5.scd b/man/waybar-clock.5.scd index d979a673..959ec94b 100644 --- a/man/waybar-clock.5.scd +++ b/man/waybar-clock.5.scd @@ -32,6 +32,10 @@ The *clock* module displays the current date and time. typeof: string ++ Command to execute when clicked on the module. +*on-click-middle*: ++ + typeof: string ++ + Command to execute when middle-clicked on the module using mousewheel. + *on-click-right*: ++ typeof: string ++ Command to execute when you right clicked on the module. diff --git a/man/waybar-cpu.5.scd b/man/waybar-cpu.5.scd index e4e52504..27dde96f 100644 --- a/man/waybar-cpu.5.scd +++ b/man/waybar-cpu.5.scd @@ -36,6 +36,10 @@ The *cpu* module displays the current cpu utilization. typeof: string ++ Command to execute when clicked on the module. +*on-click-middle*: ++ + typeof: string ++ + Command to execute when middle-clicked on the module using mousewheel. + *on-click-right*: ++ typeof: string ++ Command to execute when you right clicked on the module. diff --git a/man/waybar-custom.5.scd b/man/waybar-custom.5.scd index a427be38..0ae7f4cd 100644 --- a/man/waybar-custom.5.scd +++ b/man/waybar-custom.5.scd @@ -59,6 +59,10 @@ Addressed by *custom/* typeof: string ++ Command to execute when clicked on the module. +*on-click-middle*: ++ + typeof: string ++ + Command to execute when middle-clicked on the module using mousewheel. + *on-click-right*: ++ typeof: string ++ Command to execute when you right clicked on the module. diff --git a/man/waybar-disk.5.scd b/man/waybar-disk.5.scd index 2a69cf49..25d00b1c 100644 --- a/man/waybar-disk.5.scd +++ b/man/waybar-disk.5.scd @@ -39,6 +39,10 @@ Addressed by *disk* typeof: string ++ Command to execute when clicked on the module. +*on-click-middle*: ++ + typeof: string ++ + Command to execute when middle-clicked on the module using mousewheel. + *on-click-right*: ++ typeof: string ++ Command to execute when you right clicked on the module. diff --git a/man/waybar-idle-inhibitor.5.scd b/man/waybar-idle-inhibitor.5.scd index 74e21928..1fba291e 100644 --- a/man/waybar-idle-inhibitor.5.scd +++ b/man/waybar-idle-inhibitor.5.scd @@ -31,6 +31,10 @@ screensaving, also known as "presentation mode". typeof: string ++ Command to execute when clicked on the module. A click also toggles the state +*on-click-middle*: ++ + typeof: string ++ + Command to execute when middle-clicked on the module using mousewheel. + *on-click-right*: ++ typeof: string ++ Command to execute when you right clicked on the module. diff --git a/man/waybar-memory.5.scd b/man/waybar-memory.5.scd index a9dfb3ab..70718e14 100644 --- a/man/waybar-memory.5.scd +++ b/man/waybar-memory.5.scd @@ -38,6 +38,10 @@ Addressed by *memory* typeof: string ++ Command to execute when clicked on the module. +*on-click-middle*: ++ + typeof: string ++ + Command to execute when middle-clicked on the module using mousewheel. + *on-click-right*: ++ typeof: string ++ Command to execute when you right clicked on the module. diff --git a/man/waybar-mpd.5.scd b/man/waybar-mpd.5.scd index 155e7b30..fc3b1b36 100644 --- a/man/waybar-mpd.5.scd +++ b/man/waybar-mpd.5.scd @@ -13,110 +13,118 @@ The *mpd* module displays information about a running "Music Player Daemon" inst Addressed by *mpd* *server*: ++ - typeof: string ++ - The network address or Unix socket path of the MPD server. If empty, connect to the default host. + typeof: string ++ + The network address or Unix socket path of the MPD server. If empty, connect to the default host. *port*: ++ - typeof: integer ++ - The port MPD listens to. If empty, use the default port. + typeof: integer ++ + The port MPD listens to. If empty, use the default port. *interval*: ++ - typeof: integer++ - default: 5 ++ - The interval in which the connection to the MPD server is retried + typeof: integer++ + default: 5 ++ + The interval in which the connection to the MPD server is retried *timeout*: ++ - typeof: integer++ - default: 30 ++ - The timeout for the connection. Change this if your MPD server has a low `connection_timeout` setting + typeof: integer++ + default: 30 ++ + The timeout for the connection. Change this if your MPD server has a low `connection_timeout` setting *unknown-tag*: ++ - typeof: string ++ - default: "N/A" ++ - The text to display when a tag is not present in the current song, but used in `format` + typeof: string ++ + default: "N/A" ++ + The text to display when a tag is not present in the current song, but used in `format` *format*: ++ - typeof: string ++ - default: "{album} - {artist} - {title}" ++ - Information displayed when a song is playing or paused + typeof: string ++ + default: "{album} - {artist} - {title}" ++ + Information displayed when a song is playing. *format-stopped*: ++ - typeof: string ++ - default: "stopped" ++ - Information displayed when the player is stopped. + typeof: string ++ + default: "stopped" ++ + Information displayed when the player is stopped. + +*format-paused*: ++ + typeof: string ++ + This format is used when a song is paused. *format-disconnected*: ++ - typeof: string ++ - default: "disconnected" ++ - Information displayed when the MPD server can't be reached. + typeof: string ++ + default: "disconnected" ++ + Information displayed when the MPD server can't be reached. *tooltip*: ++ - typeof: bool ++ - default: true ++ - Option to disable tooltip on hover. + typeof: bool ++ + default: true ++ + Option to disable tooltip on hover. *tooltip-format*: ++ - typeof: string ++ - default: "MPD (connected)" ++ - Tooltip information displayed when connected to MPD. + typeof: string ++ + default: "MPD (connected)" ++ + Tooltip information displayed when connected to MPD. *tooltip-format-disconnected*: ++ - typeof: string ++ - default: "MPD (disconnected)" ++ - Tooltip information displayed when the MPD server can't be reached. + typeof: string ++ + default: "MPD (disconnected)" ++ + Tooltip information displayed when the MPD server can't be reached. *rotate*: ++ - typeof: integer ++ - Positive value to rotate the text label. + typeof: integer ++ + Positive value to rotate the text label. *max-length*: ++ - typeof: integer ++ - The maximum length in character the module should display. + typeof: integer ++ + The maximum length in character the module should display. *on-click*: ++ - typeof: string ++ - Command to execute when clicked on the module. + typeof: string ++ + Command to execute when clicked on the module. + +*on-click-middle*: ++ + typeof: string ++ + Command to execute when middle-clicked on the module using mousewheel. *on-click-right*: ++ - typeof: string ++ - Command to execute when you right clicked on the module. + typeof: string ++ + Command to execute when you right clicked on the module. *on-scroll-up*: ++ - typeof: string ++ - Command to execute when scrolling up on the module. + typeof: string ++ + Command to execute when scrolling up on the module. *on-scroll-down*: ++ - typeof: string ++ - Command to execute when scrolling down on the module. + typeof: string ++ + Command to execute when scrolling down on the module. *smooth-scrolling-threshold*: ++ - typeof: double ++ - Threshold to be used when scrolling. + typeof: double ++ + Threshold to be used when scrolling. *state-icons*: ++ - typeof: object ++ - default: {} ++ - Icon to show depending on the play/pause state of the player (*{ "playing": "...", "paused": "..." }*) + typeof: object ++ + default: {} ++ + Icon to show depending on the play/pause state of the player (*{ "playing": "...", "paused": "..." }*) *consume-icons*: ++ - typeof: object ++ - default: {} ++ - Icon to show depending on the "consume" option (*{ "on": "...", "off": "..." }*) + typeof: object ++ + default: {} ++ + Icon to show depending on the "consume" option (*{ "on": "...", "off": "..." }*) *random-icons*: ++ - typeof: object ++ - default: {} ++ - Icon to show depending on the "random" option (*{ "on": "...", "off": "..." }*) + typeof: object ++ + default: {} ++ + Icon to show depending on the "random" option (*{ "on": "...", "off": "..." }*) *repeat-icons*: ++ - typeof: object ++ - default: {} ++ - Icon to show depending on the "repeat" option (*{ "on": "...", "off": "..." }*) + typeof: object ++ + default: {} ++ + Icon to show depending on the "repeat" option (*{ "on": "...", "off": "..." }*) *single-icons*: ++ - typeof: object ++ - default: {} ++ - Icon to show depending on the "single" option (*{ "on": "...", "off": "..." }*) + typeof: object ++ + default: {} ++ + Icon to show depending on the "single" option (*{ "on": "...", "off": "..." }*) # FORMAT REPLACEMENTS diff --git a/man/waybar-network.5.scd b/man/waybar-network.5.scd index ed8451f4..a557aa32 100644 --- a/man/waybar-network.5.scd +++ b/man/waybar-network.5.scd @@ -21,6 +21,11 @@ Addressed by *network* default: 60 ++ The interval in which the network information gets polled (e.g. signal strength). +*family*: ++ + typeof: string ++ + default: *ipv4* ++ + The address family that is used for the format replacement {ipaddr} and to determine if a network connection is present. + *format*: ++ typeof: string ++ default: *{ifname}* ++ @@ -42,6 +47,11 @@ Addressed by *network* typeof: string ++ This format is used when the displayed interface is disconnected. +*format-icons*: ++ + typeof: array/object ++ + Based on the current signal strength, the corresponding icon gets selected. ++ + The order is *low* to *high*. Or by the state if it is an object. + *rotate*: ++ typeof: integer ++ Positive value to rotate the text label. @@ -54,6 +64,10 @@ Addressed by *network* typeof: string ++ Command to execute when clicked on the module. +*on-click-middle*: ++ + typeof: string ++ + Command to execute when middle-clicked on the module using mousewheel. + *on-click-right*: ++ typeof: string ++ Command to execute when you right clicked on the module. @@ -117,6 +131,8 @@ Addressed by *network* *{bandwidthDownOctets}*: Instant down speed in octets/seconds. +*{icon}*: Icon, as defined in *format-icons*. + # EXAMPLES ``` diff --git a/man/waybar-pulseaudio.5.scd b/man/waybar-pulseaudio.5.scd index 2b117782..7640c706 100644 --- a/man/waybar-pulseaudio.5.scd +++ b/man/waybar-pulseaudio.5.scd @@ -59,6 +59,10 @@ Additionally you can control the volume by scrolling *up* or *down* while the cu typeof: string ++ Command to execute when clicked on the module. +*on-click-middle*: ++ + typeof: string ++ + Command to execute when middle-clicked on the module using mousewheel. + *on-click-right*: ++ typeof: string ++ Command to execute when you right clicked on the module. diff --git a/man/waybar-sway-mode.5.scd b/man/waybar-sway-mode.5.scd index 64d9a3e8..85a25d13 100644 --- a/man/waybar-sway-mode.5.scd +++ b/man/waybar-sway-mode.5.scd @@ -29,6 +29,10 @@ Addressed by *sway/mode* typeof: string ++ Command to execute when clicked on the module. +*on-click-middle*: ++ + typeof: string ++ + Command to execute when middle-clicked on the module using mousewheel. + *on-click-right*: ++ typeof: string ++ Command to execute when you right clicked on the module. diff --git a/man/waybar-sway-window.5.scd b/man/waybar-sway-window.5.scd index 75a974c4..6a9d4e31 100644 --- a/man/waybar-sway-window.5.scd +++ b/man/waybar-sway-window.5.scd @@ -29,6 +29,10 @@ Addressed by *sway/window* typeof: string ++ Command to execute when clicked on the module. +*on-click-middle*: ++ + typeof: string ++ + Command to execute when middle-clicked on the module using mousewheel. + *on-click-right*: ++ typeof: string ++ Command to execute when you right clicked on the module. diff --git a/man/waybar-temperature.5.scd b/man/waybar-temperature.5.scd index 8177969e..437cd29d 100644 --- a/man/waybar-temperature.5.scd +++ b/man/waybar-temperature.5.scd @@ -13,67 +13,71 @@ The *temperature* module displays the current temperature from a thermal zone. Addressed by *temperature* *thermal-zone*: ++ - typeof: integer ++ - The thermal zone, as in */sys/class/thermal/*. + typeof: integer ++ + The thermal zone, as in */sys/class/thermal/*. *hwmon-path*: ++ - typeof: string ++ - The temperature path to use, e.g. */sys/class/hwmon/hwmon2/temp1_input* instead of one in */sys/class/thermal/*. + typeof: string ++ + The temperature path to use, e.g. */sys/class/hwmon/hwmon2/temp1_input* instead of one in */sys/class/thermal/*. *critical-threshold*: ++ - typeof: integer ++ - The threshold before it is considered critical (Celcius). + typeof: integer ++ + The threshold before it is considered critical (Celcius). *interval*: ++ - typeof: integer ++ - default: 10 ++ - The interval in which the information gets polled. + typeof: integer ++ + default: 10 ++ + The interval in which the information gets polled. *format-critical*: ++ - typeof: string ++ - The format to use when temperature is considered critical + typeof: string ++ + The format to use when temperature is considered critical *format*: ++ - typeof: string ++ - default: {temperatureC}°C ++ - The format (Celcius/Farenheit) in which the temperature should be displayed. + typeof: string ++ + default: {temperatureC}°C ++ + The format (Celcius/Farenheit) in which the temperature should be displayed. *format-icons*: ++ - typeof: array ++ - Based on the current temperature (Celcius) and *critical-threshold* if available, the corresponding icon gets selected. The order is *low* to *high*. + typeof: array ++ + Based on the current temperature (Celcius) and *critical-threshold* if available, the corresponding icon gets selected. The order is *low* to *high*. *rotate*: ++ - typeof: integer ++ - Positive value to rotate the text label. + typeof: integer ++ + Positive value to rotate the text label. *max-length*: ++ - typeof: integer ++ - The maximum length in characters the module should display. + typeof: integer ++ + The maximum length in characters the module should display. *on-click*: ++ - typeof: string ++ - Command to execute when you clicked on the module. + typeof: string ++ + Command to execute when you clicked on the module. + +*on-click-middle*: ++ + typeof: string ++ + Command to execute when middle-clicked on the module using mousewheel. *on-click-right*: ++ - typeof: string ++ - Command to execute when you right clicked on the module. + typeof: string ++ + Command to execute when you right clicked on the module. *on-scroll-up*: ++ - typeof: string ++ - Command to execute when scrolling up on the module. + typeof: string ++ + Command to execute when scrolling up on the module. *on-scroll-down*: ++ - typeof: string ++ - Command to execute when scrolling down on the module. + typeof: string ++ + Command to execute when scrolling down on the module. *smooth-scrolling-threshold*: ++ - typeof: double ++ - Threshold to be used when scrolling. + typeof: double ++ + Threshold to be used when scrolling. *tooltip*: ++ - typeof: bool ++ - default: true ++ - Option to disable tooltip on hover. + typeof: bool ++ + default: true ++ + Option to disable tooltip on hover. # FORMAT REPLACEMENTS diff --git a/man/waybar.5.scd b/man/waybar.5.scd index 3278c636..758d90a9 100644 --- a/man/waybar.5.scd +++ b/man/waybar.5.scd @@ -23,7 +23,8 @@ Also a minimal example configuration can be found on the at the bottom of this m *layer* ++ typeof: string ++ default: bottom ++ - Decide if the bar is displayed in front of the windows or behind them. + Decide if the bar is displayed in front (*top*) of the windows or behind (*bottom*) + them. *output* ++ typeof: string|array ++ @@ -66,6 +67,12 @@ Also a minimal example configuration can be found on the at the bottom of this m typeof: string ++ Optional name added as a CSS class, for styling multiple waybars. +*gtk-layer-shell* ++ + typeof: bool ++ + default: true ++ + Option to disable the use of gtk-layer-shell for popups. + Only functional if compiled with gtk-layer-shell support. + # MODULE FORMAT You can use PangoMarkupFormat (See https://developer.gnome.org/pango/stable/PangoMarkupFormat.html#PangoMarkupFormat). diff --git a/protocol/dbus-status-notifier-item.xml b/protocol/dbus-status-notifier-item.xml index e46eb3c6..c33cd846 100644 --- a/protocol/dbus-status-notifier-item.xml +++ b/protocol/dbus-status-notifier-item.xml @@ -31,7 +31,9 @@ + @@ -44,4 +46,4 @@ - \ No newline at end of file + diff --git a/src/client.cpp b/src/client.cpp index dd4cd50e..f7c70e06 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -49,7 +49,7 @@ void waybar::Client::handleGlobalRemove(void * data, struct wl_registry * /*re // Nothing here } -void waybar::Client::handleOutput(std::unique_ptr &output) { +void waybar::Client::handleOutput(struct waybar_output &output) { static const struct zxdg_output_v1_listener xdgOutputListener = { .logical_position = [](void *, struct zxdg_output_v1 *, int32_t, int32_t) {}, .logical_size = [](void *, struct zxdg_output_v1 *, int32_t, int32_t) {}, @@ -58,42 +58,39 @@ void waybar::Client::handleOutput(std::unique_ptr &output) .description = [](void *, struct zxdg_output_v1 *, const char *) {}, }; // owned by output->monitor; no need to destroy - auto wl_output = gdk_wayland_monitor_get_wl_output(output->monitor->gobj()); - output->xdg_output.reset(zxdg_output_manager_v1_get_xdg_output(xdg_output_manager, wl_output)); - zxdg_output_v1_add_listener(output->xdg_output.get(), &xdgOutputListener, output.get()); + auto wl_output = gdk_wayland_monitor_get_wl_output(output.monitor->gobj()); + output.xdg_output.reset(zxdg_output_manager_v1_get_xdg_output(xdg_output_manager, wl_output)); + zxdg_output_v1_add_listener(output.xdg_output.get(), &xdgOutputListener, &output); } -bool waybar::Client::isValidOutput(const Json::Value & config, - std::unique_ptr &output) { +bool waybar::Client::isValidOutput(const Json::Value &config, struct waybar_output &output) { bool found = true; if (config["output"].isArray()) { bool in_array = false; for (auto const &output_conf : config["output"]) { - if (output_conf.isString() && output_conf.asString() == output->name) { + if (output_conf.isString() && output_conf.asString() == output.name) { in_array = true; break; } } found = in_array; } - if (config["output"].isString() && config["output"].asString() != output->name) { + if (config["output"].isString() && config["output"].asString() != output.name) { found = false; } return found; } -std::unique_ptr &waybar::Client::getOutput(void *addr) { - auto it = std::find_if(outputs_.begin(), outputs_.end(), [&addr](const auto &output) { - return output.get() == addr; - }); +struct waybar::waybar_output &waybar::Client::getOutput(void *addr) { + auto it = std::find_if( + outputs_.begin(), outputs_.end(), [&addr](const auto &output) { return &output == addr; }); if (it == outputs_.end()) { throw std::runtime_error("Unable to find valid output"); } return *it; } -std::vector waybar::Client::getOutputConfigs( - std::unique_ptr &output) { +std::vector waybar::Client::getOutputConfigs(struct waybar_output &output) { std::vector configs; if (config_.isArray()) { for (auto const &config : config_) { @@ -112,18 +109,18 @@ void waybar::Client::handleOutputName(void * data, struct zxdg_output_v1 * auto client = waybar::Client::inst(); try { auto &output = client->getOutput(data); - output->name = name; + output.name = name; spdlog::debug("Output detected: {} ({} {})", name, - output->monitor->get_manufacturer(), - output->monitor->get_model()); + output.monitor->get_manufacturer(), + output.monitor->get_model()); auto configs = client->getOutputConfigs(output); if (configs.empty()) { - output->xdg_output.reset(); + output.xdg_output.reset(); } else { wl_display_roundtrip(client->wl_display); for (const auto &config : configs) { - client->bars.emplace_back(std::make_unique(output.get(), config)); + client->bars.emplace_back(std::make_unique(&output, config)); Glib::RefPtr screen = client->bars.back()->window.get_screen(); client->style_context_->add_provider_for_screen( screen, client->css_provider_, GTK_STYLE_PROVIDER_PRIORITY_USER); @@ -135,7 +132,8 @@ void waybar::Client::handleOutputName(void * data, struct zxdg_output_v1 * } void waybar::Client::handleMonitorAdded(Glib::RefPtr monitor) { - auto &output = outputs_.emplace_back(new struct waybar_output({monitor})); + auto &output = outputs_.emplace_back(); + output.monitor = monitor; handleOutput(output); } @@ -151,9 +149,7 @@ void waybar::Client::handleMonitorRemoved(Glib::RefPtr monitor) { ++it; } } - std::remove_if(outputs_.begin(), outputs_.end(), [&monitor](const auto &output) { - return output->monitor == monitor; - }); + outputs_.remove_if([&monitor](const auto &output) { return output.monitor == monitor; }); } std::tuple waybar::Client::getConfigs( diff --git a/src/modules/mpd.cpp b/src/modules/mpd.cpp index 7bad855b..13ab9f0d 100644 --- a/src/modules/mpd.cpp +++ b/src/modules/mpd.cpp @@ -140,7 +140,9 @@ void waybar::modules::MPD::setLabel() { if (playing()) { label_.get_style_context()->add_class("playing"); label_.get_style_context()->remove_class("paused"); - } else { + } else if (paused()) { + format = + config_["format-paused"].isString() ? config_["format-paused"].asString() : config_["format"].asString(); label_.get_style_context()->add_class("paused"); label_.get_style_context()->remove_class("playing"); } @@ -346,3 +348,5 @@ bool waybar::modules::MPD::stopped() { } bool waybar::modules::MPD::playing() { return connection_ != nullptr && state_ == MPD_STATE_PLAY; } + +bool waybar::modules::MPD::paused() { return connection_ != nullptr && state_ == MPD_STATE_PAUSE; } diff --git a/src/modules/network.cpp b/src/modules/network.cpp index a332d5a2..43f29f67 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include "util/format.hpp" @@ -439,7 +440,6 @@ out: } void waybar::modules::Network::getInterfaceAddress() { - unsigned int cidrRaw; struct ifaddrs *ifaddr, *ifa; cidr_ = 0; int success = getifaddrs(&ifaddr); @@ -451,18 +451,34 @@ void waybar::modules::Network::getInterfaceAddress() { if (ifa->ifa_addr != nullptr && ifa->ifa_addr->sa_family == family_ && ifa->ifa_name == ifname_) { char ipaddr[INET6_ADDRSTRLEN]; - ipaddr_ = inet_ntop(family_, - &reinterpret_cast(ifa->ifa_addr)->sin_addr, - ipaddr, - INET6_ADDRSTRLEN); char netmask[INET6_ADDRSTRLEN]; - auto net_addr = reinterpret_cast(ifa->ifa_netmask); - netmask_ = inet_ntop(family_, &net_addr->sin_addr, netmask, INET6_ADDRSTRLEN); - cidrRaw = net_addr->sin_addr.s_addr; unsigned int cidr = 0; - while (cidrRaw) { - cidr += cidrRaw & 1; - cidrRaw >>= 1; + if (family_ == AF_INET) { + ipaddr_ = inet_ntop(AF_INET, + &reinterpret_cast(ifa->ifa_addr)->sin_addr, + ipaddr, + INET_ADDRSTRLEN); + auto net_addr = reinterpret_cast(ifa->ifa_netmask); + netmask_ = inet_ntop(AF_INET, &net_addr->sin_addr, netmask, INET_ADDRSTRLEN); + unsigned int cidrRaw = net_addr->sin_addr.s_addr; + while (cidrRaw) { + cidr += cidrRaw & 1; + cidrRaw >>= 1; + } + } else { + ipaddr_ = inet_ntop(AF_INET6, + &reinterpret_cast(ifa->ifa_addr)->sin6_addr, + ipaddr, + INET6_ADDRSTRLEN); + auto net_addr = reinterpret_cast(ifa->ifa_netmask); + netmask_ = inet_ntop(AF_INET6, &net_addr->sin6_addr, netmask, INET6_ADDRSTRLEN); + for (size_t i = 0; i < sizeof(net_addr->sin6_addr.s6_addr); ++i) { + unsigned char cidrRaw = net_addr->sin6_addr.s6_addr[i]; + while (cidrRaw) { + cidr += cidrRaw & 1; + cidrRaw >>= 1; + } + } } cidr_ = cidr; break; diff --git a/src/modules/pulseaudio.cpp b/src/modules/pulseaudio.cpp index ef2bc273..eb05b8c7 100644 --- a/src/modules/pulseaudio.cpp +++ b/src/modules/pulseaudio.cpp @@ -158,6 +158,9 @@ void waybar::modules::Pulseaudio::sinkInfoCb(pa_context * /*context*/, const pa_ pa->desc_ = i->description; pa->monitor_ = i->monitor_source_name; pa->port_name_ = i->active_port != nullptr ? i->active_port->name : "Unknown"; + if (auto ff = pa_proplist_gets(i->proplist, PA_PROP_DEVICE_FORM_FACTOR)) { + pa->form_factor_ = ff; + } pa->dp.emit(); } } @@ -185,7 +188,7 @@ static const std::array ports = { }; const std::string waybar::modules::Pulseaudio::getPortIcon() const { - std::string nameLC = port_name_; + std::string nameLC = port_name_ + form_factor_; std::transform(nameLC.begin(), nameLC.end(), nameLC.begin(), ::tolower); for (auto const &port : ports) { if (nameLC.find(port) != std::string::npos) { diff --git a/src/modules/sni/item.cpp b/src/modules/sni/item.cpp index bcc66e22..b298e442 100644 --- a/src/modules/sni/item.cpp +++ b/src/modules/sni/item.cpp @@ -265,7 +265,11 @@ void Item::updateImage() { if (pixbuf->gobj() != nullptr) { // An icon specified by path and filename may be the wrong size for // the tray - pixbuf = pixbuf->scale_simple(icon_size, icon_size, Gdk::InterpType::INTERP_BILINEAR); + // Keep the aspect ratio and scale to make the height equal to icon_size + // If people have non square icons, assume they want it to grow in width not height + int width = icon_size * pixbuf->get_width() / pixbuf->get_height(); + + pixbuf = pixbuf->scale_simple(width, icon_size, Gdk::InterpType::INTERP_BILINEAR); image.set(pixbuf); } } else { diff --git a/subprojects/fmt.wrap b/subprojects/fmt.wrap index b60b22a4..eb79283c 100644 --- a/subprojects/fmt.wrap +++ b/subprojects/fmt.wrap @@ -5,6 +5,6 @@ source_url = https://github.com/fmtlib/fmt/archive/5.3.0.tar.gz source_filename = fmt-5.3.0.tar.gz source_hash = defa24a9af4c622a7134076602070b45721a43c51598c8456ec6f2c4dbb51c89 -patch_url = https://wrapdb.mesonbuild.com/v1/projects/fmt/5.3.0/1/get_zip +patch_url = https://github.com/mesonbuild/fmt/releases/download/5.3.0-1/fmt.zip patch_filename = fmt-5.3.0-1-wrap.zip patch_hash = 18f21a3b8833949c35d4ac88a7059577d5fa24b98786e4b1b2d3d81bb811440f \ No newline at end of file diff --git a/subprojects/spdlog.wrap b/subprojects/spdlog.wrap index 9dac4d8d..750036b9 100644 --- a/subprojects/spdlog.wrap +++ b/subprojects/spdlog.wrap @@ -5,6 +5,6 @@ source_url = https://github.com/gabime/spdlog/archive/v1.3.1.tar.gz source_filename = v1.3.1.tar.gz source_hash = 160845266e94db1d4922ef755637f6901266731c4cb3b30b45bf41efa0e6ab70 -patch_url = https://wrapdb.mesonbuild.com/v1/projects/spdlog/1.3.1/1/get_zip +patch_url = https://github.com/mesonbuild/spdlog/releases/download/1.3.1-1/spdlog.zip patch_filename = spdlog-1.3.1-1-wrap.zip patch_hash = 715a0229781019b853d409cc0bf891ee4b9d3a17bec0cf87f4ad30b28bbecc87