diff --git a/.github/workflows/freebsd.yml b/.github/workflows/freebsd.yml
index 8af7a04a..d5064fe4 100644
--- a/.github/workflows/freebsd.yml
+++ b/.github/workflows/freebsd.yml
@@ -4,12 +4,16 @@ on: [ push, pull_request ]
jobs:
clang:
- runs-on: macos-latest # until https://github.com/actions/runner/issues/385
+ # Run actions in a FreeBSD vm on the macos-10.15 runner
+ # https://github.com/actions/runner/issues/385 - for FreeBSD runner support
+ # https://github.com/actions/virtual-environments/issues/4060 - for lack of VirtualBox on MacOS 11 runners
+ runs-on: macos-10.15
steps:
- uses: actions/checkout@v2
- name: Test in FreeBSD VM
- uses: vmactions/freebsd-vm@v0.1.4 # aka FreeBSD 12.2
+ uses: vmactions/freebsd-vm@v0.1.5 # aka FreeBSD 13.0
with:
+ mem: 2048
usesh: true
prepare: |
export CPPFLAGS=-isystem/usr/local/include LDFLAGS=-L/usr/local/lib # sndio
diff --git a/README.md b/README.md
index 98b99a2d..c5806e3b 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
> Highly customizable Wayland bar for Sway and Wlroots based compositors.
> Available in Arch [community](https://www.archlinux.org/packages/community/x86_64/waybar/) or
-[AUR](https://aur.archlinux.org/packages/waybar-git/), [openSUSE](https://build.opensuse.org/package/show/X11:Wayland/waybar), and [Alpine Linux](https://pkgs.alpinelinux.org/packages?name=waybar)
+[AUR](https://aur.archlinux.org/packages/waybar-git/), [Gentoo](https://packages.gentoo.org/packages/gui-apps/waybar), [openSUSE](https://build.opensuse.org/package/show/X11:Wayland/waybar), and [Alpine Linux](https://pkgs.alpinelinux.org/packages?name=waybar)
> *Waybar [examples](https://github.com/Alexays/Waybar/wiki/Examples)*
#### Current features
@@ -69,6 +69,7 @@ libdbusmenu-gtk3 [Tray module]
libmpdclient [MPD module]
libsndio [sndio module]
libevdev [KeyboardState module]
+xkbregistry
```
**Build dependencies**
@@ -101,7 +102,8 @@ sudo apt install \
libsigc++-2.0-dev \
libspdlog-dev \
libwayland-dev \
- scdoc
+ scdoc \
+ libxkbregistry-dev
```
diff --git a/include/bar.hpp b/include/bar.hpp
index 6f3dfcf9..01a9d034 100644
--- a/include/bar.hpp
+++ b/include/bar.hpp
@@ -8,6 +8,9 @@
#include
#include
+#include
+#include
+
#include "AModule.hpp"
#include "xdg-output-unstable-v1-client-protocol.h"
@@ -36,6 +39,19 @@ struct bar_margins {
int left = 0;
};
+struct bar_mode {
+ bar_layer layer;
+ bool exclusive;
+ bool passthrough;
+ bool visible;
+};
+
+#ifdef HAVE_SWAY
+namespace modules::sway {
+class BarIpcClient;
+}
+#endif // HAVE_SWAY
+
class BarSurface {
protected:
BarSurface() = default;
@@ -54,38 +70,56 @@ class BarSurface {
class Bar {
public:
+ using bar_mode_map = std::map;
+ static const bar_mode_map PRESET_MODES;
+ static const std::string_view MODE_DEFAULT;
+ static const std::string_view MODE_INVISIBLE;
+
Bar(struct waybar_output *w_output, const Json::Value &);
Bar(const Bar &) = delete;
- ~Bar() = default;
+ ~Bar();
+ void setMode(const std::string_view &);
void setVisible(bool visible);
void toggle();
void handleSignal(int);
struct waybar_output *output;
Json::Value config;
- struct wl_surface * surface;
- bool exclusive = true;
+ struct wl_surface *surface;
bool visible = true;
bool vertical = false;
Gtk::Window window;
+#ifdef HAVE_SWAY
+ std::string bar_id;
+#endif
+
private:
void onMap(GdkEventAny *);
auto setupWidgets() -> void;
- void getModules(const Factory &, const std::string &);
+ void getModules(const Factory &, const std::string &, Gtk::Box*);
void setupAltFormatKeyForModule(const std::string &module_name);
void setupAltFormatKeyForModuleList(const char *module_list_name);
+ void setMode(const bar_mode &);
+
+ /* Copy initial set of modes to allow customization */
+ bar_mode_map configured_modes = PRESET_MODES;
+ std::string last_mode_{MODE_DEFAULT};
std::unique_ptr surface_impl_;
- bar_layer layer_;
Gtk::Box left_;
Gtk::Box center_;
Gtk::Box right_;
Gtk::Box box_;
- std::vector> modules_left_;
- std::vector> modules_center_;
- std::vector> modules_right_;
+ std::vector> modules_left_;
+ std::vector> modules_center_;
+ std::vector> modules_right_;
+#ifdef HAVE_SWAY
+ using BarIpcClient = modules::sway::BarIpcClient;
+ std::unique_ptr _ipc_client;
+#endif
+ std::vector> modules_all_;
};
} // namespace waybar
diff --git a/include/client.hpp b/include/client.hpp
index bd80d0bd..7fc3dce7 100644
--- a/include/client.hpp
+++ b/include/client.hpp
@@ -29,6 +29,7 @@ class Client {
struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager = nullptr;
std::vector> bars;
Config config;
+ std::string bar_id;
private:
Client() = default;
diff --git a/include/factory.hpp b/include/factory.hpp
index 4b9f32aa..3855ce22 100644
--- a/include/factory.hpp
+++ b/include/factory.hpp
@@ -14,6 +14,7 @@
#endif
#ifdef HAVE_WLR
#include "modules/wlr/taskbar.hpp"
+#include "modules/wlr/workspace_manager.hpp"
#endif
#ifdef HAVE_RIVER
#include "modules/river/tags.hpp"
@@ -50,6 +51,9 @@
#ifdef HAVE_LIBSNDIO
#include "modules/sndio.hpp"
#endif
+#ifdef HAVE_GIO_UNIX
+#include "modules/inhibitor.hpp"
+#endif
#include "bar.hpp"
#include "modules/custom.hpp"
#include "modules/temperature.hpp"
diff --git a/include/group.hpp b/include/group.hpp
new file mode 100644
index 00000000..f282f9c5
--- /dev/null
+++ b/include/group.hpp
@@ -0,0 +1,21 @@
+#pragma once
+
+#include
+#include
+#include
+#include "AModule.hpp"
+#include "bar.hpp"
+#include "factory.hpp"
+
+namespace waybar {
+
+class Group : public AModule {
+ public:
+ Group(const std::string&, const Bar&, const Json::Value&);
+ ~Group() = default;
+ auto update() -> void;
+ operator Gtk::Widget &();
+ Gtk::Box box;
+};
+
+} // namespace waybar
diff --git a/include/modules/clock.hpp b/include/modules/clock.hpp
index 17752e4d..9f950192 100644
--- a/include/modules/clock.hpp
+++ b/include/modules/clock.hpp
@@ -17,6 +17,8 @@ struct waybar_time {
date::zoned_seconds ztime;
};
+const std::string kCalendarPlaceholder = "calendar";
+
class Clock : public ALabel {
public:
Clock(const std::string&, const Json::Value&);
@@ -26,18 +28,19 @@ class Clock : public ALabel {
private:
util::SleeperThread thread_;
std::locale locale_;
- const date::time_zone* time_zone_;
- bool fixed_time_zone_;
- int time_zone_idx_;
+ std::vector time_zones_;
+ int current_time_zone_idx_;
date::year_month_day cached_calendar_ymd_ = date::January/1/0;
std::string cached_calendar_text_;
+ bool is_calendar_in_tooltip_;
bool handleScroll(GdkEventScroll* e);
auto calendar_text(const waybar_time& wtime) -> std::string;
auto weekdays_header(const date::weekday& first_dow, std::ostream& os) -> void;
auto first_day_of_week() -> date::weekday;
- bool setTimeZone(Json::Value zone_name);
+ const date::time_zone* current_timezone();
+ bool is_timezone_fixed();
};
} // namespace waybar::modules
diff --git a/include/modules/inhibitor.hpp b/include/modules/inhibitor.hpp
new file mode 100644
index 00000000..aa2f97d4
--- /dev/null
+++ b/include/modules/inhibitor.hpp
@@ -0,0 +1,27 @@
+#pragma once
+
+#include
+
+#include
+
+#include "ALabel.hpp"
+#include "bar.hpp"
+
+namespace waybar::modules {
+
+class Inhibitor : public ALabel {
+ public:
+ Inhibitor(const std::string&, const waybar::Bar&, const Json::Value&);
+ ~Inhibitor() override;
+ auto update() -> void;
+ auto activated() -> bool;
+
+ private:
+ auto handleToggle(::GdkEventButton* const& e) -> bool;
+
+ const std::unique_ptr<::GDBusConnection, void(*)(::GDBusConnection*)> dbus_;
+ const std::string inhibitors_;
+ int handle_ = -1;
+};
+
+} // namespace waybar::modules
diff --git a/include/modules/network.hpp b/include/modules/network.hpp
index ad28520e..7b8281b1 100644
--- a/include/modules/network.hpp
+++ b/include/modules/network.hpp
@@ -43,6 +43,7 @@ class Network : public ALabel {
const std::string getNetworkState() const;
void clearIface();
bool wildcardMatch(const std::string& pattern, const std::string& text) const;
+ std::optional> readBandwidthUsage();
int ifid_;
sa_family_t family_;
@@ -72,7 +73,8 @@ class Network : public ALabel {
int cidr_;
int32_t signal_strength_dbm_;
uint8_t signal_strength_;
- uint32_t frequency_;
+ std::string signal_strength_app_;
+ float frequency_;
uint32_t route_priority;
util::SleeperThread thread_;
diff --git a/include/modules/river/tags.hpp b/include/modules/river/tags.hpp
index 9b75fbd3..c49ec60d 100644
--- a/include/modules/river/tags.hpp
+++ b/include/modules/river/tags.hpp
@@ -6,6 +6,7 @@
#include "AModule.hpp"
#include "bar.hpp"
#include "river-status-unstable-v1-client-protocol.h"
+#include "river-control-unstable-v1-client-protocol.h"
#include "xdg-output-unstable-v1-client-protocol.h"
namespace waybar::modules::river {
@@ -20,7 +21,12 @@ class Tags : public waybar::AModule {
void handle_view_tags(struct wl_array *tags);
void handle_urgent_tags(uint32_t tags);
+ void handle_primary_clicked(uint32_t tag);
+ bool handle_button_press(GdkEventButton *event_button, uint32_t tag);
+
struct zriver_status_manager_v1 *status_manager_;
+ struct zriver_control_v1 *control_;
+ struct wl_seat *seat_;
private:
const waybar::Bar & bar_;
diff --git a/include/modules/sway/bar.hpp b/include/modules/sway/bar.hpp
new file mode 100644
index 00000000..c4381a43
--- /dev/null
+++ b/include/modules/sway/bar.hpp
@@ -0,0 +1,49 @@
+#pragma once
+#include
+
+#include "modules/sway/ipc/client.hpp"
+#include "util/SafeSignal.hpp"
+#include "util/json.hpp"
+
+namespace waybar {
+
+class Bar;
+
+namespace modules::sway {
+
+/*
+ * Supported subset of i3/sway IPC barconfig object
+ */
+struct swaybar_config {
+ std::string id;
+ std::string mode;
+ std::string hidden_state;
+};
+
+/**
+ * swaybar IPC client
+ */
+class BarIpcClient {
+ public:
+ BarIpcClient(waybar::Bar& bar);
+
+ private:
+ void onInitialConfig(const struct Ipc::ipc_response& res);
+ void onIpcEvent(const struct Ipc::ipc_response&);
+ void onConfigUpdate(const swaybar_config& config);
+ void onVisibilityUpdate(bool visible_by_modifier);
+ void update();
+
+ Bar& bar_;
+ util::JsonParser parser_;
+ Ipc ipc_;
+
+ swaybar_config bar_config_;
+ bool visible_by_modifier_ = false;
+
+ SafeSignal signal_visible_;
+ SafeSignal signal_config_;
+};
+
+} // namespace modules::sway
+} // namespace waybar
diff --git a/include/modules/sway/language.hpp b/include/modules/sway/language.hpp
index 1faf52b3..92e2bbaa 100644
--- a/include/modules/sway/language.hpp
+++ b/include/modules/sway/language.hpp
@@ -32,6 +32,7 @@ class Language : public ALabel, public sigc::trackable {
std::string short_name;
std::string variant;
std::string short_description;
+ std::string country_flag() const;
};
class XKBContext {
@@ -54,7 +55,7 @@ class Language : public ALabel, public sigc::trackable {
const static std::string XKB_LAYOUT_NAMES_KEY;
const static std::string XKB_ACTIVE_LAYOUT_NAME_KEY;
-
+
Layout layout_;
std::string tooltip_format_ = "";
std::map layouts_map_;
diff --git a/include/modules/wlr/taskbar.hpp b/include/modules/wlr/taskbar.hpp
index 891ad55b..973d15db 100644
--- a/include/modules/wlr/taskbar.hpp
+++ b/include/modules/wlr/taskbar.hpp
@@ -3,11 +3,13 @@
#include "AModule.hpp"
#include "bar.hpp"
#include "client.hpp"
+#include "giomm/desktopappinfo.h"
#include "util/json.hpp"
#include
#include
#include
+#include