diff --git a/.github/workflows/freebsd.yml b/.github/workflows/freebsd.yml
index 7072c493..f02c9b57 100644
--- a/.github/workflows/freebsd.yml
+++ b/.github/workflows/freebsd.yml
@@ -8,15 +8,16 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Test in FreeBSD VM
- uses: vmactions/freebsd-vm@v0.0.9 # aka FreeBSD 12.2
+ uses: vmactions/freebsd-vm@v0.1.4 # aka FreeBSD 12.2
with:
usesh: true
prepare: |
export CPPFLAGS=-isystem/usr/local/include LDFLAGS=-L/usr/local/lib # sndio
sed -i '' 's/quarterly/latest/' /etc/pkg/FreeBSD.conf
pkg install -y git # subprojects/date
- pkg install -y gtk-layer-shell gtkmm30 jsoncpp libdbusmenu sndio \
- libfmt libmpdclient libudev-devd meson pkgconf pulseaudio scdoc spdlog
+ pkg install -y evdev-proto gtk-layer-shell gtkmm30 jsoncpp libdbusmenu \
+ libevdev libfmt libmpdclient libudev-devd meson pkgconf pulseaudio \
+ scdoc sndio spdlog
run: |
meson build -Dman-pages=enabled
ninja -C build
diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml
new file mode 100644
index 00000000..e550e20b
--- /dev/null
+++ b/.github/workflows/linux.yml
@@ -0,0 +1,25 @@
+name: linux
+
+on: [push, pull_request]
+
+jobs:
+ build:
+ strategy:
+ matrix:
+ distro:
+ - alpine
+ - archlinux
+ - debian
+ - fedora
+ - opensuse
+
+ runs-on: ubuntu-latest
+ container:
+ image: alexays/waybar:${{ matrix.distro }}
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: configure
+ run: meson -Dman-pages=enabled build
+ - name: build
+ run: ninja -C build
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index abc739cd..00000000
--- a/.travis.yml
+++ /dev/null
@@ -1,38 +0,0 @@
-language: cpp
-
-services:
- - docker
-
-git:
- submodules: false
-
-env:
- - distro: debian
- - distro: archlinux
- - distro: fedora
- - distro: alpine
- - distro: opensuse
-
-before_install:
- - docker pull alexays/waybar:${distro}
- - find . -type f \( -name '*.cpp' -o -name '*.h' \) -print0 | xargs -r0 clang-format -i
-
-script:
- - echo FROM alexays/waybar:${distro} > Dockerfile
- - echo ADD . /root >> Dockerfile
- - docker build -t waybar .
- - docker run waybar /bin/sh -c "cd /root && meson build -Dman-pages=enabled && ninja -C build"
-
-jobs:
- include:
- - os: freebsd
- compiler: clang
- env:
- before_install:
- - export CPPFLAGS+=-isystem/usr/local/include LDFLAGS+=-L/usr/local/lib # sndio
- - sudo sed -i '' 's/quarterly/latest/' /etc/pkg/FreeBSD.conf
- - sudo pkg install -y gtk-layer-shell gtkmm30 jsoncpp libdbusmenu sndio
- libfmt libmpdclient libudev-devd meson pulseaudio scdoc spdlog
- script:
- - meson build -Dman-pages=enabled
- - ninja -C build
diff --git a/Dockerfiles/alpine b/Dockerfiles/alpine
index 21d1cbba..c0e032ff 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
+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
diff --git a/Dockerfiles/archlinux b/Dockerfiles/archlinux
index 0b618ffe..40a1b2e3 100644
--- a/Dockerfiles/archlinux
+++ b/Dockerfiles/archlinux
@@ -1,6 +1,6 @@
# vim: ft=Dockerfile
-FROM archlinux/base:latest
+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
+ 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
diff --git a/Dockerfiles/debian b/Dockerfiles/debian
index cee17441..026d8fdb 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 && \
+ 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 clean
diff --git a/Dockerfiles/fedora b/Dockerfiles/fedora
index d75083c8..a61dcd3e 100644
--- a/Dockerfiles/fedora
+++ b/Dockerfiles/fedora
@@ -1,7 +1,12 @@
# vim: ft=Dockerfile
-FROM fedora:32
+FROM fedora:latest
-RUN dnf install sway meson git libinput-devel wayland-devel wayland-protocols-devel pugixml-devel egl-wayland-devel mesa-libEGL-devel mesa-libGLES-devel mesa-libgbm-devel libxkbcommon-devel libudev-devel pixman-devel gtkmm30-devel jsoncpp-devel scdoc -y && \
- dnf group install "C Development Tools and Libraries" -y && \
+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)' && \
dnf clean all -y
diff --git a/Dockerfiles/opensuse b/Dockerfiles/opensuse
index 5b664fb2..49dea272 100644
--- a/Dockerfiles/opensuse
+++ b/Dockerfiles/opensuse
@@ -3,5 +3,7 @@
FROM opensuse/tumbleweed:latest
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 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
diff --git a/README.md b/README.md
index b104adec..98b99a2d 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# Waybar [![Travis](https://travis-ci.org/Alexays/Waybar.svg?branch=master)](https://travis-ci.org/Alexays/Waybar) [![Licence](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) [![Paypal Donate](https://img.shields.io/badge/Donate-Paypal-2244dd.svg)](https://paypal.me/ARouillard)
![Waybar](https://raw.githubusercontent.com/alexays/waybar/master/preview-2.png)
+# Waybar [![Licence](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) [![Paypal Donate](https://img.shields.io/badge/Donate-Paypal-2244dd.svg)](https://paypal.me/ARouillard)
![Waybar](https://raw.githubusercontent.com/alexays/waybar/master/preview-2.png)
> Highly customizable Wayland bar for Sway and Wlroots based compositors.
> Available in Arch [community](https://www.archlinux.org/packages/community/x86_64/waybar/) or
@@ -68,6 +68,7 @@ libappindicator-gtk3 [Tray module]
libdbusmenu-gtk3 [Tray module]
libmpdclient [MPD module]
libsndio [sndio module]
+libevdev [KeyboardState module]
```
**Build dependencies**
@@ -86,6 +87,7 @@ sudo apt install \
clang-tidy \
gobject-introspection \
libdbusmenu-gtk3-dev \
+ libevdev-dev \
libfmt-dev \
libgirepository1.0-dev \
libgtk-3-dev \
diff --git a/include/ALabel.hpp b/include/ALabel.hpp
index 5b9ac541..d8a5b504 100644
--- a/include/ALabel.hpp
+++ b/include/ALabel.hpp
@@ -14,7 +14,7 @@ class ALabel : public AModule {
virtual ~ALabel() = 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, std::vector &alts, uint16_t max = 0);
+ virtual std::string getIcon(uint16_t, const std::vector &alts, uint16_t max = 0);
protected:
Gtk::Label label_;
diff --git a/include/bar.hpp b/include/bar.hpp
index d6cd895f..6f3dfcf9 100644
--- a/include/bar.hpp
+++ b/include/bar.hpp
@@ -44,6 +44,7 @@ class BarSurface {
virtual void setExclusiveZone(bool enable) = 0;
virtual void setLayer(bar_layer layer) = 0;
virtual void setMargins(const struct bar_margins &margins) = 0;
+ virtual void setPassThrough(bool enable) = 0;
virtual void setPosition(const std::string_view &position) = 0;
virtual void setSize(uint32_t width, uint32_t height) = 0;
virtual void commit(){};
@@ -64,6 +65,7 @@ class Bar {
struct waybar_output *output;
Json::Value config;
struct wl_surface * surface;
+ bool exclusive = true;
bool visible = true;
bool vertical = false;
Gtk::Window window;
diff --git a/include/client.hpp b/include/client.hpp
index ec3866ad..e7fa1db0 100644
--- a/include/client.hpp
+++ b/include/client.hpp
@@ -38,7 +38,9 @@ class Client {
const std::string getValidPath(const std::vector &paths) const;
void handleOutput(struct waybar_output &output);
bool isValidOutput(const Json::Value &config, struct waybar_output &output);
- auto setupConfig(const std::string &config_file) -> void;
+ auto setupConfig(const std::string &config_file, int depth) -> void;
+ auto resolveConfigIncludes(Json::Value &config, int depth) -> void;
+ auto mergeConfig(Json::Value &a_config_, Json::Value &b_config_) -> void;
auto setupCss(const std::string &css_file) -> void;
struct waybar_output & getOutput(void *);
std::vector getOutputConfigs(struct waybar_output &output);
diff --git a/include/factory.hpp b/include/factory.hpp
index 1cae68c9..4b9f32aa 100644
--- a/include/factory.hpp
+++ b/include/factory.hpp
@@ -38,6 +38,9 @@
#ifdef HAVE_LIBUDEV
#include "modules/backlight.hpp"
#endif
+#ifdef HAVE_LIBEVDEV
+#include "modules/keyboard_state.hpp"
+#endif
#ifdef HAVE_LIBPULSE
#include "modules/pulseaudio.hpp"
#endif
diff --git a/include/modules/cpu.hpp b/include/modules/cpu.hpp
index d5b79e05..866b5af7 100644
--- a/include/modules/cpu.hpp
+++ b/include/modules/cpu.hpp
@@ -21,7 +21,9 @@ class Cpu : public ALabel {
private:
double getCpuLoad();
std::tuple getCpuUsage();
+ std::tuple getCpuFrequency();
std::vector> parseCpuinfo();
+ std::vector parseCpuFrequencies();
std::vector> prev_times_;
diff --git a/include/modules/keyboard_state.hpp b/include/modules/keyboard_state.hpp
new file mode 100644
index 00000000..1793bfe8
--- /dev/null
+++ b/include/modules/keyboard_state.hpp
@@ -0,0 +1,47 @@
+#pragma once
+
+#include
+#if FMT_VERSION < 60000
+#include
+#else
+#include
+#endif
+#include "AModule.hpp"
+#include "bar.hpp"
+#include "util/sleeper_thread.hpp"
+#include
+
+extern "C" {
+#include
+}
+
+namespace waybar::modules {
+
+class KeyboardState : public AModule {
+ public:
+ KeyboardState(const std::string&, const waybar::Bar&, const Json::Value&);
+ ~KeyboardState();
+ auto update() -> void;
+
+ private:
+ static auto openDevice(const std::string&) -> std::pair;
+
+ Gtk::Box box_;
+ Gtk::Label numlock_label_;
+ Gtk::Label capslock_label_;
+ Gtk::Label scrolllock_label_;
+
+ std::string numlock_format_;
+ std::string capslock_format_;
+ std::string scrolllock_format_;
+ const std::chrono::seconds interval_;
+ std::string icon_locked_;
+ std::string icon_unlocked_;
+
+ int fd_;
+ libevdev* dev_;
+
+ util::SleeperThread thread_;
+};
+
+} // namespace waybar::modules
diff --git a/include/modules/network.hpp b/include/modules/network.hpp
index 539f4583..009ae5a3 100644
--- a/include/modules/network.hpp
+++ b/include/modules/network.hpp
@@ -2,9 +2,7 @@
#include
#include
-#include
#include
-#include
#include
#include
#include
@@ -28,23 +26,20 @@ class Network : public ALabel {
static const uint8_t EPOLL_MAX = 200;
static int handleEvents(struct nl_msg*, void*);
+ static int handleEventsDone(struct nl_msg*, void*);
static int handleScan(struct nl_msg*, void*);
+ void askForStateDump(void);
+
void worker();
void createInfoSocket();
void createEventSocket();
- int getExternalInterface(int skip_idx = -1) const;
- void getInterfaceAddress();
- int netlinkRequest(void*, uint32_t, uint32_t groups = 0) const;
- int netlinkResponse(void*, uint32_t, uint32_t groups = 0) const;
void parseEssid(struct nlattr**);
void parseSignal(struct nlattr**);
void parseFreq(struct nlattr**);
bool associatedOrJoined(struct nlattr**);
- bool checkInterface(struct ifinfomsg* rtif, std::string name);
- int getPreferredIface(int skip_idx = -1, bool wait = true) const;
+ bool checkInterface(std::string name);
auto getInfo() -> void;
- void checkNewInterface(struct ifinfomsg* rtif);
const std::string getNetworkState() const;
void clearIface();
bool wildcardMatch(const std::string& pattern, const std::string& text) const;
@@ -59,11 +54,17 @@ class Network : public ALabel {
int nl80211_id_;
std::mutex mutex_;
+ bool want_route_dump_;
+ bool want_link_dump_;
+ bool want_addr_dump_;
+ bool dump_in_progress_;
+
unsigned long long bandwidth_down_total_;
unsigned long long bandwidth_up_total_;
std::string state_;
std::string essid_;
+ bool carrier_;
std::string ifname_;
std::string ipaddr_;
std::string netmask_;
@@ -71,6 +72,7 @@ class Network : public ALabel {
int32_t signal_strength_dbm_;
uint8_t signal_strength_;
uint32_t frequency_;
+ uint32_t route_priority;
util::SleeperThread thread_;
util::SleeperThread thread_timer_;
diff --git a/include/modules/pulseaudio.hpp b/include/modules/pulseaudio.hpp
index 5f17620a..99511b37 100644
--- a/include/modules/pulseaudio.hpp
+++ b/include/modules/pulseaudio.hpp
@@ -24,7 +24,7 @@ class Pulseaudio : public ALabel {
static void volumeModifyCb(pa_context*, int, void*);
bool handleScroll(GdkEventScroll* e);
- const std::string getPortIcon() const;
+ const std::vector getPulseIcon() const;
pa_threaded_mainloop* mainloop_;
pa_mainloop_api* mainloop_api_;
@@ -38,7 +38,8 @@ class Pulseaudio : public ALabel {
std::string form_factor_;
std::string desc_;
std::string monitor_;
- std::string default_sink_name_;
+ std::string current_sink_name_;
+ bool current_sink_running_;
// SOURCE
uint32_t source_idx_{0};
uint16_t source_volume_;
diff --git a/include/modules/river/tags.hpp b/include/modules/river/tags.hpp
index f80b3c59..9b75fbd3 100644
--- a/include/modules/river/tags.hpp
+++ b/include/modules/river/tags.hpp
@@ -18,6 +18,7 @@ class Tags : public waybar::AModule {
// Handlers for wayland events
void handle_focused_tags(uint32_t tags);
void handle_view_tags(struct wl_array *tags);
+ void handle_urgent_tags(uint32_t tags);
struct zriver_status_manager_v1 *status_manager_;
diff --git a/include/modules/sni/host.hpp b/include/modules/sni/host.hpp
index f97900fd..8d321036 100644
--- a/include/modules/sni/host.hpp
+++ b/include/modules/sni/host.hpp
@@ -5,13 +5,15 @@
#include
#include
#include
+#include "bar.hpp"
#include "modules/sni/item.hpp"
namespace waybar::modules::SNI {
class Host {
public:
- Host(const std::size_t id, const Json::Value&, const std::function&)>&,
+ Host(const std::size_t id, const Json::Value&, const Bar&,
+ const std::function&)>&,
const std::function&)>&);
~Host();
@@ -36,6 +38,7 @@ class Host {
GCancellable* cancellable_ = nullptr;
SnWatcher* watcher_ = nullptr;
const Json::Value& config_;
+ const Bar& bar_;
const std::function&)> on_add_;
const std::function&)> on_remove_;
};
diff --git a/include/modules/sni/item.hpp b/include/modules/sni/item.hpp
index 3cbd0b74..430c351c 100644
--- a/include/modules/sni/item.hpp
+++ b/include/modules/sni/item.hpp
@@ -11,11 +11,21 @@
#include
#include
+#include
+#include
+
+#include "bar.hpp"
+
namespace waybar::modules::SNI {
+struct ToolTip {
+ Glib::ustring icon_name;
+ Glib::ustring text;
+};
+
class Item : public sigc::trackable {
public:
- Item(const std::string&, const std::string&, const Json::Value&);
+ Item(const std::string&, const std::string&, const Json::Value&, const Bar&);
~Item() = default;
std::string bus_name;
@@ -27,10 +37,8 @@ class Item : public sigc::trackable {
Gtk::EventBox event_box;
std::string category;
std::string id;
- std::string status;
std::string title;
- int32_t window_id;
std::string icon_name;
Glib::RefPtr icon_pixmap;
Glib::RefPtr icon_theme;
@@ -39,6 +47,7 @@ class Item : public sigc::trackable {
std::string attention_movie_name;
std::string icon_theme_path;
std::string menu;
+ ToolTip tooltip;
DbusmenuGtkMenu* dbus_menu = nullptr;
Gtk::Menu* gtk_menu = nullptr;
/**
@@ -49,8 +58,10 @@ class Item : public sigc::trackable {
bool item_is_menu = true;
private:
+ void onConfigure(GdkEventConfigure* ev);
void proxyReady(Glib::RefPtr& result);
void setProperty(const Glib::ustring& name, Glib::VariantBase& value);
+ void setStatus(const Glib::ustring& value);
void getUpdatedProperties();
void processUpdatedProperties(Glib::RefPtr& result);
void onSignal(const Glib::ustring& sender_name, const Glib::ustring& signal_name,
@@ -58,14 +69,24 @@ class Item : public sigc::trackable {
void updateImage();
Glib::RefPtr extractPixBuf(GVariant* variant);
+ Glib::RefPtr getIconPixbuf();
Glib::RefPtr getIconByName(const std::string& name, int size);
+ double getScaledIconSize();
static void onMenuDestroyed(Item* self, GObject* old_menu_pointer);
void makeMenu();
bool handleClick(GdkEventButton* const& /*ev*/);
+ bool handleScroll(GdkEventScroll* const&);
+
+ // smooth scrolling threshold
+ gdouble scroll_threshold_ = 0;
+ gdouble distance_scrolled_x_ = 0;
+ gdouble distance_scrolled_y_ = 0;
+ // visibility of items with Status == Passive
+ bool show_passive_ = false;
Glib::RefPtr proxy_;
Glib::RefPtr cancellable_;
- bool update_pending_;
+ std::set update_pending_;
};
} // namespace waybar::modules::SNI
diff --git a/include/modules/sway/ipc/ipc.hpp b/include/modules/sway/ipc/ipc.hpp
index 2c5a7a6e..5f23d172 100644
--- a/include/modules/sway/ipc/ipc.hpp
+++ b/include/modules/sway/ipc/ipc.hpp
@@ -29,4 +29,8 @@ enum ipc_command_type {
IPC_EVENT_BINDING = ((1 << 31) | 5),
IPC_EVENT_SHUTDOWN = ((1 << 31) | 6),
IPC_EVENT_TICK = ((1 << 31) | 7),
+
+ // sway-specific event types
+ IPC_EVENT_BAR_STATE_UPDATE = ((1<<31) | 20),
+ IPC_EVENT_INPUT = ((1<<31) | 21),
};
diff --git a/include/modules/sway/language.hpp b/include/modules/sway/language.hpp
index 7cd6bf62..1faf52b3 100644
--- a/include/modules/sway/language.hpp
+++ b/include/modules/sway/language.hpp
@@ -1,6 +1,11 @@
#pragma once
#include
+#include
+
+#include