Merge pull request #1 from Alexays/master
Integrate changes from Alexays/Waybar
This commit is contained in:
		
						commit
						bd67c9e620
					
				|  | @ -30,12 +30,12 @@ class Client { | ||||||
|                                                               const std::string &style) const; |                                                               const std::string &style) const; | ||||||
|   void                                             bindInterfaces(); |   void                                             bindInterfaces(); | ||||||
|   const std::string getValidPath(const std::vector<std::string> &paths) const; |   const std::string getValidPath(const std::vector<std::string> &paths) const; | ||||||
|   void              handleOutput(std::unique_ptr<struct waybar_output> &output); |   void              handleOutput(struct waybar_output &output); | ||||||
|   bool isValidOutput(const Json::Value &config, std::unique_ptr<struct waybar_output> &output); |   bool isValidOutput(const Json::Value &config, struct waybar_output &output); | ||||||
|   auto setupConfig(const std::string &config_file) -> void; |   auto setupConfig(const std::string &config_file) -> void; | ||||||
|   auto setupCss(const std::string &css_file) -> void; |   auto setupCss(const std::string &css_file) -> void; | ||||||
|   std::unique_ptr<struct waybar_output> &getOutput(void *); |   struct waybar_output &getOutput(void *); | ||||||
|   std::vector<Json::Value> getOutputConfigs(std::unique_ptr<struct waybar_output> &output); |   std::vector<Json::Value> getOutputConfigs(struct waybar_output &output); | ||||||
| 
 | 
 | ||||||
|   static void handleGlobal(void *data, struct wl_registry *registry, uint32_t name, |   static void handleGlobal(void *data, struct wl_registry *registry, uint32_t name, | ||||||
|                            const char *interface, uint32_t version); |                            const char *interface, uint32_t version); | ||||||
|  | @ -47,7 +47,7 @@ class Client { | ||||||
|   Json::Value                     config_; |   Json::Value                     config_; | ||||||
|   Glib::RefPtr<Gtk::StyleContext> style_context_; |   Glib::RefPtr<Gtk::StyleContext> style_context_; | ||||||
|   Glib::RefPtr<Gtk::CssProvider>  css_provider_; |   Glib::RefPtr<Gtk::CssProvider>  css_provider_; | ||||||
|   std::vector<std::unique_ptr<struct waybar_output>> outputs_; |   std::list<struct waybar_output> outputs_; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| }  // namespace waybar
 | }  // namespace waybar
 | ||||||
