From 3c66f4baa71e92331a3739f006cfdcf3cccc52a2 Mon Sep 17 00:00:00 2001 From: Alexis Date: Sat, 11 Aug 2018 09:59:35 +0200 Subject: [PATCH] feat(config): can force width --- resources/config | 2 ++ src/bar.cpp | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/resources/config b/resources/config index 47681af..34ee435 100644 --- a/resources/config +++ b/resources/config @@ -1,6 +1,8 @@ { // "layer": "top", // Waybar at top layer // "position": "bottom", // Waybar at the bottom of your screen + // "height": 30, // Waybar height + // "width": 1280, // Waybar width // Choose the order of the modules "modules-left": ["workspaces", "custom/spotify"], "modules-right": ["pulseaudio", "network", "cpu", "memory", "battery", "clock"], diff --git a/src/bar.cpp b/src/bar.cpp index 60e437e..0d801d2 100644 --- a/src/bar.cpp +++ b/src/bar.cpp @@ -98,7 +98,8 @@ void waybar::Bar::_handleMode(void *data, struct wl_output *wl_output, uint32_t f, int32_t w, int32_t h, int32_t refresh) { auto o = reinterpret_cast(data); - o->setWidth(w); + // If the width is configured we force it + o->setWidth(o->_config["width"] ? o->_config["width"].asUInt() : w); } void waybar::Bar::_handleDone(void *data, struct wl_output *) @@ -119,8 +120,7 @@ void waybar::Bar::_layerSurfaceHandleConfigure( auto o = reinterpret_cast(data); o->window.show_all(); zwlr_layer_surface_v1_ack_configure(surface, serial); - if (o->_height != height) - { + if (o->_height != height) { height = o->_height; std::cout << fmt::format("New Height: {}", height) << std::endl; zwlr_layer_surface_v1_set_size(surface, width, height);