diff --git a/.envrc.sample b/.envrc.sample
new file mode 100644
index 00000000..3550a30f
--- /dev/null
+++ b/.envrc.sample
@@ -0,0 +1 @@
+use flake
diff --git a/.github/workflows/freebsd.yml b/.github/workflows/freebsd.yml
index a6da7ef7..550f9453 100644
--- a/.github/workflows/freebsd.yml
+++ b/.github/workflows/freebsd.yml
@@ -9,7 +9,7 @@ jobs:
# https://github.com/actions/virtual-environments/issues/4060 - for lack of VirtualBox on MacOS 11 runners
runs-on: macos-12
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
- name: Test in FreeBSD VM
uses: vmactions/freebsd-vm@v0
with:
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index e9f1656f..d11d2ccc 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -6,7 +6,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
- uses: DoozyX/clang-format-lint-action@v0.13
with:
source: '.'
diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml
index 4c77c3af..1c00a5ed 100644
--- a/.github/workflows/linux.yml
+++ b/.github/workflows/linux.yml
@@ -13,16 +13,20 @@ jobs:
- fedora
- opensuse
- gentoo
+ cpp_std: [c++17]
+ include:
+ - distro: fedora
+ cpp_std: c++20
runs-on: ubuntu-latest
container:
image: alexays/waybar:${{ matrix.distro }}
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
- name: configure
- run: meson -Dman-pages=enabled build
+ run: meson -Dman-pages=enabled -Dcpp_std=${{matrix.cpp_std}} build
- name: build
run: ninja -C build
- name: test
- run: meson test -C build --no-rebuild --print-errorlogs --suite waybar
+ run: make test
diff --git a/.gitignore b/.gitignore
index 56a2f73d..4d7babf3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,8 @@
*~
vgcore.*
/.vscode
+/.idea
+/.cache
*.swp
packagecache
/subprojects/**/
@@ -41,3 +43,4 @@ packagecache
*.exe
*.out
*.app
+/.direnv/
diff --git a/Dockerfiles/alpine b/Dockerfiles/alpine
index 03836aaa..d9a3dd58 100644
--- a/Dockerfiles/alpine
+++ b/Dockerfiles/alpine
@@ -2,4 +2,4 @@
FROM alpine:latest
-RUN apk add --no-cache git meson alpine-sdk libinput-dev wayland-dev wayland-protocols mesa-dev libxkbcommon-dev eudev-dev pixman-dev gtkmm3-dev jsoncpp-dev pugixml-dev libnl3-dev pulseaudio-dev libmpdclient-dev sndio-dev scdoc libxkbcommon tzdata
+RUN apk add --no-cache git meson alpine-sdk libinput-dev wayland-dev wayland-protocols mesa-dev libxkbcommon-dev eudev-dev pixman-dev gtkmm3-dev jsoncpp-dev pugixml-dev libnl3-dev pulseaudio-dev libmpdclient-dev sndio-dev scdoc libxkbcommon tzdata playerctl-dev
diff --git a/Dockerfiles/archlinux b/Dockerfiles/archlinux
index 40a1b2e3..cab4146b 100644
--- a/Dockerfiles/archlinux
+++ b/Dockerfiles/archlinux
@@ -3,4 +3,5 @@
FROM archlinux:base-devel
RUN pacman -Syu --noconfirm && \
- pacman -S git meson base-devel libinput wayland wayland-protocols pixman libxkbcommon mesa gtkmm3 jsoncpp pugixml scdoc libpulse libdbusmenu-gtk3 libmpdclient gobject-introspection --noconfirm libxkbcommon
+ pacman -S --noconfirm git meson base-devel libinput wayland wayland-protocols pixman libxkbcommon mesa gtkmm3 jsoncpp pugixml scdoc libpulse libdbusmenu-gtk3 libmpdclient gobject-introspection libxkbcommon playerctl && \
+ sed -Ei 's/#(en_(US|GB)\.UTF)/\1/' /etc/locale.gen && locale-gen
diff --git a/Dockerfiles/debian b/Dockerfiles/debian
index 026d8fdb..578588c7 100644
--- a/Dockerfiles/debian
+++ b/Dockerfiles/debian
@@ -3,5 +3,5 @@
FROM debian:sid
RUN apt-get update && \
- apt-get install -y build-essential meson ninja-build git pkg-config libinput10 libpugixml-dev libinput-dev wayland-protocols libwayland-client0 libwayland-cursor0 libwayland-dev libegl1-mesa-dev libgles2-mesa-dev libgbm-dev libxkbcommon-dev libudev-dev libpixman-1-dev libgtkmm-3.0-dev libjsoncpp-dev scdoc libdbusmenu-gtk3-dev libnl-3-dev libnl-genl-3-dev libpulse-dev libmpdclient-dev gobject-introspection libgirepository1.0-dev libxkbcommon-dev libxkbregistry-dev libxkbregistry0 && \
+ apt-get install -y build-essential meson ninja-build git pkg-config libinput10 libpugixml-dev libinput-dev wayland-protocols libwayland-client0 libwayland-cursor0 libwayland-dev libegl1-mesa-dev libgles2-mesa-dev libgbm-dev libxkbcommon-dev libudev-dev libpixman-1-dev libgtkmm-3.0-dev libjsoncpp-dev scdoc libdbusmenu-gtk3-dev libnl-3-dev libnl-genl-3-dev libpulse-dev libmpdclient-dev gobject-introspection libgirepository1.0-dev libxkbcommon-dev libxkbregistry-dev libxkbregistry0 libplayerctl-dev && \
apt-get clean
diff --git a/Dockerfiles/fedora b/Dockerfiles/fedora
index a61dcd3e..5892159c 100644
--- a/Dockerfiles/fedora
+++ b/Dockerfiles/fedora
@@ -2,11 +2,33 @@
FROM fedora:latest
-RUN dnf install -y @c-development git-core meson scdoc 'pkgconfig(date)' \
- 'pkgconfig(dbusmenu-gtk3-0.4)' 'pkgconfig(fmt)' 'pkgconfig(gdk-pixbuf-2.0)' \
- 'pkgconfig(gio-unix-2.0)' 'pkgconfig(gtk-layer-shell-0)' 'pkgconfig(gtkmm-3.0)' \
- 'pkgconfig(jsoncpp)' 'pkgconfig(libinput)' 'pkgconfig(libmpdclient)' \
- 'pkgconfig(libnl-3.0)' 'pkgconfig(libnl-genl-3.0)' 'pkgconfig(libpulse)' \
- 'pkgconfig(libudev)' 'pkgconfig(pugixml)' 'pkgconfig(sigc++-2.0)' 'pkgconfig(spdlog)' \
- 'pkgconfig(wayland-client)' 'pkgconfig(wayland-cursor)' 'pkgconfig(wayland-protocols)' 'pkgconfig(xkbregistry)' && \
+RUN dnf install -y @c-development \
+ git-core glibc-langpack-en meson scdoc \
+ 'pkgconfig(catch2)' \
+ 'pkgconfig(date)' \
+ 'pkgconfig(dbusmenu-gtk3-0.4)' \
+ 'pkgconfig(fmt)' \
+ 'pkgconfig(gdk-pixbuf-2.0)' \
+ 'pkgconfig(gio-unix-2.0)' \
+ 'pkgconfig(gtk-layer-shell-0)' \
+ 'pkgconfig(gtkmm-3.0)' \
+ 'pkgconfig(jack)' \
+ 'pkgconfig(jsoncpp)' \
+ 'pkgconfig(libevdev)' \
+ 'pkgconfig(libinput)' \
+ 'pkgconfig(libmpdclient)' \
+ 'pkgconfig(libnl-3.0)' \
+ 'pkgconfig(libnl-genl-3.0)' \
+ 'pkgconfig(libpulse)' \
+ 'pkgconfig(libudev)' \
+ 'pkgconfig(playerctl)' \
+ 'pkgconfig(pugixml)' \
+ 'pkgconfig(sigc++-2.0)' \
+ 'pkgconfig(spdlog)' \
+ 'pkgconfig(upower-glib)' \
+ 'pkgconfig(wayland-client)' \
+ 'pkgconfig(wayland-cursor)' \
+ 'pkgconfig(wayland-protocols)' \
+ 'pkgconfig(wireplumber-0.4)' \
+ 'pkgconfig(xkbregistry)' && \
dnf clean all -y
diff --git a/Dockerfiles/gentoo b/Dockerfiles/gentoo
index 536ef637..f2ec0dc9 100644
--- a/Dockerfiles/gentoo
+++ b/Dockerfiles/gentoo
@@ -6,6 +6,6 @@ RUN export FEATURES="-ipc-sandbox -network-sandbox -pid-sandbox -sandbox -usersa
emerge --sync && \
eselect news read --quiet new 1>/dev/null 2>&1 && \
emerge --verbose --update --deep --with-bdeps=y --backtrack=30 --newuse @world && \
- USE="wayland gtk3 gtk -doc X" emerge dev-vcs/git dev-libs/wayland dev-libs/wayland-protocols =dev-cpp/gtkmm-3.24.6 x11-libs/libxkbcommon \
+ USE="wayland gtk3 gtk -doc X pulseaudio minimal" emerge dev-vcs/git dev-libs/wayland dev-libs/wayland-protocols =dev-cpp/gtkmm-3.24.6 x11-libs/libxkbcommon \
x11-libs/gtk+:3 dev-libs/libdbusmenu dev-libs/libnl sys-power/upower media-libs/libpulse dev-libs/libevdev media-libs/libmpdclient \
- media-sound/sndio gui-libs/gtk-layer-shell app-text/scdoc
+ media-sound/sndio gui-libs/gtk-layer-shell app-text/scdoc media-sound/playerctl dev-libs/iniparser sci-libs/fftw
diff --git a/Dockerfiles/opensuse b/Dockerfiles/opensuse
index 49dea272..bdb42fbf 100644
--- a/Dockerfiles/opensuse
+++ b/Dockerfiles/opensuse
@@ -6,4 +6,4 @@ RUN zypper -n up && \
zypper addrepo https://download.opensuse.org/repositories/X11:Wayland/openSUSE_Tumbleweed/X11:Wayland.repo | echo 'a' && \
zypper -n refresh && \
zypper -n install -t pattern devel_C_C++ && \
- zypper -n install git meson clang libinput10 libinput-devel pugixml-devel libwayland-client0 libwayland-cursor0 wayland-protocols-devel wayland-devel Mesa-libEGL-devel Mesa-libGLESv2-devel libgbm-devel libxkbcommon-devel libudev-devel libpixman-1-0-devel gtkmm3-devel jsoncpp-devel libxkbregistry-devel scdoc
+ zypper -n install git meson clang libinput10 libinput-devel pugixml-devel libwayland-client0 libwayland-cursor0 wayland-protocols-devel wayland-devel Mesa-libEGL-devel Mesa-libGLESv2-devel libgbm-devel libxkbcommon-devel libudev-devel libpixman-1-0-devel gtkmm3-devel jsoncpp-devel libxkbregistry-devel scdoc playerctl-devel
diff --git a/Makefile b/Makefile
index 94f8ee6e..b1dbfc6e 100644
--- a/Makefile
+++ b/Makefile
@@ -19,5 +19,9 @@ run: build
debug-run: build-debug
./build/waybar --log-level debug
+test:
+ meson test -C build --no-rebuild --verbose --suite waybar
+.PHONY: test
+
clean:
rm -rf build
diff --git a/README.md b/README.md
index addee57a..718ceb44 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# Waybar [](LICENSE) [](https://paypal.me/ARouillard)

> Highly customizable Wayland bar for Sway and Wlroots based compositors.
-> Available in Arch [community](https://www.archlinux.org/packages/community/x86_64/waybar/) or
+> Available in Arch [community](https://www.archlinux.org/packages/extra/x86_64/waybar/) or
[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)*
@@ -9,6 +9,7 @@
- Sway (Workspaces, Binding mode, Focused window name)
- River (Mapping mode, Tags, Focused window name)
- Hyprland (Focused window name)
+- DWL (Tags) [requires dwl ipc patch](https://github.com/djpohly/dwl/wiki/ipc)
- Tray [#21](https://github.com/Alexays/Waybar/issues/21)
- Local time
- Battery
@@ -16,12 +17,14 @@
- Network
- Bluetooth
- Pulseaudio
+- Wireplumber
- Disk
- Memory
- Cpu load average
- Temperature
- MPD
- Custom scripts
+- Custom image
- Multiple output configuration
- And many more customizations
diff --git a/default.nix b/default.nix
new file mode 100644
index 00000000..2cccff28
--- /dev/null
+++ b/default.nix
@@ -0,0 +1,10 @@
+(import
+ (
+ let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
+ fetchTarball {
+ url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
+ sha256 = lock.nodes.flake-compat.locked.narHash;
+ }
+ )
+ { src = ./.; }
+).defaultNix
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 00000000..b10c9bf7
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,111 @@
+{
+ "nodes": {
+ "devshell": {
+ "inputs": {
+ "flake-utils": "flake-utils",
+ "nixpkgs": "nixpkgs"
+ },
+ "locked": {
+ "lastModified": 1676293499,
+ "narHash": "sha256-uIOTlTxvrXxpKeTvwBI1JGDGtCxMXE3BI0LFwoQMhiQ=",
+ "owner": "numtide",
+ "repo": "devshell",
+ "rev": "71e3022e3ab20bbf1342640547ef5bc14fb43bf4",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "devshell",
+ "type": "github"
+ }
+ },
+ "flake-compat": {
+ "flake": false,
+ "locked": {
+ "lastModified": 1673956053,
+ "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
+ "type": "github"
+ },
+ "original": {
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "type": "github"
+ }
+ },
+ "flake-utils": {
+ "locked": {
+ "lastModified": 1642700792,
+ "narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "846b2ae0fc4cc943637d3d1def4454213e203cba",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
+ "flake-utils_2": {
+ "locked": {
+ "lastModified": 1676283394,
+ "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1643381941,
+ "narHash": "sha256-pHTwvnN4tTsEKkWlXQ8JMY423epos8wUOhthpwJjtpc=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "5efc8ca954272c4376ac929f4c5ffefcc20551d5",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixpkgs-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "nixpkgs_2": {
+ "locked": {
+ "lastModified": 1676300157,
+ "narHash": "sha256-1HjRzfp6LOLfcj/HJHdVKWAkX9QRAouoh6AjzJiIerU=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "545c7a31e5dedea4a6d372712a18e00ce097d462",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixos-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "devshell": "devshell",
+ "flake-compat": "flake-compat",
+ "flake-utils": "flake-utils_2",
+ "nixpkgs": "nixpkgs_2"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 00000000..97f4ed57
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,93 @@
+{
+ description = "Highly customizable Wayland bar for Sway and Wlroots based compositors.";
+
+ inputs = {
+ nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
+ devshell.url = "github:numtide/devshell";
+ flake-utils.url = "github:numtide/flake-utils";
+ flake-compat = {
+ url = "github:edolstra/flake-compat";
+ flake = false;
+ };
+ };
+
+ outputs = { self, flake-utils, devshell, nixpkgs, flake-compat }:
+ let
+ inherit (nixpkgs) lib;
+ genSystems = lib.genAttrs [
+ "x86_64-linux"
+ ];
+
+ pkgsFor = genSystems (system:
+ import nixpkgs {
+ inherit system;
+ });
+
+ mkDate = longDate: (lib.concatStringsSep "-" [
+ (builtins.substring 0 4 longDate)
+ (builtins.substring 4 2 longDate)
+ (builtins.substring 6 2 longDate)
+ ]);
+ in
+ {
+ overlays.default = _: prev: {
+ waybar = prev.callPackage ./nix/default.nix {
+ version = prev.waybar.version + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty");
+ };
+ };
+ packages = genSystems
+ (system:
+ (self.overlays.default null pkgsFor.${system})
+ // {
+ default = self.packages.${system}.waybar;
+ });
+ } //
+ flake-utils.lib.eachDefaultSystem (system: {
+ devShell =
+ let pkgs = import nixpkgs {
+ inherit system;
+
+ overlays = [ devshell.overlay ];
+ };
+ in
+ pkgs.devshell.mkShell {
+ imports = [ "${pkgs.devshell.extraModulesDir}/language/c.nix" ];
+ commands = [
+ {
+ package = pkgs.devshell.cli;
+ help = "Per project developer environments";
+ }
+ ];
+ devshell.packages = with pkgs; [
+ clang-tools
+ gdb
+ # from nativeBuildInputs
+ gnumake
+ meson
+ ninja
+ pkg-config
+ scdoc
+ ] ++ (map lib.getDev [
+ # from buildInputs
+ wayland wlroots gtkmm3 libsigcxx jsoncpp spdlog gtk-layer-shell howard-hinnant-date libxkbcommon
+ # optional dependencies
+ gobject-introspection glib playerctl python3.pkgs.pygobject3
+ libevdev libinput libjack2 libmpdclient playerctl libnl
+ libpulseaudio sndio sway libdbusmenu-gtk3 udev upower wireplumber
+
+ # from propagated build inputs?
+ at-spi2-atk atkmm cairo cairomm catch2 fmt_8 fontconfig
+ gdk-pixbuf glibmm gtk3 harfbuzz pango pangomm wayland-protocols
+ ]);
+ env = with pkgs; [
+ { name = "CPLUS_INCLUDE_PATH"; prefix = "$DEVSHELL_DIR/include"; }
+ { name = "PKG_CONFIG_PATH"; prefix = "$DEVSHELL_DIR/lib/pkgconfig"; }
+ { name = "PKG_CONFIG_PATH"; prefix = "$DEVSHELL_DIR/share/pkgconfig"; }
+ { name = "PATH"; prefix = "${wayland.bin}/bin"; }
+ { name = "LIBRARY_PATH"; prefix = "${lib.getLib sndio}/lib"; }
+ { name = "LIBRARY_PATH"; prefix = "${lib.getLib zlib}/lib"; }
+ { name = "LIBRARY_PATH"; prefix = "${lib.getLib howard-hinnant-date}/lib"; }
+ ];
+ };
+ });
+}
diff --git a/include/AButton.hpp b/include/AButton.hpp
deleted file mode 100644
index ce29a09f..00000000
--- a/include/AButton.hpp
+++ /dev/null
@@ -1,35 +0,0 @@
-#pragma once
-
-#include
-#include
-#include
-#include
-#include
-
-#include "AModule.hpp"
-
-namespace waybar {
-
-class AButton : public AModule {
- public:
- AButton(const Json::Value &, const std::string &, const std::string &, const std::string &format,
- uint16_t interval = 0, bool ellipsize = false, bool enable_click = false,
- bool enable_scroll = false);
- virtual ~AButton() = default;
- virtual auto update() -> void;
- virtual std::string getIcon(uint16_t, const std::string &alt = "", uint16_t max = 0);
- virtual std::string getIcon(uint16_t, const std::vector &alts, uint16_t max = 0);
-
- protected:
- Gtk::Button button_ = Gtk::Button(name_);
- Gtk::Label *label_ = (Gtk::Label *)button_.get_child();
- std::string format_;
- const std::chrono::seconds interval_;
- bool alt_ = false;
- std::string default_format_;
-
- virtual bool handleToggle(GdkEventButton *const &e);
- virtual std::string getState(uint8_t value, bool lesser = false);
-};
-
-} // namespace waybar
diff --git a/include/AIconLabel.hpp b/include/AIconLabel.hpp
index aeeba6cb..054d031a 100644
--- a/include/AIconLabel.hpp
+++ b/include/AIconLabel.hpp
@@ -13,7 +13,7 @@ class AIconLabel : public ALabel {
const std::string &format, uint16_t interval = 0, bool ellipsize = false,
bool enable_click = false, bool enable_scroll = false);
virtual ~AIconLabel() = default;
- virtual auto update() -> void;
+ auto update() -> void override;
protected:
Gtk::Image image_;
diff --git a/include/ALabel.hpp b/include/ALabel.hpp
index 14f82242..888c65a8 100644
--- a/include/ALabel.hpp
+++ b/include/ALabel.hpp
@@ -14,7 +14,7 @@ class ALabel : public AModule {
uint16_t interval = 0, bool ellipsize = false, bool enable_click = false,
bool enable_scroll = false);
virtual ~ALabel() = default;
- virtual auto update() -> void;
+ auto update() -> void override;
virtual std::string getIcon(uint16_t, const std::string &alt = "", uint16_t max = 0);
virtual std::string getIcon(uint16_t, const std::vector &alts, uint16_t max = 0);
@@ -25,7 +25,7 @@ class ALabel : public AModule {
bool alt_ = false;
std::string default_format_;
- virtual bool handleToggle(GdkEventButton *const &e);
+ bool handleToggle(GdkEventButton *const &e) override;
virtual std::string getState(uint8_t value, bool lesser = false);
};
diff --git a/include/AModule.hpp b/include/AModule.hpp
index d3009af1..03bf25e1 100644
--- a/include/AModule.hpp
+++ b/include/AModule.hpp
@@ -11,15 +11,20 @@ namespace waybar {
class AModule : public IModule {
public:
- AModule(const Json::Value &, const std::string &, const std::string &, bool enable_click = false,
- bool enable_scroll = false);
virtual ~AModule();
- virtual auto update() -> void;
- virtual operator Gtk::Widget &();
+ auto update() -> void override;
+ virtual auto refresh(int) -> void{};
+ operator Gtk::Widget &() override;
+ auto doAction(const std::string &name) -> void override;
Glib::Dispatcher dp;
protected:
+ // Don't need to make an object directly
+ // Derived classes are able to use it
+ AModule(const Json::Value &, const std::string &, const std::string &, bool enable_click = false,
+ bool enable_scroll = false);
+
enum SCROLL_DIR { NONE, UP, DOWN, LEFT, RIGHT };
SCROLL_DIR getScrollDir(GdkEventScroll *e);
@@ -36,6 +41,7 @@ class AModule : public IModule {
private:
gdouble distance_scrolled_y_;
gdouble distance_scrolled_x_;
+ std::map eventActionMap_;
static const inline std::map, std::string> eventMap_{
{std::make_pair(1, GdkEventType::GDK_BUTTON_PRESS), "on-click"},
{std::make_pair(1, GdkEventType::GDK_2BUTTON_PRESS), "on-double-click"},
diff --git a/include/IModule.hpp b/include/IModule.hpp
index 961a4612..b76c33e3 100644
--- a/include/IModule.hpp
+++ b/include/IModule.hpp
@@ -9,6 +9,7 @@ class IModule {
virtual ~IModule() = default;
virtual auto update() -> void = 0;
virtual operator Gtk::Widget&() = 0;
+ virtual auto doAction(const std::string& name) -> void = 0;
};
} // namespace waybar
diff --git a/include/factory.hpp b/include/factory.hpp
index ca707a3c..90d0ac1d 100644
--- a/include/factory.hpp
+++ b/include/factory.hpp
@@ -1,7 +1,7 @@
#pragma once
#include
-#ifdef HAVE_LIBDATE
+#if defined(HAVE_CHRONO_TIMEZONES) || defined(HAVE_LIBDATE)
#include "modules/clock.hpp"
#else
#include "modules/simpleclock.hpp"
@@ -18,14 +18,20 @@
#include "modules/wlr/workspace_manager.hpp"
#endif
#ifdef HAVE_RIVER
+#include "modules/river/layout.hpp"
#include "modules/river/mode.hpp"
#include "modules/river/tags.hpp"
#include "modules/river/window.hpp"
#endif
+#ifdef HAVE_DWL
+#include "modules/dwl/tags.hpp"
+#endif
#ifdef HAVE_HYPRLAND
#include "modules/hyprland/backend.hpp"
#include "modules/hyprland/language.hpp"
+#include "modules/hyprland/submap.hpp"
#include "modules/hyprland/window.hpp"
+#include "modules/hyprland/workspaces.hpp"
#endif
#if defined(__FreeBSD__) || (defined(__linux__) && !defined(NO_FILESYSTEM))
#include "modules/battery.hpp"
@@ -41,6 +47,9 @@
#ifdef HAVE_DBUSMENU
#include "modules/sni/tray.hpp"
#endif
+#ifdef HAVE_MPRIS
+#include "modules/mpris/mpris.hpp"
+#endif
#ifdef HAVE_LIBNL
#include "modules/network.hpp"
#endif
@@ -72,8 +81,15 @@
#ifdef HAVE_LIBJACK
#include "modules/jack.hpp"
#endif
+#ifdef HAVE_LIBWIREPLUMBER
+#include "modules/wireplumber.hpp"
+#endif
+#ifdef HAVE_LIBCAVA
+#include "modules/cava.hpp"
+#endif
#include "bar.hpp"
#include "modules/custom.hpp"
+#include "modules/image.hpp"
#include "modules/temperature.hpp"
#include "modules/user.hpp"
diff --git a/include/group.hpp b/include/group.hpp
index 5e828677..60e31c96 100644
--- a/include/group.hpp
+++ b/include/group.hpp
@@ -12,10 +12,10 @@ namespace waybar {
class Group : public AModule {
public:
- Group(const std::string&, const Bar&, const Json::Value&);
+ Group(const std::string&, const std::string&, const Json::Value&, bool);
~Group() = default;
- auto update() -> void;
- operator Gtk::Widget&();
+ auto update() -> void override;
+ operator Gtk::Widget&() override;
Gtk::Box box;
};
diff --git a/include/modules/backlight.hpp b/include/modules/backlight.hpp
index 90567716..ade4bc78 100644
--- a/include/modules/backlight.hpp
+++ b/include/modules/backlight.hpp
@@ -5,7 +5,8 @@
#include
#include
-#include "AButton.hpp"
+#include "ALabel.hpp"
+#include "giomm/dbusproxy.h"
#include "util/json.hpp"
#include "util/sleeper_thread.hpp"
@@ -14,7 +15,7 @@ struct udev_device;
namespace waybar::modules {
-class Backlight : public AButton {
+class Backlight : public ALabel {
class BacklightDev {
public:
BacklightDev() = default;
@@ -39,8 +40,8 @@ class Backlight : public AButton {
public:
Backlight(const std::string &, const Json::Value &);
- ~Backlight();
- auto update() -> void;
+ virtual ~Backlight();
+ auto update() -> void override;
private:
template
@@ -50,6 +51,8 @@ class Backlight : public AButton {
template
static void enumerate_devices(ForwardIt first, ForwardIt last, Inserter inserter, udev *udev);
+ bool handleScroll(GdkEventScroll *e) override;
+
const std::string preferred_device_;
static constexpr int EPOLL_MAX_EVENTS = 16;
@@ -60,5 +63,7 @@ class Backlight : public AButton {
std::vector devices_;
// thread must destruct before shared data
util::SleeperThread udev_thread_;
+
+ Glib::RefPtr login_proxy_;
};
} // namespace waybar::modules
diff --git a/include/modules/battery.hpp b/include/modules/battery.hpp
index 614b36ab..017b0e48 100644
--- a/include/modules/battery.hpp
+++ b/include/modules/battery.hpp
@@ -15,7 +15,7 @@
#include
#include
-#include "AButton.hpp"
+#include "ALabel.hpp"
#include "util/sleeper_thread.hpp"
namespace waybar::modules {
@@ -26,11 +26,11 @@ namespace fs = std::experimental::filesystem;
namespace fs = std::filesystem;
#endif
-class Battery : public AButton {
+class Battery : public ALabel {
public:
Battery(const std::string&, const Json::Value&);
- ~Battery();
- auto update() -> void;
+ virtual ~Battery();
+ auto update() -> void override;
private:
static inline const fs::path data_dir_ = "/sys/class/power_supply/";
diff --git a/include/modules/bluetooth.hpp b/include/modules/bluetooth.hpp
index 6aac0747..18481e31 100644
--- a/include/modules/bluetooth.hpp
+++ b/include/modules/bluetooth.hpp
@@ -1,6 +1,6 @@
#pragma once
-#include "AButton.hpp"
+#include "ALabel.hpp"
#ifdef WANT_RFKILL
#include "util/rfkill.hpp"
#endif
@@ -12,7 +12,7 @@
namespace waybar::modules {
-class Bluetooth : public AButton {
+class Bluetooth : public ALabel {
struct ControllerInfo {
std::string path;
std::string address;
@@ -45,8 +45,8 @@ class Bluetooth : public AButton {
public:
Bluetooth(const std::string&, const Json::Value&);
- ~Bluetooth() = default;
- auto update() -> void;
+ virtual ~Bluetooth() = default;
+ auto update() -> void override;
private:
static auto onInterfaceAddedOrRemoved(GDBusObjectManager*, GDBusObject*, GDBusInterface*,
diff --git a/include/modules/cava.hpp b/include/modules/cava.hpp
new file mode 100644
index 00000000..d4da2b77
--- /dev/null
+++ b/include/modules/cava.hpp
@@ -0,0 +1,46 @@
+#pragma once
+
+#include "ALabel.hpp"
+#include "util/sleeper_thread.hpp"
+
+extern "C" {
+#include
+}
+
+namespace waybar::modules {
+using namespace std::literals::chrono_literals;
+
+class Cava final : public ALabel {
+ public:
+ Cava(const std::string&, const Json::Value&);
+ virtual ~Cava();
+ auto update() -> void override;
+ auto doAction(const std::string& name) -> void override;
+
+ private:
+ util::SleeperThread thread_;
+ util::SleeperThread thread_fetch_input_;
+
+ struct error_s error_ {}; // cava errors
+ struct config_params prm_ {}; // cava parameters
+ struct audio_raw audio_raw_ {}; // cava handled raw audio data(is based on audio_data)
+ struct audio_data audio_data_ {}; // cava audio data
+ struct cava_plan* plan_; //{new cava_plan{}};
+ // Cava API to read audio source
+ ptr input_source_;
+ // Delay to handle audio source
+ std::chrono::milliseconds frame_time_milsec_{1s};
+ // Text to display
+ std::string text_{""};
+ int rePaint_{1};
+ std::chrono::seconds fetch_input_delay_{4};
+ std::chrono::seconds suspend_silence_delay_{0};
+ bool silence_{false};
+ int sleep_counter_{0};
+ // Cava method
+ void pause_resume();
+ // ModuleActionMap
+ static inline std::map actionMap_{
+ {"mode", &waybar::modules::Cava::pause_resume}};
+};
+} // namespace waybar::modules
diff --git a/include/modules/clock.hpp b/include/modules/clock.hpp
index b3e49888..fab38111 100644
--- a/include/modules/clock.hpp
+++ b/include/modules/clock.hpp
@@ -1,44 +1,72 @@
#pragma once
-#include
-
-#include "AButton.hpp"
+#include "ALabel.hpp"
+#include "util/date.hpp"
#include "util/sleeper_thread.hpp"
-namespace waybar {
-
-struct waybar_time;
-
-namespace modules {
+namespace waybar::modules {
const std::string kCalendarPlaceholder = "calendar";
const std::string KTimezonedTimeListPlaceholder = "timezoned_time_list";
-class Clock : public AButton {
+enum class WeeksSide {
+ LEFT,
+ RIGHT,
+ HIDDEN,
+};
+
+enum class CldMode { MONTH, YEAR };
+
+class Clock final : public ALabel {
public:
Clock(const std::string&, const Json::Value&);
- ~Clock() = default;
- auto update() -> void;
+ virtual ~Clock() = default;
+ auto update() -> void override;
+ auto doAction(const std::string& name) -> void override;
private:
util::SleeperThread thread_;
std::locale locale_;
std::vector time_zones_;
int current_time_zone_idx_;
- date::year_month_day calendar_cached_ymd_{date::January / 1 / 0};
- date::months calendar_shift_{0}, calendar_shift_init_{0};
- std::string calendar_cached_text_;
bool is_calendar_in_tooltip_;
bool is_timezoned_list_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;
const date::time_zone* current_timezone();
bool is_timezone_fixed();
auto timezones_text(std::chrono::system_clock::time_point* now) -> std::string;
+
+ /*Calendar properties*/
+ WeeksSide cldWPos_{WeeksSide::HIDDEN};
+ std::map fmtMap_;
+ CldMode cldMode_{CldMode::MONTH};
+ uint cldMonCols_{3}; // Count of the month in the row
+ int cldMonColLen_{20}; // Length of the month column
+ int cldWnLen_{3}; // Length of the week number
+ date::year_month_day cldYearShift_;
+ date::year_month cldMonShift_;
+ date::months cldCurrShift_{0};
+ date::months cldShift_{0};
+ std::string cldYearCached_{};
+ std::string cldMonCached_{};
+ date::day cldBaseDay_{0};
+ /*Calendar functions*/
+ auto get_calendar(const date::zoned_seconds& now, const date::zoned_seconds& wtime)
+ -> std::string;
+ /*Clock actions*/
+ void cldModeSwitch();
+ void cldShift_up();
+ void cldShift_down();
+ void tz_up();
+ void tz_down();
+
+ // ModuleActionMap
+ static inline std::map actionMap_{
+ {"mode", &waybar::modules::Clock::cldModeSwitch},
+ {"shift_up", &waybar::modules::Clock::cldShift_up},
+ {"shift_down", &waybar::modules::Clock::cldShift_down},
+ {"tz_up", &waybar::modules::Clock::tz_up},
+ {"tz_down", &waybar::modules::Clock::tz_down}};
};
-} // namespace modules
-} // namespace waybar
+} // namespace waybar::modules
diff --git a/include/modules/cpu.hpp b/include/modules/cpu.hpp
index 4ad5771f..a5235486 100644
--- a/include/modules/cpu.hpp
+++ b/include/modules/cpu.hpp
@@ -9,16 +9,16 @@
#include
#include
-#include "AButton.hpp"
+#include "ALabel.hpp"
#include "util/sleeper_thread.hpp"
namespace waybar::modules {
-class Cpu : public AButton {
+class Cpu : public ALabel {
public:
Cpu(const std::string&, const Json::Value&);
- ~Cpu() = default;
- auto update() -> void;
+ virtual ~Cpu() = default;
+ auto update() -> void override;
private:
double getCpuLoad();
diff --git a/include/modules/custom.hpp b/include/modules/custom.hpp
index e4a81bb4..a6024a84 100644
--- a/include/modules/custom.hpp
+++ b/include/modules/custom.hpp
@@ -5,19 +5,19 @@
#include
#include
-#include "AButton.hpp"
+#include "ALabel.hpp"
#include "util/command.hpp"
#include "util/json.hpp"
#include "util/sleeper_thread.hpp"
namespace waybar::modules {
-class Custom : public AButton {
+class Custom : public ALabel {
public:
Custom(const std::string&, const std::string&, const Json::Value&);
- ~Custom();
- auto update() -> void;
- void refresh(int /*signal*/);
+ virtual ~Custom();
+ auto update() -> void override;
+ void refresh(int /*signal*/) override;
private:
void delayWorker();
@@ -25,8 +25,8 @@ class Custom : public AButton {
void parseOutputRaw();
void parseOutputJson();
void handleEvent();
- bool handleScroll(GdkEventScroll* e);
- bool handleToggle(GdkEventButton* const& e);
+ bool handleScroll(GdkEventScroll* e) override;
+ bool handleToggle(GdkEventButton* const& e) override;
const std::string name_;
std::string text_;
diff --git a/include/modules/disk.hpp b/include/modules/disk.hpp
index 761314e2..2a307c9e 100644
--- a/include/modules/disk.hpp
+++ b/include/modules/disk.hpp
@@ -5,17 +5,17 @@
#include
-#include "AButton.hpp"
+#include "ALabel.hpp"
#include "util/format.hpp"
#include "util/sleeper_thread.hpp"
namespace waybar::modules {
-class Disk : public AButton {
+class Disk : public ALabel {
public:
Disk(const std::string&, const Json::Value&);
- ~Disk() = default;
- auto update() -> void;
+ virtual ~Disk() = default;
+ auto update() -> void override;
private:
util::SleeperThread thread_;
diff --git a/include/modules/dwl/tags.hpp b/include/modules/dwl/tags.hpp
new file mode 100644
index 00000000..53dff989
--- /dev/null
+++ b/include/modules/dwl/tags.hpp
@@ -0,0 +1,34 @@
+#pragma once
+
+#include
+#include
+
+#include "AModule.hpp"
+#include "bar.hpp"
+#include "dwl-ipc-unstable-v2-client-protocol.h"
+#include "xdg-output-unstable-v1-client-protocol.h"
+
+namespace waybar::modules::dwl {
+
+class Tags : public waybar::AModule {
+ public:
+ Tags(const std::string &, const waybar::Bar &, const Json::Value &);
+ virtual ~Tags();
+
+ // Handlers for wayland events
+ void handle_view_tags(uint32_t tag, uint32_t state, uint32_t clients, uint32_t focused);
+
+ void handle_primary_clicked(uint32_t tag);
+ bool handle_button_press(GdkEventButton *event_button, uint32_t tag);
+
+ struct zdwl_ipc_manager_v2 *status_manager_;
+ struct wl_seat *seat_;
+
+ private:
+ const waybar::Bar &bar_;
+ Gtk::Box box_;
+ std::vector buttons_;
+ struct zdwl_ipc_output_v2 *output_status_;
+};
+
+} /* namespace waybar::modules::dwl */
diff --git a/include/modules/gamemode.hpp b/include/modules/gamemode.hpp
index b027393f..69c0c3ae 100644
--- a/include/modules/gamemode.hpp
+++ b/include/modules/gamemode.hpp
@@ -18,8 +18,8 @@ namespace waybar::modules {
class Gamemode : public AModule {
public:
Gamemode(const std::string &, const Json::Value &);
- ~Gamemode();
- auto update() -> void;
+ virtual ~Gamemode();
+ auto update() -> void override;
private:
const std::string DEFAULT_ICON_NAME = "input-gaming-symbolic";
@@ -39,7 +39,7 @@ class Gamemode : public AModule {
const Glib::VariantContainerBase &arguments);
void getData();
- bool handleToggle(GdkEventButton *const &);
+ bool handleToggle(GdkEventButton *const &) override;
// Config
std::string format = DEFAULT_FORMAT;
diff --git a/include/modules/hyprland/backend.hpp b/include/modules/hyprland/backend.hpp
index 9401bf5a..e23b1582 100644
--- a/include/modules/hyprland/backend.hpp
+++ b/include/modules/hyprland/backend.hpp
@@ -1,15 +1,17 @@
#pragma once
-#include
#include
+#include
#include
#include
#include
#include
+#include "util/json.hpp"
+
namespace waybar::modules::hyprland {
class EventHandler {
-public:
+ public:
virtual void onEvent(const std::string& ev) = 0;
virtual ~EventHandler() = default;
};
@@ -22,12 +24,14 @@ class IPC {
void unregisterForIPC(EventHandler*);
std::string getSocket1Reply(const std::string& rq);
+ Json::Value getSocket1JsonReply(const std::string& rq);
private:
void startIPC();
void parseIPC(const std::string&);
std::mutex callbackMutex;
+ util::JsonParser parser_;
std::list> callbacks;
};
diff --git a/include/modules/hyprland/language.hpp b/include/modules/hyprland/language.hpp
index 04fe3825..30789d06 100644
--- a/include/modules/hyprland/language.hpp
+++ b/include/modules/hyprland/language.hpp
@@ -1,30 +1,38 @@
#include
-#include "AButton.hpp"
+#include "ALabel.hpp"
#include "bar.hpp"
#include "modules/hyprland/backend.hpp"
#include "util/json.hpp"
namespace waybar::modules::hyprland {
-class Language : public waybar::AButton,
-public EventHandler {
+class Language : public waybar::ALabel, public EventHandler {
public:
Language(const std::string&, const waybar::Bar&, const Json::Value&);
- ~Language();
+ virtual ~Language();
- auto update() -> void;
+ auto update() -> void override;
private:
- void onEvent(const std::string&);
+ void onEvent(const std::string&) override;
void initLanguage();
- std::string getShortFrom(const std::string&);
+
+ struct Layout {
+ std::string full_name;
+ std::string short_name;
+ std::string variant;
+ std::string short_description;
+ };
+
+ auto getLayout(const std::string&) -> Layout;
std::mutex mutex_;
const Bar& bar_;
util::JsonParser parser_;
- std::string layoutName_;
+
+ Layout layout_;
};
} // namespace waybar::modules::hyprland
diff --git a/include/modules/hyprland/submap.hpp b/include/modules/hyprland/submap.hpp
new file mode 100644
index 00000000..e2a84981
--- /dev/null
+++ b/include/modules/hyprland/submap.hpp
@@ -0,0 +1,26 @@
+#include
+
+#include "ALabel.hpp"
+#include "bar.hpp"
+#include "modules/hyprland/backend.hpp"
+#include "util/json.hpp"
+
+namespace waybar::modules::hyprland {
+
+class Submap : public waybar::ALabel, public EventHandler {
+ public:
+ Submap(const std::string&, const waybar::Bar&, const Json::Value&);
+ virtual ~Submap();
+
+ auto update() -> void override;
+
+ private:
+ void onEvent(const std::string&) override;
+
+ std::mutex mutex_;
+ const Bar& bar_;
+ util::JsonParser parser_;
+ std::string submap_;
+};
+
+} // namespace waybar::modules::hyprland
diff --git a/include/modules/hyprland/window.hpp b/include/modules/hyprland/window.hpp
index 4b697cf3..950be05f 100644
--- a/include/modules/hyprland/window.hpp
+++ b/include/modules/hyprland/window.hpp
@@ -1,7 +1,5 @@
#include
-#include
-
#include "ALabel.hpp"
#include "bar.hpp"
#include "modules/hyprland/backend.hpp"
@@ -9,24 +7,40 @@
namespace waybar::modules::hyprland {
-class Window : public waybar::ALabel,
- public EventHandler {
+class Window : public waybar::ALabel, public EventHandler {
public:
Window(const std::string&, const waybar::Bar&, const Json::Value&);
- ~Window();
+ virtual ~Window();
- auto update() -> void;
+ auto update() -> void override;
private:
- uint getActiveWorkspaceID(std::string);
- std::string getLastWindowTitle(uint);
- void onEvent(const std::string&);
+ struct Workspace {
+ int id;
+ int windows;
+ std::string last_window;
+ std::string last_window_title;
+
+ static auto parse(const Json::Value&) -> Workspace;
+ };
+
+ auto getActiveWorkspace(const std::string&) -> Workspace;
+ auto getActiveWorkspace() -> Workspace;
+ void onEvent(const std::string&) override;
+ void queryActiveWorkspace();
+ void setClass(const std::string&, bool enable);
bool separate_outputs;
std::mutex mutex_;
const Bar& bar_;
util::JsonParser parser_;
- std::string lastView;
+ std::string last_title_;
+ Workspace workspace_;
+ std::string solo_class_;
+ std::string last_solo_class_;
+ bool solo_;
+ bool all_floating_;
+ bool fullscreen_;
};
} // namespace waybar::modules::hyprland
diff --git a/include/modules/hyprland/workspaces.hpp b/include/modules/hyprland/workspaces.hpp
new file mode 100644
index 00000000..500bbe36
--- /dev/null
+++ b/include/modules/hyprland/workspaces.hpp
@@ -0,0 +1,64 @@
+#include
+#include
+
+#include
+
+#include "AModule.hpp"
+#include "bar.hpp"
+#include "modules/hyprland/backend.hpp"
+
+namespace waybar::modules::hyprland {
+
+struct WorkspaceDto {
+ int id;
+
+ static WorkspaceDto parse(const Json::Value& value);
+};
+
+class Workspace {
+ public:
+ Workspace(int id);
+ Workspace(WorkspaceDto dto);
+ int id() const { return id_; };
+ int active() const { return active_; };
+ std::string& select_icon(std::map& icons_map);
+ void set_active(bool value = true) { active_ = value; };
+ Gtk::Button& button() { return button_; };
+
+ void update(const std::string& format, const std::string& icon);
+
+ private:
+ int id_;
+ bool active_;
+
+ Gtk::Button button_;
+ Gtk::Box content_;
+ Gtk::Label label_;
+};
+
+class Workspaces : public AModule, public EventHandler {
+ public:
+ Workspaces(const std::string&, const waybar::Bar&, const Json::Value&);
+ virtual ~Workspaces();
+ void update() override;
+ void init();
+
+ private:
+ void onEvent(const std::string&) override;
+ void sort_workspaces();
+ void create_workspace(int id);
+ void remove_workspace(int id);
+
+ std::string format_;
+ std::map icons_map_;
+ bool with_icon_;
+ int active_workspace_id;
+ std::vector> workspaces_;
+ std::vector workspaces_to_create_;
+ std::vector workspaces_to_remove_;
+ std::mutex mutex_;
+ const Bar& bar_;
+ Gtk::Box box_;
+};
+
+} // namespace waybar::modules::hyprland
diff --git a/include/modules/idle_inhibitor.hpp b/include/modules/idle_inhibitor.hpp
index 80d370c4..22bd808f 100644
--- a/include/modules/idle_inhibitor.hpp
+++ b/include/modules/idle_inhibitor.hpp
@@ -2,24 +2,24 @@
#include
-#include "AButton.hpp"
+#include "ALabel.hpp"
#include "bar.hpp"
#include "client.hpp"
namespace waybar::modules {
-class IdleInhibitor : public AButton {
+class IdleInhibitor : public ALabel {
sigc::connection timeout_;
public:
IdleInhibitor(const std::string&, const waybar::Bar&, const Json::Value&);
- ~IdleInhibitor();
- auto update() -> void;
+ virtual ~IdleInhibitor();
+ auto update() -> void override;
static std::list modules;
static bool status;
private:
- bool handleToggle(GdkEventButton* const& e);
+ bool handleToggle(GdkEventButton* const& e) override;
void toggleStatus();
const Bar& bar_;
diff --git a/include/modules/image.hpp b/include/modules/image.hpp
new file mode 100644
index 00000000..7c0d014f
--- /dev/null
+++ b/include/modules/image.hpp
@@ -0,0 +1,40 @@
+#pragma once
+
+#include
+#include
+
+#include
+#include
+
+#include "ALabel.hpp"
+#include "gtkmm/box.h"
+#include "util/command.hpp"
+#include "util/json.hpp"
+#include "util/sleeper_thread.hpp"
+
+namespace waybar::modules {
+
+class Image : public AModule {
+ public:
+ Image(const std::string&, const Json::Value&);
+ virtual ~Image() = default;
+ auto update() -> void override;
+ void refresh(int /*signal*/) override;
+
+ private:
+ void delayWorker();
+ void handleEvent();
+ void parseOutputRaw();
+
+ Gtk::Box box_;
+ Gtk::Image image_;
+ std::string path_;
+ std::string tooltip_;
+ int size_;
+ int interval_;
+ util::command::res output_;
+
+ util::SleeperThread thread_;
+};
+
+} // namespace waybar::modules
diff --git a/include/modules/inhibitor.hpp b/include/modules/inhibitor.hpp
index 9a012035..43cb6cab 100644
--- a/include/modules/inhibitor.hpp
+++ b/include/modules/inhibitor.hpp
@@ -4,20 +4,20 @@
#include
-#include "AButton.hpp"
+#include "ALabel.hpp"
#include "bar.hpp"
namespace waybar::modules {
-class Inhibitor : public AButton {
+class Inhibitor : public ALabel {
public:
Inhibitor(const std::string&, const waybar::Bar&, const Json::Value&);
- ~Inhibitor() override;
- auto update() -> void;
+ virtual ~Inhibitor();
+ auto update() -> void override;
auto activated() -> bool;
private:
- auto handleToggle(::GdkEventButton* const& e) -> bool;
+ auto handleToggle(::GdkEventButton* const& e) -> bool override;
const std::unique_ptr<::GDBusConnection, void (*)(::GDBusConnection*)> dbus_;
const std::string inhibitors_;
diff --git a/include/modules/jack.hpp b/include/modules/jack.hpp
index fbab0623..452c43a3 100644
--- a/include/modules/jack.hpp
+++ b/include/modules/jack.hpp
@@ -14,8 +14,8 @@ namespace waybar::modules {
class JACK : public ALabel {
public:
JACK(const std::string &, const Json::Value &);
- ~JACK() = default;
- auto update() -> void;
+ virtual ~JACK() = default;
+ auto update() -> void override;
int bufSize(jack_nframes_t size);
int sampleRate(jack_nframes_t rate);
diff --git a/include/modules/keyboard_state.hpp b/include/modules/keyboard_state.hpp
index ce9faba0..deb577e2 100644
--- a/include/modules/keyboard_state.hpp
+++ b/include/modules/keyboard_state.hpp
@@ -19,8 +19,8 @@ namespace waybar::modules {
class KeyboardState : public AModule {
public:
KeyboardState(const std::string&, const waybar::Bar&, const Json::Value&);
- ~KeyboardState();
- auto update() -> void;
+ virtual ~KeyboardState();
+ auto update() -> void override;
private:
auto tryAddDevice(const std::string&) -> void;
diff --git a/include/modules/memory.hpp b/include/modules/memory.hpp
index a5887e3d..3b6342b3 100644
--- a/include/modules/memory.hpp
+++ b/include/modules/memory.hpp
@@ -5,16 +5,16 @@
#include
#include
-#include "AButton.hpp"
+#include "ALabel.hpp"
#include "util/sleeper_thread.hpp"
namespace waybar::modules {
-class Memory : public AButton {
+class Memory : public ALabel {
public:
Memory(const std::string&, const Json::Value&);
- ~Memory() = default;
- auto update() -> void;
+ virtual ~Memory() = default;
+ auto update() -> void override;
private:
void parseMeminfo();
diff --git a/include/modules/mpd/mpd.hpp b/include/modules/mpd/mpd.hpp
index b85906d1..32d526e9 100644
--- a/include/modules/mpd/mpd.hpp
+++ b/include/modules/mpd/mpd.hpp
@@ -7,12 +7,12 @@
#include
#include
-#include "AButton.hpp"
+#include "ALabel.hpp"
#include "modules/mpd/state.hpp"
namespace waybar::modules {
-class MPD : public AButton {
+class MPD : public ALabel {
friend class detail::Context;
// State machine
@@ -37,7 +37,7 @@ class MPD : public AButton {
public:
MPD(const std::string&, const Json::Value&);
virtual ~MPD() noexcept = default;
- auto update() -> void;
+ auto update() -> void override;
private:
std::string getTag(mpd_tag_type type, unsigned idx = 0) const;
diff --git a/include/modules/mpd/state.hpp b/include/modules/mpd/state.hpp
index 28ca6410..1276e3c3 100644
--- a/include/modules/mpd/state.hpp
+++ b/include/modules/mpd/state.hpp
@@ -7,7 +7,7 @@
#include
#include
-#include "AButton.hpp"
+#include "ALabel.hpp"
namespace waybar::modules {
class MPD;
diff --git a/include/modules/mpris/mpris.hpp b/include/modules/mpris/mpris.hpp
new file mode 100644
index 00000000..a0aee3b2
--- /dev/null
+++ b/include/modules/mpris/mpris.hpp
@@ -0,0 +1,88 @@
+#pragma once
+
+#include
+#include
+#include
+
+#include "gtkmm/box.h"
+#include "gtkmm/label.h"
+
+extern "C" {
+#include
+}
+
+#include "ALabel.hpp"
+#include "util/sleeper_thread.hpp"
+
+namespace waybar::modules::mpris {
+
+class Mpris : public ALabel {
+ public:
+ Mpris(const std::string&, const Json::Value&);
+ virtual ~Mpris();
+ auto update() -> void override;
+ bool handleToggle(GdkEventButton* const&) override;
+
+ private:
+ static auto onPlayerNameAppeared(PlayerctlPlayerManager*, PlayerctlPlayerName*, gpointer) -> void;
+ static auto onPlayerNameVanished(PlayerctlPlayerManager*, PlayerctlPlayerName*, gpointer) -> void;
+ static auto onPlayerPlay(PlayerctlPlayer*, gpointer) -> void;
+ static auto onPlayerPause(PlayerctlPlayer*, gpointer) -> void;
+ static auto onPlayerStop(PlayerctlPlayer*, gpointer) -> void;
+ static auto onPlayerMetadata(PlayerctlPlayer*, GVariant*, gpointer) -> void;
+
+ struct PlayerInfo {
+ std::string name;
+ PlayerctlPlaybackStatus status;
+ std::string status_string;
+
+ std::optional artist;
+ std::optional album;
+ std::optional title;
+ std::optional length; // as HH:MM:SS
+ std::optional position; // same format
+ };
+
+ auto getPlayerInfo() -> std::optional;
+ auto getIconFromJson(const Json::Value&, const std::string&) -> std::string;
+ auto getArtistStr(const PlayerInfo&, bool) -> std::string;
+ auto getAlbumStr(const PlayerInfo&, bool) -> std::string;
+ auto getTitleStr(const PlayerInfo&, bool) -> std::string;
+ auto getLengthStr(const PlayerInfo&, bool) -> std::string;
+ auto getPositionStr(const PlayerInfo&, bool) -> std::string;
+ auto getDynamicStr(const PlayerInfo&, bool, bool) -> std::string;
+
+ // config
+ std::string format_playing_;
+ std::string format_paused_;
+ std::string format_stopped_;
+
+ std::string tooltip_;
+ std::string tooltip_playing_;
+ std::string tooltip_paused_;
+ std::string tooltip_stopped_;
+
+ int artist_len_;
+ int album_len_;
+ int title_len_;
+ int dynamic_len_;
+ std::string dynamic_separator_;
+ std::vector dynamic_order_;
+ std::vector dynamic_prio_;
+ bool truncate_hours_;
+ bool tooltip_len_limits_;
+ std::string ellipsis_;
+
+ std::string player_;
+ std::vector ignored_players_;
+
+ PlayerctlPlayerManager* manager;
+ PlayerctlPlayer* player;
+ std::string lastStatus;
+ std::string lastPlayer;
+
+ util::SleeperThread thread_;
+ std::chrono::time_point last_update_;
+};
+
+} // namespace waybar::modules::mpris
diff --git a/include/modules/network.hpp b/include/modules/network.hpp
index 9f13da59..47701b4e 100644
--- a/include/modules/network.hpp
+++ b/include/modules/network.hpp
@@ -10,7 +10,7 @@
#include
-#include "AButton.hpp"
+#include "ALabel.hpp"
#include "util/sleeper_thread.hpp"
#ifdef WANT_RFKILL
#include "util/rfkill.hpp"
@@ -18,11 +18,11 @@
namespace waybar::modules {
-class Network : public AButton {
+class Network : public ALabel {
public:
Network(const std::string&, const Json::Value&);
- ~Network();
- auto update() -> void;
+ virtual ~Network();
+ auto update() -> void override;
private:
static const uint8_t MAX_RETRY = 5;
@@ -62,6 +62,7 @@ class Network : public AButton {
bool want_link_dump_;
bool want_addr_dump_;
bool dump_in_progress_;
+ bool is_p2p_;
unsigned long long bandwidth_down_total_;
unsigned long long bandwidth_up_total_;
@@ -77,7 +78,6 @@ class Network : public AButton {
int32_t signal_strength_dbm_;
uint8_t signal_strength_;
std::string signal_strength_app_;
- float frequency_;
uint32_t route_priority;
util::SleeperThread thread_;
@@ -85,6 +85,7 @@ class Network : public AButton {
#ifdef WANT_RFKILL
util::Rfkill rfkill_;
#endif
+ float frequency_;
};
} // namespace waybar::modules
diff --git a/include/modules/pulseaudio.hpp b/include/modules/pulseaudio.hpp
index f222f9e7..d0b17e47 100644
--- a/include/modules/pulseaudio.hpp
+++ b/include/modules/pulseaudio.hpp
@@ -7,15 +7,15 @@
#include
#include
-#include "AButton.hpp"
+#include "ALabel.hpp"
namespace waybar::modules {
-class Pulseaudio : public AButton {
+class Pulseaudio : public ALabel {
public:
Pulseaudio(const std::string&, const Json::Value&);
- ~Pulseaudio();
- auto update() -> void;
+ virtual ~Pulseaudio();
+ auto update() -> void override;
private:
static void subscribeCb(pa_context*, pa_subscription_event_type_t, uint32_t, void*);
@@ -25,7 +25,7 @@ class Pulseaudio : public AButton {
static void serverInfoCb(pa_context*, const pa_server_info*, void*);
static void volumeModifyCb(pa_context*, int, void*);
- bool handleScroll(GdkEventScroll* e);
+ bool handleScroll(GdkEventScroll* e) override;
const std::vector getPulseIcon() const;
pa_threaded_mainloop* mainloop_;
diff --git a/include/modules/river/layout.hpp b/include/modules/river/layout.hpp
new file mode 100644
index 00000000..dc78ee20
--- /dev/null
+++ b/include/modules/river/layout.hpp
@@ -0,0 +1,33 @@
+#pragma once
+
+#include
+
+#include "ALabel.hpp"
+#include "bar.hpp"
+#include "river-status-unstable-v1-client-protocol.h"
+
+namespace waybar::modules::river {
+
+class Layout : public waybar::ALabel {
+ public:
+ Layout(const std::string &, const waybar::Bar &, const Json::Value &);
+ virtual ~Layout();
+
+ // Handlers for wayland events
+ void handle_name(const char *name);
+ void handle_clear();
+ void handle_focused_output(struct wl_output *output);
+ void handle_unfocused_output(struct wl_output *output);
+
+ struct zriver_status_manager_v1 *status_manager_;
+ struct wl_seat *seat_;
+
+ private:
+ const waybar::Bar &bar_;
+ struct wl_output *output_; // stores the output this module belongs to
+ struct wl_output *focused_output_; // stores the currently focused output
+ struct zriver_output_status_v1 *output_status_;
+ struct zriver_seat_status_v1 *seat_status_;
+};
+
+} /* namespace waybar::modules::river */
diff --git a/include/modules/river/mode.hpp b/include/modules/river/mode.hpp
index 2aff4950..246cecae 100644
--- a/include/modules/river/mode.hpp
+++ b/include/modules/river/mode.hpp
@@ -11,7 +11,7 @@ namespace waybar::modules::river {
class Mode : public waybar::ALabel {
public:
Mode(const std::string &, const waybar::Bar &, const Json::Value &);
- ~Mode();
+ virtual ~Mode();
// Handlers for wayland events
void handle_mode(const char *mode);
diff --git a/include/modules/river/tags.hpp b/include/modules/river/tags.hpp
index c2b1a119..fb3eefaa 100644
--- a/include/modules/river/tags.hpp
+++ b/include/modules/river/tags.hpp
@@ -14,7 +14,7 @@ namespace waybar::modules::river {
class Tags : public waybar::AModule {
public:
Tags(const std::string &, const waybar::Bar &, const Json::Value &);
- ~Tags();
+ virtual ~Tags();
// Handlers for wayland events
void handle_focused_tags(uint32_t tags);
diff --git a/include/modules/river/window.hpp b/include/modules/river/window.hpp
index 1f6c5252..bf29ebbf 100644
--- a/include/modules/river/window.hpp
+++ b/include/modules/river/window.hpp
@@ -13,7 +13,7 @@ namespace waybar::modules::river {
class Window : public waybar::ALabel {
public:
Window(const std::string &, const waybar::Bar &, const Json::Value &);
- ~Window();
+ virtual ~Window();
// Handlers for wayland events
void handle_focused_view(const char *title);
diff --git a/include/modules/simpleclock.hpp b/include/modules/simpleclock.hpp
index 2945d86e..43472ef0 100644
--- a/include/modules/simpleclock.hpp
+++ b/include/modules/simpleclock.hpp
@@ -2,16 +2,16 @@
#include
-#include "AButton.hpp"
+#include "ALabel.hpp"
#include "util/sleeper_thread.hpp"
namespace waybar::modules {
-class Clock : public AButton {
+class Clock : public ALabel {
public:
Clock(const std::string&, const Json::Value&);
- ~Clock() = default;
- auto update() -> void;
+ virtual ~Clock() = default;
+ auto update() -> void override;
private:
util::SleeperThread thread_;
diff --git a/include/modules/sndio.hpp b/include/modules/sndio.hpp
index 6d7350cf..3fe36fad 100644
--- a/include/modules/sndio.hpp
+++ b/include/modules/sndio.hpp
@@ -4,20 +4,20 @@
#include
-#include "AButton.hpp"
+#include "ALabel.hpp"
#include "util/sleeper_thread.hpp"
namespace waybar::modules {
-class Sndio : public AButton {
+class Sndio : public ALabel {
public:
Sndio(const std::string &, const Json::Value &);
- ~Sndio();
- auto update() -> void;
+ virtual ~Sndio();
+ auto update() -> void override;
auto set_desc(struct sioctl_desc *, unsigned int) -> void;
auto put_val(unsigned int, unsigned int) -> void;
- bool handleScroll(GdkEventScroll *);
- bool handleToggle(GdkEventButton *const &);
+ bool handleScroll(GdkEventScroll *) override;
+ bool handleToggle(GdkEventButton *const &) override;
private:
auto connect_to_sndio() -> void;
diff --git a/include/modules/sni/tray.hpp b/include/modules/sni/tray.hpp
index c1499b9e..6cda35d7 100644
--- a/include/modules/sni/tray.hpp
+++ b/include/modules/sni/tray.hpp
@@ -13,8 +13,8 @@ namespace waybar::modules::SNI {
class Tray : public AModule {
public:
Tray(const std::string&, const Bar&, const Json::Value&);
- ~Tray() = default;
- auto update() -> void;
+ virtual ~Tray() = default;
+ auto update() -> void override;
private:
void onAdd(std::unique_ptr- & item);
diff --git a/include/modules/sway/ipc/client.hpp b/include/modules/sway/ipc/client.hpp
index 77dab083..a9a3e4e9 100644
--- a/include/modules/sway/ipc/client.hpp
+++ b/include/modules/sway/ipc/client.hpp
@@ -8,6 +8,8 @@
#include
#include
#include
+#include
+#include
#include "ipc.hpp"
#include "util/sleeper_thread.hpp"
diff --git a/include/modules/sway/language.hpp b/include/modules/sway/language.hpp
index 8673067b..3e9519f5 100644
--- a/include/modules/sway/language.hpp
+++ b/include/modules/sway/language.hpp
@@ -6,7 +6,7 @@
#include