|  |  | ||||||
|  | @ -36,6 +36,7 @@ class MPD : public ALabel { | ||||||
| 
 | 
 | ||||||
|   bool stopped(); |   bool stopped(); | ||||||
|   bool playing(); |   bool playing(); | ||||||
|  |   bool paused(); | ||||||
| 
 | 
 | ||||||
|   const std::string module_name_; |   const std::string module_name_; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -34,6 +34,7 @@ class Pulseaudio : public ALabel { | ||||||
|   pa_cvolume  pa_volume_; |   pa_cvolume  pa_volume_; | ||||||
|   bool        muted_; |   bool        muted_; | ||||||
|   std::string port_name_; |   std::string port_name_; | ||||||
|  |   std::string form_factor_; | ||||||
|   std::string desc_; |   std::string desc_; | ||||||
|   std::string monitor_; |   std::string monitor_; | ||||||
|   // SOURCE
 |   // SOURCE
 | ||||||
|  |  | ||||||
|  | @ -36,6 +36,10 @@ The *backlight* module displays the current backlight level. | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	Command to execute when the module is clicked. | 	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* ++ | *on-click-right* ++ | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	Command to execute when the module is right clicked. | 	Command to execute when the module is right clicked. | ||||||
|  |  | ||||||
|  | @ -37,32 +37,36 @@ The *battery* module displays the current capacity and state (eg. charging) of y | ||||||
| 	default: {H} h {M} min ++ | 	default: {H} h {M} min ++ | ||||||
| 	The format, how the time should be displayed. | 	The format, how the time should be displayed. | ||||||
| 
 | 
 | ||||||
| *format-icons* | *format-icons*: ++ | ||||||
| 	typeof: array/object | 	typeof: array/object ++ | ||||||
| 	Based on the current capacity, the corresponding icon gets selected. ++ | 	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. | 	The order is *low* to *high*. Or by the state if it is an object. | ||||||
| 
 | 
 | ||||||
| *max-length* ++ | *max-length*: ++ | ||||||
| 	typeof: integer++ | 	typeof: integer++ | ||||||
| 	The maximum length in character the module should display. | 	The maximum length in character the module should display. | ||||||
| 
 | 
 | ||||||
| *rotate* ++ | *rotate*: ++ | ||||||
| 	typeof: integer++ | 	typeof: integer++ | ||||||
| 	Positive value to rotate the text label. | 	Positive value to rotate the text label. | ||||||
| 
 | 
 | ||||||
| *on-click* ++ | *on-click*: ++ | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	Command to execute when clicked on the module. | 	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* ++ | *on-click-right* ++ | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	Command to execute when you right clicked on the module. | 	Command to execute when you right clicked on the module. | ||||||
| 
 | 
 | ||||||
| *on-scroll-up* ++ | *on-scroll-up*: ++ | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	Command to execute when scrolling up on the module. | 	Command to execute when scrolling up on the module. | ||||||
| 
 | 
 | ||||||
| *on-scroll-down* ++ | *on-scroll-down*: ++ | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	Command to execute when scrolling down on the module. | 	Command to execute when scrolling down on the module. | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -32,6 +32,10 @@ The *clock* module displays the current date and time. | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	Command to execute when clicked on the module. | 	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*: ++ | *on-click-right*: ++ | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	Command to execute when you right clicked on the module. | 	Command to execute when you right clicked on the module. | ||||||
|  |  | ||||||
|  | @ -36,6 +36,10 @@ The *cpu* module displays the current cpu utilization. | ||||||
| 	typeof: string  ++ | 	typeof: string  ++ | ||||||
| 	Command to execute when clicked on the module. | 	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*: ++ | *on-click-right*: ++ | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	Command to execute when you right clicked on the module. | 	Command to execute when you right clicked on the module. | ||||||
|  |  | ||||||
|  | @ -59,6 +59,10 @@ Addressed by *custom/<name>* | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	Command to execute when clicked on the module. | 	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*: ++ | *on-click-right*: ++ | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	Command to execute when you right clicked on the module. | 	Command to execute when you right clicked on the module. | ||||||
|  |  | ||||||
|  | @ -39,6 +39,10 @@ Addressed by *disk* | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	Command to execute when clicked on the module. | 	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*: ++ | *on-click-right*: ++ | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	Command to execute when you right clicked on the module. | 	Command to execute when you right clicked on the module. | ||||||
|  |  | ||||||
|  | @ -31,6 +31,10 @@ screensaving, also known as "presentation mode". | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	Command to execute when clicked on the module. A click also toggles the state | 	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*: ++ | *on-click-right*: ++ | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	Command to execute when you right clicked on the module. | 	Command to execute when you right clicked on the module. | ||||||
|  |  | ||||||
|  | @ -38,6 +38,10 @@ Addressed by *memory* | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	Command to execute when clicked on the module. | 	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*: ++ | *on-click-right*: ++ | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	Command to execute when you right clicked on the module. | 	Command to execute when you right clicked on the module. | ||||||
|  |  | ||||||
|  | @ -38,13 +38,17 @@ Addressed by *mpd* | ||||||
| *format*: ++ | *format*: ++ | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	default: "{album} - {artist} - {title}" ++ | 	default: "{album} - {artist} - {title}" ++ | ||||||
|     Information displayed when a song is playing or paused | 	Information displayed when a song is playing. | ||||||
| 
 | 
 | ||||||
| *format-stopped*: ++ | *format-stopped*: ++ | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	default: "stopped" ++ | 	default: "stopped" ++ | ||||||
| 	Information displayed when the player is stopped. | 	Information displayed when the player is stopped. | ||||||
| 
 | 
 | ||||||
|  | *format-paused*: ++ | ||||||
|  | 	typeof: string ++ | ||||||
|  | 	This format is used when a song is paused. | ||||||
|  | 
 | ||||||
| *format-disconnected*: ++ | *format-disconnected*: ++ | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	default: "disconnected" ++ | 	default: "disconnected" ++ | ||||||
|  | @ -77,6 +81,10 @@ Addressed by *mpd* | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	Command to execute when clicked on the module. | 	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*: ++ | *on-click-right*: ++ | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	Command to execute when you right clicked on the module. | 	Command to execute when you right clicked on the module. | ||||||
|  |  | ||||||
|  | @ -21,6 +21,11 @@ Addressed by *network* | ||||||
| 	default: 60 ++ | 	default: 60 ++ | ||||||
| 	The interval in which the network information gets polled (e.g. signal strength). | 	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*: ++ | *format*: ++ | ||||||
| 	typeof: string  ++ | 	typeof: string  ++ | ||||||
| 	default: *{ifname}* ++ | 	default: *{ifname}* ++ | ||||||
|  | @ -42,6 +47,11 @@ Addressed by *network* | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	This format is used when the displayed interface is disconnected. | 	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*: ++ | *rotate*: ++ | ||||||
| 	typeof: integer ++ | 	typeof: integer ++ | ||||||
| 	Positive value to rotate the text label. | 	Positive value to rotate the text label. | ||||||
|  | @ -54,6 +64,10 @@ Addressed by *network* | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	Command to execute when clicked on the module. | 	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*: ++ | *on-click-right*: ++ | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	Command to execute when you right clicked on the module. | 	Command to execute when you right clicked on the module. | ||||||
|  | @ -117,6 +131,8 @@ Addressed by *network* | ||||||
| 
 | 
 | ||||||
| *{bandwidthDownOctets}*: Instant down speed in octets/seconds. | *{bandwidthDownOctets}*: Instant down speed in octets/seconds. | ||||||
| 
 | 
 | ||||||
|  | *{icon}*: Icon, as defined in *format-icons*. | ||||||
|  | 
 | ||||||
| # EXAMPLES | # EXAMPLES | ||||||
| 
 | 
 | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
|  | @ -59,6 +59,10 @@ Additionally you can control the volume by scrolling *up* or *down* while the cu | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	Command to execute when clicked on the module. | 	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*: ++ | *on-click-right*: ++ | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	Command to execute when you right clicked on the module. | 	Command to execute when you right clicked on the module. | ||||||
|  |  | ||||||
|  | @ -29,6 +29,10 @@ Addressed by *sway/mode* | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	Command to execute when clicked on the module. | 	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*: ++ | *on-click-right*: ++ | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	Command to execute when you right clicked on the module. | 	Command to execute when you right clicked on the module. | ||||||
|  |  | ||||||
|  | @ -29,6 +29,10 @@ Addressed by *sway/window* | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	Command to execute when clicked on the module. | 	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*: ++ | *on-click-right*: ++ | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	Command to execute when you right clicked on the module. | 	Command to execute when you right clicked on the module. | ||||||
|  |  | ||||||
|  | @ -54,6 +54,10 @@ Addressed by *temperature* | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	Command to execute when you clicked on the module. | 	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*: ++ | *on-click-right*: ++ | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	Command to execute when you right clicked on the module. | 	Command to execute when you right clicked on the module. | ||||||
|  |  | ||||||
|  | @ -23,7 +23,8 @@ Also a minimal example configuration can be found on the at the bottom of this m | ||||||
| *layer* ++ | *layer* ++ | ||||||
| 	typeof: string ++ | 	typeof: string ++ | ||||||
| 	default: bottom ++ | 	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* ++ | *output* ++ | ||||||
| 	typeof: string|array ++ | 	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 ++ | 	typeof: string ++ | ||||||
| 	Optional name added as a CSS class, for styling multiple waybars. | 	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 | # MODULE FORMAT | ||||||
| 
 | 
 | ||||||
| You can use PangoMarkupFormat (See https://developer.gnome.org/pango/stable/PangoMarkupFormat.html#PangoMarkupFormat). | You can use PangoMarkupFormat (See https://developer.gnome.org/pango/stable/PangoMarkupFormat.html#PangoMarkupFormat). | ||||||
|  |  | ||||||
|  | @ -31,7 +31,9 @@ | ||||||
|     <property name='Id' type='s' access='read'/> |     <property name='Id' type='s' access='read'/> | ||||||
|     <property name='Title' type='s' access='read'/> |     <property name='Title' type='s' access='read'/> | ||||||
|     <property name='Status' type='s' access='read'/> |     <property name='Status' type='s' access='read'/> | ||||||
|  |     <!-- See discussion on pull #536 | ||||||
|     <property name='WindowId' type='u' access='read'/> |     <property name='WindowId' type='u' access='read'/> | ||||||
|  |     --> | ||||||
|     <property name='IconThemePath' type='s' access='read'/> |     <property name='IconThemePath' type='s' access='read'/> | ||||||
|     <property name='IconName' type='s' access='read'/> |     <property name='IconName' type='s' access='read'/> | ||||||
|     <property name='IconPixmap' type='a(iiay)' access='read'/> |     <property name='IconPixmap' type='a(iiay)' access='read'/> | ||||||
|  |  | ||||||
|  | @ -49,7 +49,7 @@ void waybar::Client::handleGlobalRemove(void *   data, struct wl_registry * /*re | ||||||
|   // Nothing here
 |   // Nothing here
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void waybar::Client::handleOutput(std::unique_ptr<struct waybar_output> &output) { | void waybar::Client::handleOutput(struct waybar_output &output) { | ||||||
|   static const struct zxdg_output_v1_listener xdgOutputListener = { |   static const struct zxdg_output_v1_listener xdgOutputListener = { | ||||||
|       .logical_position = [](void *, struct zxdg_output_v1 *, int32_t, int32_t) {}, |       .logical_position = [](void *, struct zxdg_output_v1 *, int32_t, int32_t) {}, | ||||||
|       .logical_size = [](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<struct waybar_output> &output) | ||||||
|       .description = [](void *, struct zxdg_output_v1 *, const char *) {}, |       .description = [](void *, struct zxdg_output_v1 *, const char *) {}, | ||||||
|   }; |   }; | ||||||
|   // owned by output->monitor; no need to destroy
 |   // owned by output->monitor; no need to destroy
 | ||||||
|   auto wl_output = gdk_wayland_monitor_get_wl_output(output->monitor->gobj()); |   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)); |   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()); |   zxdg_output_v1_add_listener(output.xdg_output.get(), &xdgOutputListener, &output); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool waybar::Client::isValidOutput(const Json::Value &                    config, | bool waybar::Client::isValidOutput(const Json::Value &config, struct waybar_output &output) { | ||||||
|                                    std::unique_ptr<struct waybar_output> &output) { |  | ||||||
|   bool found = true; |   bool found = true; | ||||||
|   if (config["output"].isArray()) { |   if (config["output"].isArray()) { | ||||||
|     bool in_array = false; |     bool in_array = false; | ||||||
|     for (auto const &output_conf : config["output"]) { |     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; |         in_array = true; | ||||||
|         break; |         break; | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|     found = in_array; |     found = in_array; | ||||||
|   } |   } | ||||||
|   if (config["output"].isString() && config["output"].asString() != output->name) { |   if (config["output"].isString() && config["output"].asString() != output.name) { | ||||||
|     found = false; |     found = false; | ||||||
|   } |   } | ||||||
|   return found; |   return found; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::unique_ptr<struct waybar::waybar_output> &waybar::Client::getOutput(void *addr) { | struct waybar::waybar_output &waybar::Client::getOutput(void *addr) { | ||||||
|   auto it = std::find_if(outputs_.begin(), outputs_.end(), [&addr](const auto &output) { |   auto it = std::find_if( | ||||||
|     return output.get() == addr; |       outputs_.begin(), outputs_.end(), [&addr](const auto &output) { return &output == addr; }); | ||||||
|   }); |  | ||||||
|   if (it == outputs_.end()) { |   if (it == outputs_.end()) { | ||||||
|     throw std::runtime_error("Unable to find valid output"); |     throw std::runtime_error("Unable to find valid output"); | ||||||
|   } |   } | ||||||
|   return *it; |   return *it; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::vector<Json::Value> waybar::Client::getOutputConfigs( | std::vector<Json::Value> waybar::Client::getOutputConfigs(struct waybar_output &output) { | ||||||
|     std::unique_ptr<struct waybar_output> &output) { |  | ||||||
|   std::vector<Json::Value> configs; |   std::vector<Json::Value> configs; | ||||||
|   if (config_.isArray()) { |   if (config_.isArray()) { | ||||||
|     for (auto const &config : config_) { |     for (auto const &config : config_) { | ||||||
|  | @ -112,18 +109,18 @@ void waybar::Client::handleOutputName(void *      data, struct zxdg_output_v1 * | ||||||
|   auto client = waybar::Client::inst(); |   auto client = waybar::Client::inst(); | ||||||
|   try { |   try { | ||||||
|     auto &output = client->getOutput(data); |     auto &output = client->getOutput(data); | ||||||
|     output->name = name; |     output.name = name; | ||||||
|     spdlog::debug("Output detected: {} ({} {})", |     spdlog::debug("Output detected: {} ({} {})", | ||||||
|                   name, |                   name, | ||||||
|                   output->monitor->get_manufacturer(), |                   output.monitor->get_manufacturer(), | ||||||
|                   output->monitor->get_model()); |                   output.monitor->get_model()); | ||||||
|     auto configs = client->getOutputConfigs(output); |     auto configs = client->getOutputConfigs(output); | ||||||
|     if (configs.empty()) { |     if (configs.empty()) { | ||||||
|       output->xdg_output.reset(); |       output.xdg_output.reset(); | ||||||
|     } else { |     } else { | ||||||
|       wl_display_roundtrip(client->wl_display); |       wl_display_roundtrip(client->wl_display); | ||||||
|       for (const auto &config : configs) { |       for (const auto &config : configs) { | ||||||
|         client->bars.emplace_back(std::make_unique<Bar>(output.get(), config)); |         client->bars.emplace_back(std::make_unique<Bar>(&output, config)); | ||||||
|         Glib::RefPtr<Gdk::Screen> screen = client->bars.back()->window.get_screen(); |         Glib::RefPtr<Gdk::Screen> screen = client->bars.back()->window.get_screen(); | ||||||
|         client->style_context_->add_provider_for_screen( |         client->style_context_->add_provider_for_screen( | ||||||
|             screen, client->css_provider_, GTK_STYLE_PROVIDER_PRIORITY_USER); |             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<Gdk::Monitor> monitor) { | void waybar::Client::handleMonitorAdded(Glib::RefPtr<Gdk::Monitor> monitor) { | ||||||
|   auto &output = outputs_.emplace_back(new struct waybar_output({monitor})); |   auto &output = outputs_.emplace_back(); | ||||||
|  |   output.monitor = monitor; | ||||||
|   handleOutput(output); |   handleOutput(output); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -151,9 +149,7 @@ void waybar::Client::handleMonitorRemoved(Glib::RefPtr<Gdk::Monitor> monitor) { | ||||||
|       ++it; |       ++it; | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|   std::remove_if(outputs_.begin(), outputs_.end(), [&monitor](const auto &output) { |   outputs_.remove_if([&monitor](const auto &output) { return output.monitor == monitor; }); | ||||||
|     return output->monitor == monitor; |  | ||||||
|   }); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::tuple<const std::string, const std::string> waybar::Client::getConfigs( | std::tuple<const std::string, const std::string> waybar::Client::getConfigs( | ||||||
|  |  | ||||||
|  | @ -140,7 +140,9 @@ void waybar::modules::MPD::setLabel() { | ||||||
|     if (playing()) { |     if (playing()) { | ||||||
|       label_.get_style_context()->add_class("playing"); |       label_.get_style_context()->add_class("playing"); | ||||||
|       label_.get_style_context()->remove_class("paused"); |       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()->add_class("paused"); | ||||||
|       label_.get_style_context()->remove_class("playing"); |       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::playing() { return connection_ != nullptr && state_ == MPD_STATE_PLAY; } | ||||||
|  | 
 | ||||||
|  | bool waybar::modules::MPD::paused() { return connection_ != nullptr && state_ == MPD_STATE_PAUSE; } | ||||||
|  |  | ||||||
|  | @ -2,6 +2,7 @@ | ||||||
| #include <spdlog/spdlog.h> | #include <spdlog/spdlog.h> | ||||||
| #include <sys/eventfd.h> | #include <sys/eventfd.h> | ||||||
| #include <fstream> | #include <fstream> | ||||||
|  | #include <cassert> | ||||||
| #include "util/format.hpp" | #include "util/format.hpp" | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -439,7 +440,6 @@ out: | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void waybar::modules::Network::getInterfaceAddress() { | void waybar::modules::Network::getInterfaceAddress() { | ||||||
|   unsigned int    cidrRaw; |  | ||||||
|   struct ifaddrs *ifaddr, *ifa; |   struct ifaddrs *ifaddr, *ifa; | ||||||
|   cidr_ = 0; |   cidr_ = 0; | ||||||
|   int success = getifaddrs(&ifaddr); |   int success = getifaddrs(&ifaddr); | ||||||
|  | @ -451,19 +451,35 @@ void waybar::modules::Network::getInterfaceAddress() { | ||||||
|     if (ifa->ifa_addr != nullptr && ifa->ifa_addr->sa_family == family_ && |     if (ifa->ifa_addr != nullptr && ifa->ifa_addr->sa_family == family_ && | ||||||
|         ifa->ifa_name == ifname_) { |         ifa->ifa_name == ifname_) { | ||||||
|       char ipaddr[INET6_ADDRSTRLEN]; |       char ipaddr[INET6_ADDRSTRLEN]; | ||||||
|       ipaddr_ = inet_ntop(family_, |       char netmask[INET6_ADDRSTRLEN]; | ||||||
|  |       unsigned int cidr = 0; | ||||||
|  |       if (family_ == AF_INET) { | ||||||
|  |         ipaddr_ = inet_ntop(AF_INET, | ||||||
|                             &reinterpret_cast<struct sockaddr_in *>(ifa->ifa_addr)->sin_addr, |                             &reinterpret_cast<struct sockaddr_in *>(ifa->ifa_addr)->sin_addr, | ||||||
|                             ipaddr, |                             ipaddr, | ||||||
|                           INET6_ADDRSTRLEN); |                             INET_ADDRSTRLEN); | ||||||
|       char netmask[INET6_ADDRSTRLEN]; |  | ||||||
|         auto net_addr = reinterpret_cast<struct sockaddr_in *>(ifa->ifa_netmask); |         auto net_addr = reinterpret_cast<struct sockaddr_in *>(ifa->ifa_netmask); | ||||||
|       netmask_ = inet_ntop(family_, &net_addr->sin_addr, netmask, INET6_ADDRSTRLEN); |         netmask_ = inet_ntop(AF_INET, &net_addr->sin_addr, netmask, INET_ADDRSTRLEN); | ||||||
|       cidrRaw = net_addr->sin_addr.s_addr; |         unsigned int cidrRaw = net_addr->sin_addr.s_addr; | ||||||
|       unsigned int cidr = 0; |  | ||||||
|         while (cidrRaw) { |         while (cidrRaw) { | ||||||
|           cidr += cidrRaw & 1; |           cidr += cidrRaw & 1; | ||||||
|           cidrRaw >>= 1; |           cidrRaw >>= 1; | ||||||
|         } |         } | ||||||
|  |       } else { | ||||||
|  |         ipaddr_ = inet_ntop(AF_INET6, | ||||||
|  |                             &reinterpret_cast<struct sockaddr_in6 *>(ifa->ifa_addr)->sin6_addr, | ||||||
|  |                             ipaddr, | ||||||
|  |                             INET6_ADDRSTRLEN); | ||||||
|  |         auto net_addr = reinterpret_cast<struct sockaddr_in6 *>(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; |       cidr_ = cidr; | ||||||
|       break; |       break; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -158,6 +158,9 @@ void waybar::modules::Pulseaudio::sinkInfoCb(pa_context * /*context*/, const pa_ | ||||||
|     pa->desc_ = i->description; |     pa->desc_ = i->description; | ||||||
|     pa->monitor_ = i->monitor_source_name; |     pa->monitor_ = i->monitor_source_name; | ||||||
|     pa->port_name_ = i->active_port != nullptr ? i->active_port->name : "Unknown"; |     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(); |     pa->dp.emit(); | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | @ -185,7 +188,7 @@ static const std::array<std::string, 9> ports = { | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| const std::string waybar::modules::Pulseaudio::getPortIcon() const { | 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); |   std::transform(nameLC.begin(), nameLC.end(), nameLC.begin(), ::tolower); | ||||||
|   for (auto const &port : ports) { |   for (auto const &port : ports) { | ||||||
|     if (nameLC.find(port) != std::string::npos) { |     if (nameLC.find(port) != std::string::npos) { | ||||||
|  |  | ||||||
|  | @ -265,7 +265,11 @@ void Item::updateImage() { | ||||||
|         if (pixbuf->gobj() != nullptr) { |         if (pixbuf->gobj() != nullptr) { | ||||||
|           // An icon specified by path and filename may be the wrong size for
 |           // An icon specified by path and filename may be the wrong size for
 | ||||||
|           // the tray
 |           // 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); |           image.set(pixbuf); | ||||||
|         } |         } | ||||||
|       } else { |       } else { | ||||||
|  |  | ||||||
|  | @ -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_filename = fmt-5.3.0.tar.gz | ||||||
| source_hash = defa24a9af4c622a7134076602070b45721a43c51598c8456ec6f2c4dbb51c89 | 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_filename = fmt-5.3.0-1-wrap.zip | ||||||
| patch_hash = 18f21a3b8833949c35d4ac88a7059577d5fa24b98786e4b1b2d3d81bb811440f | patch_hash = 18f21a3b8833949c35d4ac88a7059577d5fa24b98786e4b1b2d3d81bb811440f | ||||||
|  | @ -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_filename = v1.3.1.tar.gz | ||||||
| source_hash = 160845266e94db1d4922ef755637f6901266731c4cb3b30b45bf41efa0e6ab70 | 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_filename = spdlog-1.3.1-1-wrap.zip | ||||||
| patch_hash = 715a0229781019b853d409cc0bf891ee4b9d3a17bec0cf87f4ad30b28bbecc87 | patch_hash = 715a0229781019b853d409cc0bf891ee4b9d3a17bec0cf87f4ad30b28bbecc87 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue