Merge branch 'master' into fix-missing-docs
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
- River (Mapping mode, Tags, Focused window name)
|
||||
- Hyprland (Window Icons, Workspaces, Focused window name)
|
||||
- Niri (Workspaces, Focused window name, Language)
|
||||
- Mango (Workspaces, Focused window name, Language, Keymode)
|
||||
- DWL (Tags, Focused window name) [requires dwl ipc patch](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/ipc)
|
||||
- Tray [#21](https://github.com/Alexays/Waybar/issues/21)
|
||||
- Local time
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
#pragma once
|
||||
|
||||
#include <glibmm/markup.h>
|
||||
#include <gtkmm/label.h>
|
||||
#include <json/json.h>
|
||||
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
|
||||
#include "AModule.hpp"
|
||||
|
||||
namespace waybar {
|
||||
|
||||
enum class GraphType { LINE, BAR, GAUGE };
|
||||
|
||||
class AGraph : public AModule {
|
||||
public:
|
||||
AGraph(const Json::Value&, const std::string&, const std::string&, uint16_t interval = 0,
|
||||
bool enable_click = false, bool enable_scroll = false);
|
||||
virtual ~AGraph() = default;
|
||||
auto update() -> void override;
|
||||
|
||||
protected:
|
||||
Gtk::DrawingArea graph_;
|
||||
std::deque<int> values_;
|
||||
uint16_t datapoints_ = 20;
|
||||
GraphType graph_type_ = GraphType::LINE;
|
||||
|
||||
void addValue(const int n);
|
||||
|
||||
const std::chrono::seconds interval_;
|
||||
|
||||
bool onDraw(const Cairo::RefPtr<Cairo::Context>& cr);
|
||||
|
||||
std::map<std::string, GtkMenuItem*> submenus_;
|
||||
std::map<std::string, std::string> menuActionsMap_;
|
||||
static void handleGtkMenuEvent(GtkMenuItem* menuitem, gpointer data);
|
||||
|
||||
private:
|
||||
void drawFilledArea(const Cairo::RefPtr<Cairo::Context>& cr,
|
||||
const std::vector<std::pair<double, double>>& points, double height,
|
||||
const Gdk::RGBA& bg_color);
|
||||
|
||||
void drawLine(const Cairo::RefPtr<Cairo::Context>& cr,
|
||||
const std::vector<std::pair<double, double>>& points, const Gdk::RGBA& fg_color);
|
||||
|
||||
void drawPath(const Cairo::RefPtr<Cairo::Context>& cr,
|
||||
const std::vector<std::pair<double, double>>& points);
|
||||
|
||||
void drawBars(const Cairo::RefPtr<Cairo::Context>& cr, double width, double height,
|
||||
int current_value, const Gdk::RGBA& fg_color);
|
||||
|
||||
void drawGauge(const Cairo::RefPtr<Cairo::Context>& cr, double width, double height,
|
||||
int current_value, const Gdk::RGBA& fg_color);
|
||||
};
|
||||
|
||||
} // namespace waybar
|
||||
@@ -14,10 +14,14 @@ class AIconLabel : public ALabel {
|
||||
bool enable_click = false, bool enable_scroll = false);
|
||||
virtual ~AIconLabel() = default;
|
||||
auto update() -> void override;
|
||||
static std::tuple<std::string, std::string> extractIcon(const std::string& input);
|
||||
|
||||
protected:
|
||||
Gtk::Image image_;
|
||||
Gtk::Box box_;
|
||||
unsigned app_icon_size_{24};
|
||||
|
||||
bool label_contains_icon{false};
|
||||
|
||||
bool iconEnabled() const;
|
||||
};
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <gtkmm/label.h>
|
||||
#include <json/json.h>
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include "AModule.hpp"
|
||||
|
||||
namespace waybar {
|
||||
@@ -25,12 +27,20 @@ class ALabel : public AModule {
|
||||
bool alt_ = false;
|
||||
std::string default_format_;
|
||||
|
||||
bool setLabelMarkup(const Glib::ustring& markup);
|
||||
bool setTooltipMarkup(const Glib::ustring& markup);
|
||||
|
||||
bool handleToggle(GdkEventButton* const& e) override;
|
||||
void copyToClipboard(const std::string&);
|
||||
virtual std::string getState(uint8_t value, bool lesser = false);
|
||||
|
||||
std::map<std::string, GtkMenuItem*> submenus_;
|
||||
std::map<std::string, std::string> menuActionsMap_;
|
||||
static void handleGtkMenuEvent(GtkMenuItem* menuitem, gpointer data);
|
||||
|
||||
private:
|
||||
std::optional<Glib::ustring> last_label_markup_;
|
||||
std::optional<Glib::ustring> last_tooltip_markup_;
|
||||
};
|
||||
|
||||
} // namespace waybar
|
||||
|
||||
+10
-2
@@ -25,6 +25,10 @@ class AModule : public IModule {
|
||||
|
||||
bool expandEnabled() const;
|
||||
|
||||
virtual void suspend() {};
|
||||
virtual void resume() {};
|
||||
bool shouldSuspend() const { return disable_on_sleep_; }
|
||||
|
||||
protected:
|
||||
// Don't need to make an object directly
|
||||
// Derived classes are able to use it
|
||||
@@ -41,13 +45,15 @@ class AModule : public IModule {
|
||||
const Json::Value& config_;
|
||||
Gtk::EventBox event_box_;
|
||||
|
||||
virtual void setCursor(Gdk::CursorType const& c);
|
||||
virtual void setCursor(std::string const& c);
|
||||
|
||||
virtual bool handleToggle(GdkEventButton* const& ev);
|
||||
virtual bool handleMouseEnter(GdkEventCrossing* const& ev);
|
||||
virtual bool handleMouseLeave(GdkEventCrossing* const& ev);
|
||||
virtual bool handleScroll(GdkEventScroll*);
|
||||
virtual bool handleRelease(GdkEventButton* const& ev);
|
||||
|
||||
bool disable_on_sleep_{false};
|
||||
GObject* menu_ = nullptr;
|
||||
|
||||
private:
|
||||
@@ -57,6 +63,7 @@ class AModule : public IModule {
|
||||
bool hasUserEvents_;
|
||||
gdouble distance_scrolled_y_;
|
||||
gdouble distance_scrolled_x_;
|
||||
sigc::connection cursor_timeout_conn_;
|
||||
std::map<std::string, std::string> eventActionMap_;
|
||||
static const inline std::map<std::pair<uint, GdkEventType>, std::string> eventMap_{
|
||||
{std::make_pair(1, GdkEventType::GDK_BUTTON_PRESS), "on-click"},
|
||||
@@ -78,7 +85,8 @@ class AModule : public IModule {
|
||||
{std::make_pair(9, GdkEventType::GDK_BUTTON_PRESS), "on-click-forward"},
|
||||
{std::make_pair(9, GdkEventType::GDK_BUTTON_RELEASE), "on-click-forward-release"},
|
||||
{std::make_pair(9, GdkEventType::GDK_2BUTTON_PRESS), "on-double-click-forward"},
|
||||
{std::make_pair(9, GdkEventType::GDK_3BUTTON_PRESS), "on-triple-click-forward"}};
|
||||
{std::make_pair(9, GdkEventType::GDK_3BUTTON_PRESS), "on-triple-click-forward"},
|
||||
{std::make_pair(10, GdkEventType::GDK_BUTTON_PRESS), "on-click-copy"}};
|
||||
};
|
||||
|
||||
} // namespace waybar
|
||||
|
||||
@@ -75,6 +75,8 @@ class Bar : public sigc::trackable {
|
||||
util::KillSignalAction getOnSigusr1Action();
|
||||
util::KillSignalAction getOnSigusr2Action();
|
||||
|
||||
void toggleSuspend(bool suspend);
|
||||
|
||||
struct waybar_output* output;
|
||||
Json::Value config;
|
||||
struct wl_surface* surface;
|
||||
@@ -99,6 +101,7 @@ class Bar : public sigc::trackable {
|
||||
void setMode(const bar_mode&);
|
||||
void setPassThrough(bool passthrough);
|
||||
void setPosition(Gtk::PositionType position);
|
||||
void forceLayerCommit();
|
||||
void onConfigure(GdkEventConfigure* ev);
|
||||
void configureGlobalOffset(int width, int height);
|
||||
void onOutputGeometryChanged();
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
struct zwp_idle_inhibitor_v1;
|
||||
struct zwp_idle_inhibit_manager_v1;
|
||||
struct ext_idle_notifier_v1;
|
||||
|
||||
namespace waybar {
|
||||
|
||||
@@ -27,6 +28,7 @@ class Client {
|
||||
struct wl_registry* registry = nullptr;
|
||||
struct zxdg_output_manager_v1* xdg_output_manager = nullptr;
|
||||
struct zwp_idle_inhibit_manager_v1* idle_inhibit_manager = nullptr;
|
||||
struct ext_idle_notifier_v1* idle_notifier = nullptr;
|
||||
std::vector<std::unique_ptr<Bar>> bars;
|
||||
Config config;
|
||||
std::string bar_id;
|
||||
@@ -44,6 +46,7 @@ class Client {
|
||||
const char* interface, uint32_t version);
|
||||
static void handleGlobalRemove(void* data, struct wl_registry* registry, uint32_t name);
|
||||
static void handleOutputDone(void*, struct zxdg_output_v1*);
|
||||
void createBarsBatch();
|
||||
static void handleOutputName(void*, struct zxdg_output_v1*, const char*);
|
||||
static void handleOutputDescription(void*, struct zxdg_output_v1*, const char*);
|
||||
void handleMonitorAdded(Glib::RefPtr<Gdk::Monitor> monitor);
|
||||
@@ -58,6 +61,8 @@ class Client {
|
||||
std::string m_cssFile;
|
||||
sigc::connection monitor_added_connection_;
|
||||
sigc::connection monitor_removed_connection_;
|
||||
std::list<waybar_output*> pending_outputs_;
|
||||
bool bars_scheduled_ = false;
|
||||
};
|
||||
|
||||
} // namespace waybar
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
namespace waybar {
|
||||
|
||||
class Group : public AModule {
|
||||
sigc::connection reveal_timeout_;
|
||||
|
||||
public:
|
||||
Group(const std::string&, const std::string&, const Json::Value&, bool);
|
||||
~Group() override = default;
|
||||
@@ -26,6 +28,7 @@ class Group : public AModule {
|
||||
bool is_first_widget = true;
|
||||
bool is_drawer = false;
|
||||
bool click_to_reveal = false;
|
||||
int reveal_delay = 0;
|
||||
std::string add_class_to_drawer_children;
|
||||
bool handleMouseEnter(GdkEventCrossing* const& ev) override;
|
||||
bool handleMouseLeave(GdkEventCrossing* const& ev) override;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <poll.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -51,6 +52,11 @@ class Battery : public ALabel {
|
||||
bool warnFirstTime_{true};
|
||||
bool weightedAverage_{true};
|
||||
const Bar& bar_;
|
||||
bool smoothPowerEnable_{false};
|
||||
double time_constant_s_{260.0};
|
||||
double smooth_power_{0.0}; // µW
|
||||
std::chrono::steady_clock::time_point last_t_{std::chrono::steady_clock::now()};
|
||||
std::string old_status_raw_{""};
|
||||
|
||||
util::SleeperThread thread_;
|
||||
util::SleeperThread thread_battery_update_;
|
||||
|
||||
@@ -41,6 +41,7 @@ class Bluetooth : public ALabel {
|
||||
bool services_resolved;
|
||||
// NOTE: experimental feature in bluez
|
||||
std::optional<unsigned char> battery_percentage;
|
||||
std::optional<unsigned char> battery_percentage_peripheral;
|
||||
};
|
||||
|
||||
public:
|
||||
@@ -59,6 +60,12 @@ class Bluetooth : public ALabel {
|
||||
gpointer) -> void;
|
||||
|
||||
auto getDeviceBatteryPercentage(GDBusObject*) -> std::optional<unsigned char>;
|
||||
auto getDeviceGattBatteryLevels(GDBusObject*, std::optional<unsigned char>&,
|
||||
std::optional<unsigned char>&) -> void;
|
||||
static auto processBatteryServiceCharacteristics(GList*, const std::string&, const std::string&,
|
||||
const std::string&,
|
||||
std::optional<unsigned char>&,
|
||||
std::optional<unsigned char>&) -> void;
|
||||
auto getDeviceProperties(GDBusObject*, DeviceInfo&) -> bool;
|
||||
auto getControllerProperties(GDBusObject*, ControllerInfo&) -> bool;
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ class Clock final : public ALabel {
|
||||
void cldShift_reset();
|
||||
void tz_up();
|
||||
void tz_down();
|
||||
void action_exec(const std::string& action);
|
||||
// Module Action Map
|
||||
static inline std::map<const std::string, void (waybar::modules::Clock::* const)()> actionMap_{
|
||||
{"mode", &waybar::modules::Clock::cldModeSwitch},
|
||||
@@ -88,6 +89,9 @@ class Clock final : public ALabel {
|
||||
{"shift_reset", &waybar::modules::Clock::cldShift_reset},
|
||||
{"tz_up", &waybar::modules::Clock::tz_up},
|
||||
{"tz_down", &waybar::modules::Clock::tz_down}};
|
||||
static inline std::map<const std::string,
|
||||
void (waybar::modules::Clock::* const)(const std::string& action)>
|
||||
actionWithArgsMap_{{"exec", &waybar::modules::Clock::action_exec}};
|
||||
};
|
||||
|
||||
} // namespace waybar::modules
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
#include <numeric>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "AGraph.hpp"
|
||||
#include "util/sleeper_thread.hpp"
|
||||
|
||||
namespace waybar::modules {
|
||||
|
||||
class CpuGraph : public AGraph {
|
||||
public:
|
||||
CpuGraph(const std::string&, const Json::Value&);
|
||||
virtual ~CpuGraph() = default;
|
||||
auto update() -> void override;
|
||||
|
||||
private:
|
||||
static constexpr const char* MODERATE_CLASS = "cpu-moderate";
|
||||
static constexpr const char* HIGH_CLASS = "cpu-high";
|
||||
static constexpr const char* INTENSIVE_CLASS = "cpu-intensive";
|
||||
|
||||
std::vector<std::tuple<size_t, size_t>> prev_times_;
|
||||
util::SleeperThread thread_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules
|
||||
@@ -5,14 +5,14 @@
|
||||
#include <csignal>
|
||||
#include <string>
|
||||
|
||||
#include "ALabel.hpp"
|
||||
#include "AIconLabel.hpp"
|
||||
#include "util/command.hpp"
|
||||
#include "util/json.hpp"
|
||||
#include "util/sleeper_thread.hpp"
|
||||
|
||||
namespace waybar::modules {
|
||||
|
||||
class Custom : public ALabel {
|
||||
class Custom : public AIconLabel {
|
||||
public:
|
||||
Custom(const std::string&, const std::string&, const Json::Value&, const std::string&);
|
||||
virtual ~Custom();
|
||||
@@ -36,6 +36,9 @@ class Custom : public ALabel {
|
||||
std::string alt_;
|
||||
std::string tooltip_;
|
||||
std::string last_tooltip_markup_;
|
||||
std::string image_path_;
|
||||
std::string image_name_;
|
||||
unsigned app_icon_size_{24};
|
||||
const bool tooltip_format_enabled_;
|
||||
std::vector<std::string> class_;
|
||||
int percentage_;
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <csignal>
|
||||
#include <string>
|
||||
|
||||
#include "AGraph.hpp"
|
||||
#include "util/command.hpp"
|
||||
#include "util/json.hpp"
|
||||
#include "util/sleeper_thread.hpp"
|
||||
|
||||
namespace waybar::modules {
|
||||
|
||||
class CustomGraph : public AGraph {
|
||||
public:
|
||||
CustomGraph(const std::string&, const std::string&, const Json::Value&, const std::string&);
|
||||
virtual ~CustomGraph();
|
||||
auto update() -> void override;
|
||||
void refresh(int /*signal*/) override;
|
||||
|
||||
private:
|
||||
void delayWorker();
|
||||
void continuousWorker();
|
||||
void waitingWorker();
|
||||
void parseOutputRaw();
|
||||
void parseOutputJson();
|
||||
void handleEvent();
|
||||
bool handleScroll(GdkEventScroll* e) override;
|
||||
bool handleToggle(GdkEventButton* const& e) override;
|
||||
|
||||
const std::string name_;
|
||||
const std::string output_name_;
|
||||
std::string text_;
|
||||
std::string id_;
|
||||
std::string alt_;
|
||||
std::string tooltip_;
|
||||
const bool tooltip_format_enabled_;
|
||||
std::vector<std::string> class_;
|
||||
int percentage_;
|
||||
FILE* fp_;
|
||||
int pid_;
|
||||
util::command::res output_;
|
||||
util::JsonParser parser_;
|
||||
|
||||
util::SleeperThread thread_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <sys/statvfs.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
#include "ALabel.hpp"
|
||||
#include "util/format.hpp"
|
||||
@@ -19,7 +20,9 @@ class Disk : public ALabel {
|
||||
|
||||
private:
|
||||
util::SleeperThread thread_;
|
||||
std::string path_;
|
||||
std::string header_;
|
||||
std::vector<std::string> paths_;
|
||||
std::string separator_;
|
||||
std::string unit_;
|
||||
|
||||
float calc_specific_divisor(const std::string& divisor);
|
||||
|
||||
@@ -21,6 +21,8 @@ class Tags : public waybar::AModule {
|
||||
void handle_primary_clicked(uint32_t tag);
|
||||
bool handle_button_press(GdkEventButton* event_button, uint32_t tag);
|
||||
|
||||
void handle_active_output(zdwl_ipc_output_v2* zdwl_output_v2, uint32_t active);
|
||||
|
||||
struct zdwl_ipc_manager_v2* status_manager_;
|
||||
struct wl_seat* seat_;
|
||||
|
||||
@@ -28,6 +30,7 @@ class Tags : public waybar::AModule {
|
||||
const waybar::Bar& bar_;
|
||||
Gtk::Box box_;
|
||||
std::vector<Gtk::Button> buttons_;
|
||||
bool hide_vacant_;
|
||||
struct zdwl_ipc_output_v2* output_status_;
|
||||
};
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ class Window : public AAppIconLabel, public sigc::trackable {
|
||||
void handle_layout(const uint32_t layout);
|
||||
void handle_title(const char* title);
|
||||
void handle_appid(const char* ppid);
|
||||
void handle_active(const uint32_t active);
|
||||
void handle_layout_symbol(const char* layout_symbol);
|
||||
void handle_frame();
|
||||
|
||||
@@ -30,6 +31,9 @@ class Window : public AAppIconLabel, public sigc::trackable {
|
||||
std::string title_;
|
||||
std::string appid_;
|
||||
std::string layout_symbol_;
|
||||
bool active_;
|
||||
bool hide_inactive_;
|
||||
bool hide_empty_;
|
||||
uint32_t layout_;
|
||||
|
||||
struct zdwl_ipc_output_v2* output_status_;
|
||||
|
||||
@@ -30,6 +30,8 @@ class Language : public waybar::ALabel, public EventHandler {
|
||||
std::string short_description;
|
||||
};
|
||||
|
||||
auto removeXkbLayoutCssClass() -> void;
|
||||
auto addXkbLayoutCssClass() -> void;
|
||||
static auto getLayout(const std::string&) -> Layout;
|
||||
|
||||
std::mutex mutex_;
|
||||
|
||||
@@ -30,6 +30,7 @@ class Workspace {
|
||||
public:
|
||||
explicit Workspace(const Json::Value& workspace_data, Workspaces& workspace_manager,
|
||||
const Json::Value& clients_data = Json::Value::nullRef);
|
||||
~Workspace();
|
||||
std::string& selectIcon(std::map<std::string, std::string>& icons_map);
|
||||
Gtk::Button& button() { return m_button; };
|
||||
|
||||
@@ -45,6 +46,15 @@ class Workspace {
|
||||
bool isUrgent() const { return m_isUrgent; };
|
||||
|
||||
bool handleClicked(GdkEventButton* bt) const;
|
||||
|
||||
bool handleEnter(GdkEventCrossing* event);
|
||||
bool handleLeave(GdkEventCrossing* event);
|
||||
|
||||
void startHoverCheck();
|
||||
void stopHoverCheck();
|
||||
bool syncHoverClass();
|
||||
bool pointerInsideButton();
|
||||
|
||||
void setActive(bool value = true) { m_isActive = value; };
|
||||
void setPersistentRule(bool value = true) { m_isPersistentRule = value; };
|
||||
void setPersistentConfig(bool value = true) { m_isPersistentConfig = value; };
|
||||
@@ -71,6 +81,7 @@ class Workspace {
|
||||
|
||||
int m_id;
|
||||
std::string m_name;
|
||||
std::string m_prevNameClass;
|
||||
std::string m_output;
|
||||
uint m_windows;
|
||||
bool m_isActive = false;
|
||||
@@ -80,6 +91,8 @@ class Workspace {
|
||||
bool m_isUrgent = false;
|
||||
bool m_isVisible = false;
|
||||
|
||||
sigc::connection m_hoverCheckConnection;
|
||||
|
||||
std::vector<WindowRepr> m_windowMap;
|
||||
|
||||
Gtk::Button m_button;
|
||||
|
||||
@@ -39,6 +39,7 @@ class Workspaces : public AModule, public EventHandler {
|
||||
auto allOutputs() const -> bool { return m_allOutputs; }
|
||||
auto showSpecial() const -> bool { return m_showSpecial; }
|
||||
auto activeOnly() const -> bool { return m_activeOnly; }
|
||||
auto hideActive() const -> bool { return m_hideActive; }
|
||||
auto specialVisibleOnly() const -> bool { return m_specialVisibleOnly; }
|
||||
auto persistentOnly() const -> bool { return m_persistentOnly; }
|
||||
auto moveToMonitor() const -> bool { return m_moveToMonitor; }
|
||||
@@ -56,12 +57,15 @@ class Workspaces : public AModule, public EventHandler {
|
||||
auto taskbarReverseDirection() const -> bool { return m_taskbarReverseDirection; }
|
||||
auto onClickWindow() const -> std::string { return m_onClickWindow; }
|
||||
auto getIgnoredWindows() const -> std::vector<std::regex> { return m_ignoreWindows; }
|
||||
auto maxWindows() const -> int { return m_maxWindows; }
|
||||
|
||||
enum class ActiveWindowPosition { NONE, FIRST, LAST };
|
||||
auto activeWindowPosition() const -> ActiveWindowPosition { return m_activeWindowPosition; }
|
||||
|
||||
std::string getRewrite(const std::string& window_class, const std::string& window_title);
|
||||
std::string& getWindowSeparator() { return m_formatWindowSeparator; }
|
||||
auto windowRewriteGroupThreshold() const -> int { return m_windowRewriteGroupThreshold; }
|
||||
auto const& getWindowRewriteGroupFormat() const { return m_windowRewriteGroupFormat; }
|
||||
bool isWorkspaceIgnored(std::string const& workspace_name);
|
||||
|
||||
bool windowRewriteConfigUsesTitle() const { return m_anyWindowRewriteRuleUsesTitle; }
|
||||
@@ -89,6 +93,7 @@ class Workspaces : public AModule, public EventHandler {
|
||||
auto populateIgnoreWorkspacesConfig(const Json::Value& config) -> void;
|
||||
auto populateFormatWindowSeparatorConfig(const Json::Value& config) -> void;
|
||||
auto populateWindowRewriteConfig(const Json::Value& config) -> void;
|
||||
auto populateMaxWindowsConfig(const Json::Value& config) -> void;
|
||||
auto populateWorkspaceTaskbarConfig(const Json::Value& config) -> void;
|
||||
|
||||
void registerIpc();
|
||||
@@ -146,6 +151,7 @@ class Workspaces : public AModule, public EventHandler {
|
||||
bool m_allOutputs = false;
|
||||
bool m_showSpecial = false;
|
||||
bool m_activeOnly = false;
|
||||
bool m_hideActive = false;
|
||||
bool m_specialVisibleOnly = false;
|
||||
bool m_persistentOnly = false;
|
||||
bool m_moveToMonitor = false;
|
||||
@@ -173,6 +179,8 @@ class Workspaces : public AModule, public EventHandler {
|
||||
util::RegexCollection m_windowRewriteRules;
|
||||
bool m_anyWindowRewriteRuleUsesTitle = false;
|
||||
std::string m_formatWindowSeparator;
|
||||
int m_windowRewriteGroupThreshold = 0;
|
||||
std::string m_windowRewriteGroupFormat = "{icon}×{count}";
|
||||
|
||||
bool m_withIcon;
|
||||
uint64_t m_monitorId;
|
||||
@@ -202,6 +210,7 @@ class Workspaces : public AModule, public EventHandler {
|
||||
};
|
||||
std::string m_onClickWindow;
|
||||
std::string m_currentActiveWindowAddress;
|
||||
int m_maxWindows = 0;
|
||||
|
||||
std::vector<std::regex> m_ignoreWorkspaces;
|
||||
std::vector<std::regex> m_ignoreWindows;
|
||||
|
||||
@@ -6,25 +6,35 @@
|
||||
#include "bar.hpp"
|
||||
#include "client.hpp"
|
||||
|
||||
struct ext_idle_notification_v1;
|
||||
|
||||
namespace waybar::modules {
|
||||
|
||||
class IdleInhibitor : public ALabel {
|
||||
sigc::connection timeout_;
|
||||
ext_idle_notification_v1* idle_notification_;
|
||||
uint32_t idle_timeout_ms_;
|
||||
|
||||
public:
|
||||
IdleInhibitor(const std::string&, const waybar::Bar&, const Json::Value&);
|
||||
virtual ~IdleInhibitor();
|
||||
auto update() -> void override;
|
||||
auto refresh(int) -> void override;
|
||||
static std::list<waybar::AModule*> modules;
|
||||
static bool status;
|
||||
|
||||
private:
|
||||
bool handleToggle(GdkEventButton* const& e) override;
|
||||
void toggleStatus();
|
||||
void setupIdleNotification();
|
||||
void teardownIdleNotification();
|
||||
static void handleIdled(void* data, ext_idle_notification_v1* notification);
|
||||
static void handleResumed(void* data, ext_idle_notification_v1* notification);
|
||||
|
||||
const Bar& bar_;
|
||||
struct zwp_idle_inhibitor_v1* idle_inhibitor_;
|
||||
int pid_;
|
||||
bool wait_for_activity_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules
|
||||
|
||||
@@ -36,8 +36,7 @@ class KeyboardState : public AModule {
|
||||
std::string capslock_format_;
|
||||
std::string scrolllock_format_;
|
||||
const std::chrono::seconds interval_;
|
||||
std::string icon_locked_;
|
||||
std::string icon_unlocked_;
|
||||
std::unordered_map<std::string, std::vector<std::string>> key_icon_states_;
|
||||
std::string devices_path_;
|
||||
|
||||
struct libinput* libinput_;
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
// include/modules/mango/backend.hpp
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "util/json.hpp"
|
||||
|
||||
namespace waybar::modules::mango {
|
||||
|
||||
class EventHandler {
|
||||
public:
|
||||
virtual void onEvent(const Json::Value& ev) = 0;
|
||||
virtual ~EventHandler() = default;
|
||||
};
|
||||
|
||||
class IPC {
|
||||
public:
|
||||
static IPC& getInstance();
|
||||
IPC(const IPC&) = delete;
|
||||
IPC& operator=(const IPC&) = delete;
|
||||
|
||||
void registerForIPC(const std::string& ev, EventHandler* handler);
|
||||
void unregisterForIPC(EventHandler* handler);
|
||||
|
||||
static Json::Value send(const Json::Value& request);
|
||||
static void sendAsync(const Json::Value& request);
|
||||
|
||||
std::unique_lock<std::mutex> lockData() { return std::unique_lock<std::mutex>(data_mutex_); }
|
||||
|
||||
std::unordered_map<std::string, Json::Value> getMonitors() const;
|
||||
Json::Value getMonitor(const std::string& name);
|
||||
Json::Value getActiveClientForMonitor(const std::string& name) const;
|
||||
std::string getKeyboardLayout() const;
|
||||
std::string getKeymode() const;
|
||||
std::string getLayoutSymbolForMonitor(const std::string& name) const;
|
||||
|
||||
private:
|
||||
IPC();
|
||||
~IPC();
|
||||
void startIPC();
|
||||
static int connectToSocket();
|
||||
void parseIPC(const std::string& line);
|
||||
|
||||
void handleMonitorUpdate(const Json::Value& mon);
|
||||
void updateFocusingClient(const Json::Value& client);
|
||||
void updateKeyboardLayout(const std::string& layout);
|
||||
|
||||
static Json::Value sendCommand(const std::string& cmd);
|
||||
|
||||
int sockfd_ = -1;
|
||||
std::thread ipc_thread_;
|
||||
mutable std::mutex data_mutex_;
|
||||
std::unordered_map<std::string, Json::Value> monitors_;
|
||||
std::unordered_map<uint64_t, Json::Value> clients_;
|
||||
uint64_t focusing_client_id_ = 0;
|
||||
std::string keyboard_layout_;
|
||||
std::string keymode_;
|
||||
Json::Value active_client_;
|
||||
std::mutex callback_mutex_;
|
||||
std::list<std::pair<std::string, EventHandler*>> callbacks_;
|
||||
};
|
||||
} // namespace waybar::modules::mango
|
||||
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
#include "ALabel.hpp"
|
||||
#include "bar.hpp"
|
||||
#include "modules/mango/backend.hpp"
|
||||
|
||||
namespace waybar::modules::mango {
|
||||
|
||||
class Keymode : public ALabel, public EventHandler {
|
||||
public:
|
||||
Keymode(const std::string&, const Bar&, const Json::Value&);
|
||||
~Keymode() override;
|
||||
void update() override;
|
||||
|
||||
private:
|
||||
void onEvent(const Json::Value& ev) override;
|
||||
void doUpdate();
|
||||
|
||||
std::mutex mutex_;
|
||||
const Bar& bar_;
|
||||
std::string last_keymode_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::mango
|
||||
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include <xkbcommon/xkbregistry.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "ALabel.hpp"
|
||||
#include "bar.hpp"
|
||||
#include "modules/mango/backend.hpp"
|
||||
|
||||
namespace waybar::modules::mango {
|
||||
|
||||
class Language : public ALabel, public EventHandler {
|
||||
public:
|
||||
Language(const std::string&, const Bar&, const Json::Value&);
|
||||
~Language() override;
|
||||
void update() override;
|
||||
|
||||
private:
|
||||
void updateFromIPC();
|
||||
void onEvent(const Json::Value& ev) override;
|
||||
void doUpdate();
|
||||
|
||||
struct Layout {
|
||||
std::string full_name;
|
||||
std::string short_name;
|
||||
std::string variant;
|
||||
std::string short_description;
|
||||
};
|
||||
|
||||
Layout getLayout(const std::string& fullName);
|
||||
|
||||
std::mutex mutex_;
|
||||
const Bar& bar_;
|
||||
|
||||
std::vector<Layout> layouts_;
|
||||
unsigned current_idx_;
|
||||
std::string last_short_name_;
|
||||
|
||||
struct rxkb_context* rxkb_ctx_ = nullptr;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::mango
|
||||
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
#include "ALabel.hpp"
|
||||
#include "bar.hpp"
|
||||
#include "modules/mango/backend.hpp"
|
||||
|
||||
namespace waybar::modules::mango {
|
||||
|
||||
class Layout : public ALabel, public EventHandler {
|
||||
public:
|
||||
Layout(const std::string&, const Bar&, const Json::Value&);
|
||||
~Layout() override;
|
||||
void update() override;
|
||||
|
||||
private:
|
||||
void onEvent(const Json::Value& ev) override;
|
||||
void doUpdate();
|
||||
|
||||
std::mutex mutex_;
|
||||
const Bar& bar_;
|
||||
std::string last_symbol_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::mango
|
||||
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <gtkmm/button.h>
|
||||
#include <json/value.h>
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include "AAppIconLabel.hpp"
|
||||
#include "bar.hpp"
|
||||
#include "modules/mango/backend.hpp"
|
||||
|
||||
namespace waybar::modules::mango {
|
||||
|
||||
class Window : public AAppIconLabel, public EventHandler {
|
||||
public:
|
||||
Window(const std::string&, const Bar&, const Json::Value&);
|
||||
~Window() override;
|
||||
void update() override;
|
||||
|
||||
private:
|
||||
void onEvent(const Json::Value& ev) override;
|
||||
void doUpdate();
|
||||
void setClass(const std::string& className, bool enable);
|
||||
|
||||
const Bar& bar_;
|
||||
std::string oldAppId_;
|
||||
std::mutex mutex_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::mango
|
||||
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include <gtkmm/button.h>
|
||||
#include <json/value.h>
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include "AModule.hpp"
|
||||
#include "bar.hpp"
|
||||
#include "modules/mango/backend.hpp"
|
||||
|
||||
namespace waybar::modules::mango {
|
||||
|
||||
class Workspaces : public AModule, public EventHandler {
|
||||
public:
|
||||
Workspaces(const std::string&, const Bar&, const Json::Value&);
|
||||
~Workspaces() override;
|
||||
void update() override;
|
||||
|
||||
private:
|
||||
void onEvent(const Json::Value& ev) override;
|
||||
void doUpdate();
|
||||
|
||||
Gtk::Button& addButton(uint64_t idx);
|
||||
void updateButtonState(Gtk::Button& button, const Json::Value& tag, const Json::Value& monitor);
|
||||
std::string getIcon(const std::string& value, const Json::Value& tag);
|
||||
bool handleButtonClick(GdkEventButton* event, uint64_t idx, bool isOverview);
|
||||
|
||||
const Bar& bar_;
|
||||
Gtk::Box box_;
|
||||
|
||||
std::unordered_map<uint64_t, Gtk::Button> buttons_;
|
||||
Gtk::Button* overview_button_ = nullptr;
|
||||
|
||||
std::string on_click_left_;
|
||||
std::string on_click_middle_;
|
||||
std::string on_click_right_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::mango
|
||||
@@ -19,8 +19,6 @@ class Memory : public ALabel {
|
||||
private:
|
||||
void parseMeminfo();
|
||||
|
||||
static float calc_divisor(const std::string& divisor);
|
||||
|
||||
std::unordered_map<std::string, unsigned long> meminfo_;
|
||||
|
||||
util::SleeperThread thread_;
|
||||
|
||||
@@ -28,11 +28,14 @@ class MPD : public ALabel {
|
||||
|
||||
unsigned timeout_;
|
||||
|
||||
unsigned playing_interval_;
|
||||
|
||||
detail::unique_connection connection_;
|
||||
|
||||
detail::unique_status status_;
|
||||
mpd_state state_;
|
||||
detail::unique_song song_;
|
||||
std::string ellipsis_;
|
||||
|
||||
public:
|
||||
MPD(const std::string&, const Json::Value&);
|
||||
@@ -45,6 +48,10 @@ class MPD : public ALabel {
|
||||
void setLabel();
|
||||
std::string getStateIcon() const;
|
||||
std::string getOptionIcon(const std::string& optionName, bool activated) const;
|
||||
std::string getArtistStr(bool truncated) const;
|
||||
std::string getAlbumArtistStr(bool truncated) const;
|
||||
std::string getAlbumStr(bool truncated) const;
|
||||
std::string getTitleStr(bool truncated) const;
|
||||
|
||||
// GUI-side methods
|
||||
bool handlePlayPause(GdkEventButton* const&);
|
||||
@@ -54,11 +61,11 @@ class MPD : public ALabel {
|
||||
void tryConnect();
|
||||
void checkErrors(mpd_connection* conn);
|
||||
void fetchState();
|
||||
void queryMPD();
|
||||
|
||||
inline bool stopped() const { return connection_ && state_ == MPD_STATE_STOP; }
|
||||
inline bool playing() const { return connection_ && state_ == MPD_STATE_PLAY; }
|
||||
inline bool paused() const { return connection_ && state_ == MPD_STATE_PAUSE; }
|
||||
inline unsigned playing_interval() const { return playing_interval_; }
|
||||
};
|
||||
|
||||
#if !defined(MPD_NOINLINE)
|
||||
|
||||
@@ -82,6 +82,7 @@ class Idle : public State {
|
||||
class Playing : public State {
|
||||
Context* const ctx_;
|
||||
sigc::connection timer_connection_;
|
||||
sigc::connection idle_connection_;
|
||||
|
||||
public:
|
||||
Playing(Context* const ctx) : ctx_{ctx} {}
|
||||
@@ -98,7 +99,10 @@ class Playing : public State {
|
||||
Playing(Playing const&) = delete;
|
||||
Playing& operator=(Playing const&) = delete;
|
||||
|
||||
void timer() noexcept;
|
||||
void idle() noexcept;
|
||||
bool on_timer();
|
||||
bool on_io(Glib::IOCondition const&);
|
||||
};
|
||||
|
||||
class Paused : public State {
|
||||
@@ -194,10 +198,10 @@ class Context {
|
||||
bool is_paused() const;
|
||||
bool is_stopped() const;
|
||||
constexpr std::size_t interval() const;
|
||||
unsigned playing_interval() const;
|
||||
void tryConnect() const;
|
||||
void checkErrors(mpd_connection*) const;
|
||||
void do_update();
|
||||
void queryMPD() const;
|
||||
void fetchState() const;
|
||||
constexpr mpd_state state() const;
|
||||
void emit() const;
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
namespace detail {
|
||||
using namespace std::literals::chrono_literals;
|
||||
|
||||
inline bool Context::is_connected() const { return mpd_module_->connection_ != nullptr; }
|
||||
inline bool Context::is_playing() const { return mpd_module_->playing(); }
|
||||
inline bool Context::is_paused() const { return mpd_module_->paused(); }
|
||||
inline bool Context::is_stopped() const { return mpd_module_->stopped(); }
|
||||
|
||||
constexpr inline std::size_t Context::interval() const { return mpd_module_->interval_.count(); }
|
||||
constexpr inline std::size_t Context::interval() const { return mpd_module_->interval_ / 1s; }
|
||||
inline unsigned Context::playing_interval() const { return mpd_module_->playing_interval(); }
|
||||
inline void Context::tryConnect() const { mpd_module_->tryConnect(); }
|
||||
inline unique_connection& Context::connection() { return mpd_module_->connection_; }
|
||||
constexpr inline mpd_state Context::state() const { return mpd_module_->state_; }
|
||||
@@ -15,7 +17,6 @@ constexpr inline mpd_state Context::state() const { return mpd_module_->state_;
|
||||
inline void Context::do_update() { mpd_module_->setLabel(); }
|
||||
|
||||
inline void Context::checkErrors(mpd_connection* conn) const { mpd_module_->checkErrors(conn); }
|
||||
inline void Context::queryMPD() const { mpd_module_->queryMPD(); }
|
||||
inline void Context::fetchState() const { mpd_module_->fetchState(); }
|
||||
inline void Context::emit() const { mpd_module_->emit(); }
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ class Mpris : public ALabel {
|
||||
|
||||
std::optional<std::string> artist;
|
||||
std::optional<std::string> album;
|
||||
std::optional<std::string> album_artist;
|
||||
std::optional<std::string> title;
|
||||
std::optional<std::string> length; // as HH:MM:SS
|
||||
std::optional<std::string> position; // same format
|
||||
@@ -76,6 +77,8 @@ class Mpris : public ALabel {
|
||||
std::string player_;
|
||||
std::vector<std::string> ignored_players_;
|
||||
|
||||
bool prefer_album_artist_;
|
||||
|
||||
PlayerctlPlayerManager* manager;
|
||||
PlayerctlPlayer* player;
|
||||
PlayerctlPlayer* last_active_player_ = nullptr;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include <gtkmm/button.h>
|
||||
#include <json/value.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "AModule.hpp"
|
||||
#include "bar.hpp"
|
||||
#include "modules/niri/backend.hpp"
|
||||
@@ -18,13 +20,19 @@ class Workspaces : public AModule, public EventHandler {
|
||||
private:
|
||||
void onEvent(const Json::Value& ev) override;
|
||||
void doUpdate();
|
||||
void sortWorkspaces(std::vector<Json::Value>& workspaces) const;
|
||||
Gtk::Button& addButton(const Json::Value& ws);
|
||||
std::string getIcon(const std::string& value, const Json::Value& ws);
|
||||
bool handleScroll(GdkEventScroll* /*unused*/) override;
|
||||
|
||||
const Bar& bar_;
|
||||
Gtk::Box box_;
|
||||
// Map from niri workspace id to button.
|
||||
std::unordered_map<uint64_t, Gtk::Button> buttons_;
|
||||
|
||||
bool sort_by_id_ = false;
|
||||
bool sort_by_name_ = false;
|
||||
bool sort_by_coordinates_ = false;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::niri
|
||||
|
||||
@@ -9,9 +9,18 @@ namespace waybar::modules {
|
||||
|
||||
struct Profile {
|
||||
std::string name;
|
||||
// Legacy driver field, kept for backward compatibility with the
|
||||
// `{driver}` format placeholder and with older power-profiles-daemon
|
||||
// versions that only expose a single `Driver` DBus property.
|
||||
std::string driver;
|
||||
std::string cpuDriver;
|
||||
std::string platformDriver;
|
||||
|
||||
Profile(std::string n, std::string d) : name(std::move(n)), driver(std::move(d)) {}
|
||||
Profile(std::string n, std::string d, std::string cd, std::string pd)
|
||||
: name(std::move(n)),
|
||||
driver(std::move(d)),
|
||||
cpuDriver(std::move(cd)),
|
||||
platformDriver(std::move(pd)) {}
|
||||
};
|
||||
|
||||
class PowerProfilesDaemon : public ALabel {
|
||||
|
||||
@@ -28,6 +28,7 @@ class Privacy : public AModule {
|
||||
|
||||
// Config
|
||||
Gtk::Box box_;
|
||||
std::vector<PrivacyItem*> modules_;
|
||||
uint iconSpacing = 4;
|
||||
uint iconSize = 20;
|
||||
uint transition_duration = 250;
|
||||
|
||||
@@ -22,6 +22,7 @@ class Pulseaudio : public ALabel {
|
||||
const std::vector<std::string> getPulseIcon() const;
|
||||
|
||||
std::shared_ptr<util::AudioBackend> backend = nullptr;
|
||||
util::PulseaudioTarget target = util::PulseaudioTarget::Sink;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules
|
||||
|
||||
@@ -6,11 +6,6 @@
|
||||
#include "util/audio_backend.hpp"
|
||||
namespace waybar::modules {
|
||||
|
||||
enum class PulseaudioSliderTarget {
|
||||
Sink,
|
||||
Source,
|
||||
};
|
||||
|
||||
class PulseaudioSlider : public ASlider {
|
||||
public:
|
||||
PulseaudioSlider(const std::string&, const Json::Value&);
|
||||
@@ -21,7 +16,15 @@ class PulseaudioSlider : public ASlider {
|
||||
|
||||
private:
|
||||
std::shared_ptr<util::AudioBackend> backend = nullptr;
|
||||
PulseaudioSliderTarget target = PulseaudioSliderTarget::Sink;
|
||||
util::PulseaudioTarget target = util::PulseaudioTarget::Sink;
|
||||
|
||||
bool zero_on_mute = true;
|
||||
bool unmute_on_volume_change = true;
|
||||
// zero_on_mute and unmute_on_volume_change default to true
|
||||
// in order to maintain previous behaviour when using a
|
||||
// config in which these values are undefined
|
||||
|
||||
bool previously_muted = false;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules
|
||||
@@ -20,6 +20,8 @@ class Tags : public waybar::AModule {
|
||||
void handle_focused_tags(uint32_t tags);
|
||||
void handle_view_tags(struct wl_array* tags);
|
||||
void handle_urgent_tags(uint32_t tags);
|
||||
void handle_focused_output(struct wl_output* output);
|
||||
void handle_unfocused_output(struct wl_output* output);
|
||||
|
||||
void handle_show();
|
||||
void handle_primary_clicked(uint32_t tag);
|
||||
@@ -31,9 +33,11 @@ class Tags : public waybar::AModule {
|
||||
|
||||
private:
|
||||
const waybar::Bar& bar_;
|
||||
struct wl_output* output_; // stores the output this module belongs to
|
||||
Gtk::Box box_;
|
||||
std::vector<Gtk::Button> buttons_;
|
||||
struct zriver_output_status_v1* output_status_;
|
||||
struct zriver_seat_status_v1* seat_status_;
|
||||
};
|
||||
|
||||
} /* namespace waybar::modules::river */
|
||||
|
||||
@@ -14,11 +14,14 @@ namespace waybar::modules::SNI {
|
||||
|
||||
class Host {
|
||||
public:
|
||||
Host(const std::size_t id, const Json::Value&, const Bar&,
|
||||
Host(const std::size_t id, const Json::Value&, const Bar&, const std::vector<std::string>&,
|
||||
const std::function<void(std::unique_ptr<Item>&)>&,
|
||||
const std::function<void(std::unique_ptr<Item>&)>&, const std::function<void()>&);
|
||||
~Host();
|
||||
|
||||
void checkIgnoreList(const std::vector<std::string>& ignore_list,
|
||||
const std::function<void(std::unique_ptr<Item>&)>& on_remove);
|
||||
|
||||
private:
|
||||
void busAcquired(const Glib::RefPtr<Gio::DBus::Connection>&, Glib::ustring);
|
||||
void nameAppeared(const Glib::RefPtr<Gio::DBus::Connection>&, Glib::ustring,
|
||||
@@ -43,8 +46,11 @@ class Host {
|
||||
std::size_t watcher_id_;
|
||||
GCancellable* cancellable_ = nullptr;
|
||||
SnWatcher* watcher_ = nullptr;
|
||||
sigc::connection retry_connection_;
|
||||
unsigned retry_count_ = 0;
|
||||
const Json::Value& config_;
|
||||
const Bar& bar_;
|
||||
const std::vector<std::string> ignore_list_;
|
||||
const std::function<void(std::unique_ptr<Item>&)> on_add_;
|
||||
const std::function<void(std::unique_ptr<Item>&)> on_remove_;
|
||||
const std::function<void()> on_update_;
|
||||
|
||||
@@ -46,6 +46,7 @@ class Item : public sigc::trackable {
|
||||
std::string title;
|
||||
std::string icon_name;
|
||||
Glib::RefPtr<Gdk::Pixbuf> icon_pixmap;
|
||||
bool has_custom_icon_ = false;
|
||||
Glib::RefPtr<Gtk::IconTheme> icon_theme;
|
||||
std::string overlay_icon_name;
|
||||
Glib::RefPtr<Gdk::Pixbuf> overlay_icon_pixmap;
|
||||
|
||||
@@ -19,12 +19,14 @@ class Tray : public AModule {
|
||||
private:
|
||||
void onAdd(std::unique_ptr<Item>& item);
|
||||
void onRemove(std::unique_ptr<Item>& item);
|
||||
void checkIgnoreList(std::unique_ptr<Item>* item);
|
||||
std::vector<std::string> parseIgnoreList(const Json::Value& config);
|
||||
void queueUpdate();
|
||||
|
||||
static inline std::size_t nb_hosts_ = 0;
|
||||
bool show_passive_ = false;
|
||||
Gtk::Box box_;
|
||||
SNI::Watcher::singleton watcher_;
|
||||
std::vector<std::string> ignore_list_;
|
||||
SNI::Host host_;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <sigc++/sigc++.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include "ipc.hpp"
|
||||
@@ -41,8 +37,9 @@ class Ipc {
|
||||
static inline const std::string ipc_magic_ = "i3-ipc";
|
||||
static inline const size_t ipc_header_size_ = ipc_magic_.size() + 8;
|
||||
|
||||
const std::string getSocketPath() const;
|
||||
int open(const std::string&) const;
|
||||
static std::string getSocketPath();
|
||||
static int open(const std::string&);
|
||||
|
||||
struct ipc_response send(int fd, uint32_t type, const std::string& payload = "");
|
||||
struct ipc_response recv(int fd);
|
||||
|
||||
|
||||
@@ -24,12 +24,15 @@ class Workspaces : public AModule, public sigc::trackable {
|
||||
|
||||
private:
|
||||
static constexpr std::string_view workspace_switch_cmd_ = "workspace {} \"{}\"";
|
||||
static constexpr std::string_view workspace_switch_number_cmd_ = "workspace {} number {}";
|
||||
static constexpr std::string_view persistent_workspace_switch_cmd_ =
|
||||
R"(workspace {} "{}"; move workspace to output "{}"; workspace {} "{}")";
|
||||
|
||||
static int convertWorkspaceNameToNum(const std::string& name);
|
||||
static int windowRewritePriorityFunction(std::string const& window_rule);
|
||||
|
||||
auto populateIgnoreWorkspacesConfig(const Json::Value& config) -> void;
|
||||
bool isWorkspaceIgnored(std::string const& name);
|
||||
void onCmd(const struct Ipc::ipc_response&);
|
||||
void onEvent(const struct Ipc::ipc_response&);
|
||||
bool filterButtons();
|
||||
@@ -49,6 +52,7 @@ class Workspaces : public AModule, public sigc::trackable {
|
||||
std::vector<std::string> workspaces_order_;
|
||||
Gtk::Box box_;
|
||||
std::string m_formatWindowSeparator;
|
||||
std::vector<std::regex> m_ignoreWorkspaces;
|
||||
util::RegexCollection m_windowRewriteRules;
|
||||
util::JsonParser parser_;
|
||||
std::unordered_map<std::string, Gtk::Button> buttons_;
|
||||
|
||||
@@ -14,6 +14,8 @@ class Temperature : public ALabel {
|
||||
Temperature(const std::string&, const Json::Value&);
|
||||
virtual ~Temperature() = default;
|
||||
auto update() -> void override;
|
||||
void suspend() override;
|
||||
void resume() override;
|
||||
|
||||
private:
|
||||
float getTemperature();
|
||||
|
||||
@@ -33,6 +33,7 @@ class Wireplumber : public ALabel {
|
||||
static void onDefaultNodesApiChanged(waybar::modules::Wireplumber* self);
|
||||
|
||||
bool handleScroll(GdkEventScroll* e) override;
|
||||
std::vector<std::string> getWPIcon();
|
||||
|
||||
static std::list<waybar::modules::Wireplumber*> modules;
|
||||
|
||||
@@ -54,6 +55,7 @@ class Wireplumber : public ALabel {
|
||||
bool source_muted_;
|
||||
double source_volume_;
|
||||
gchar* default_source_name_;
|
||||
std::string form_factor_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "AModule.hpp"
|
||||
#include "bar.hpp"
|
||||
#include "client.hpp"
|
||||
#include "ext-workspace-v1-client-protocol.h"
|
||||
#include "giomm/desktopappinfo.h"
|
||||
#include "util/icon_loader.hpp"
|
||||
#include "util/json.hpp"
|
||||
@@ -80,6 +81,7 @@ class Task {
|
||||
std::string title_;
|
||||
std::string app_id_;
|
||||
uint32_t state_ = 0;
|
||||
struct ext_workspace_handle_v1* workspace_ = nullptr;
|
||||
|
||||
int32_t drag_start_x;
|
||||
int32_t drag_start_y;
|
||||
@@ -102,6 +104,9 @@ class Task {
|
||||
bool minimized() const { return state_ & MINIMIZED; }
|
||||
bool active() const { return state_ & ACTIVE; }
|
||||
bool fullscreen() const { return state_ & FULLSCREEN; }
|
||||
bool visible() const { return button_visible_; }
|
||||
struct ext_workspace_handle_v1* workspace() const { return workspace_; }
|
||||
void set_workspace(struct ext_workspace_handle_v1* workspace) { workspace_ = workspace; }
|
||||
|
||||
public:
|
||||
/* Callbacks for the wlr protocol */
|
||||
@@ -142,6 +147,12 @@ using TaskPtr = std::unique_ptr<Task>;
|
||||
|
||||
class Taskbar : public waybar::AModule {
|
||||
public:
|
||||
struct WorkspaceState {
|
||||
Taskbar* taskbar;
|
||||
struct ext_workspace_handle_v1* handle;
|
||||
uint32_t state = 0;
|
||||
};
|
||||
|
||||
Taskbar(const std::string&, const waybar::Bar&, const Json::Value&);
|
||||
~Taskbar();
|
||||
void update();
|
||||
@@ -156,22 +167,35 @@ class Taskbar : public waybar::AModule {
|
||||
std::map<std::string, std::string> app_ids_replace_map_;
|
||||
|
||||
struct zwlr_foreign_toplevel_manager_v1* manager_;
|
||||
struct ext_workspace_manager_v1* workspace_manager_;
|
||||
struct wl_seat* seat_;
|
||||
std::vector<struct ext_workspace_group_handle_v1*> workspace_groups_;
|
||||
std::vector<std::unique_ptr<WorkspaceState>> workspaces_;
|
||||
struct ext_workspace_handle_v1* current_workspace_ = nullptr;
|
||||
|
||||
public:
|
||||
/* Callbacks for global registration */
|
||||
void register_manager(struct wl_registry*, uint32_t name, uint32_t version);
|
||||
void register_workspace_manager(struct wl_registry*, uint32_t name, uint32_t version);
|
||||
void register_seat(struct wl_registry*, uint32_t name, uint32_t version);
|
||||
|
||||
/* Callbacks for the wlr protocol */
|
||||
void handle_toplevel_create(struct zwlr_foreign_toplevel_handle_v1*);
|
||||
void handle_finished();
|
||||
void handle_workspace_group_create(struct ext_workspace_group_handle_v1*);
|
||||
void handle_workspace_group_removed(struct ext_workspace_group_handle_v1*);
|
||||
void handle_workspace_create(struct ext_workspace_handle_v1*);
|
||||
void handle_workspace_done();
|
||||
void handle_workspace_finished();
|
||||
void handle_workspace_removed(struct ext_workspace_handle_v1*);
|
||||
|
||||
public:
|
||||
void add_button(Gtk::Button&);
|
||||
void move_button(Gtk::Button&, int);
|
||||
void remove_button(Gtk::Button&);
|
||||
void remove_task(uint32_t);
|
||||
void assign_current_workspace(Task&);
|
||||
void update_bar_css_classes();
|
||||
|
||||
bool show_output(struct wl_output*) const;
|
||||
bool all_outputs() const;
|
||||
@@ -179,6 +203,9 @@ class Taskbar : public waybar::AModule {
|
||||
const IconLoader& icon_loader() const;
|
||||
const std::unordered_set<std::string>& ignore_list() const;
|
||||
const std::map<std::string, std::string>& app_ids_replace_map() const;
|
||||
|
||||
private:
|
||||
void set_bar_css_class(const std::string&, bool);
|
||||
};
|
||||
|
||||
} /* namespace waybar::modules::wlr */
|
||||
|
||||
@@ -12,11 +12,6 @@
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
#define SIGRTMIN SIGUSR1 - 1
|
||||
#define SIGRTMAX SIGUSR1 + 1
|
||||
#endif
|
||||
|
||||
namespace waybar {
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,6 +14,11 @@
|
||||
|
||||
namespace waybar::util {
|
||||
|
||||
enum class PulseaudioTarget {
|
||||
Sink,
|
||||
Source,
|
||||
};
|
||||
|
||||
class AudioBackend {
|
||||
private:
|
||||
static void subscribeCb(pa_context*, pa_subscription_event_type_t, uint32_t, void*);
|
||||
@@ -22,12 +27,14 @@ class AudioBackend {
|
||||
static void sourceInfoCb(pa_context*, const pa_source_info* i, int, void* data);
|
||||
static void serverInfoCb(pa_context*, const pa_server_info*, void*);
|
||||
static void volumeModifyCb(pa_context*, int, void*);
|
||||
static void sourceVolumeModifyCb(pa_context*, int, void*);
|
||||
void connectContext();
|
||||
|
||||
pa_threaded_mainloop* mainloop_;
|
||||
pa_mainloop_api* mainloop_api_;
|
||||
pa_context* context_;
|
||||
pa_cvolume pa_volume_;
|
||||
pa_cvolume pa_source_volume_;
|
||||
|
||||
// SINK
|
||||
uint32_t sink_idx_{0};
|
||||
@@ -50,6 +57,7 @@ class AudioBackend {
|
||||
std::string default_source_name_;
|
||||
|
||||
std::vector<std::string> ignored_sinks_;
|
||||
std::map<std::string, std::string> sink_mapping_;
|
||||
|
||||
std::function<void()> on_updated_cb_ = NOOP;
|
||||
|
||||
@@ -67,10 +75,13 @@ class AudioBackend {
|
||||
AudioBackend(std::function<void()> on_updated_cb, private_constructor_tag tag);
|
||||
~AudioBackend();
|
||||
|
||||
void changeVolume(uint16_t volume, uint16_t min_volume = 0, uint16_t max_volume = 100);
|
||||
void changeVolume(ChangeType change_type, double step = 1, uint16_t max_volume = 100);
|
||||
void changeVolume(uint16_t volume, uint16_t min_volume = 0, uint16_t max_volume = 100,
|
||||
PulseaudioTarget target = PulseaudioTarget::Sink);
|
||||
void changeVolume(ChangeType change_type, double step = 1, uint16_t max_volume = 100,
|
||||
PulseaudioTarget target = PulseaudioTarget::Sink);
|
||||
|
||||
void setIgnoredSinks(const Json::Value& config);
|
||||
void setSinkMapping(const Json::Value& config);
|
||||
|
||||
std::string getSinkPortName() const { return port_name_; }
|
||||
std::string getFormFactor() const { return form_factor_; }
|
||||
@@ -92,6 +103,10 @@ class AudioBackend {
|
||||
void toggleSourceMute();
|
||||
void toggleSourceMute(bool);
|
||||
|
||||
uint16_t getVolume(PulseaudioTarget) const;
|
||||
bool getMuted(PulseaudioTarget) const;
|
||||
void unmute(PulseaudioTarget);
|
||||
|
||||
bool isBluetooth();
|
||||
};
|
||||
|
||||
|
||||
@@ -14,12 +14,14 @@ struct pollfd;
|
||||
namespace waybar {
|
||||
class CssReloadHelper {
|
||||
public:
|
||||
CssReloadHelper(std::string cssFile, std::function<void()> callback);
|
||||
CssReloadHelper(std::string cssFile, std::function<void(const std::string&)> callback);
|
||||
|
||||
virtual ~CssReloadHelper() = default;
|
||||
|
||||
virtual void monitorChanges();
|
||||
|
||||
virtual void changeCssFile(const std::string& newCssFile);
|
||||
|
||||
protected:
|
||||
std::vector<std::string> parseImports(const std::string& cssFile);
|
||||
|
||||
@@ -42,7 +44,7 @@ class CssReloadHelper {
|
||||
private:
|
||||
std::string m_cssFile;
|
||||
|
||||
std::function<void()> m_callback;
|
||||
std::function<void(const std::string&)> m_callback;
|
||||
|
||||
std::vector<std::tuple<Glib::RefPtr<Gio::FileMonitor>>> m_fileMonitors;
|
||||
};
|
||||
|
||||
@@ -5,12 +5,13 @@
|
||||
|
||||
class pow_format {
|
||||
public:
|
||||
pow_format(long long val, std::string&& unit, bool binary = false)
|
||||
: val_(val), unit_(unit), binary_(binary) {};
|
||||
pow_format(long long val, std::string&& unit, bool binary = false, int min_pow_for_decimal = 0)
|
||||
: val_(val), unit_(unit), binary_(binary), min_pow_for_decimal_(min_pow_for_decimal) {};
|
||||
|
||||
long long val_;
|
||||
std::string unit_;
|
||||
bool binary_;
|
||||
int min_pow_for_decimal_;
|
||||
};
|
||||
|
||||
namespace fmt {
|
||||
@@ -74,7 +75,8 @@ struct formatter<pow_format> {
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
format = "{coefficient:.1f}{prefix}{unit}";
|
||||
format = pow < s.min_pow_for_decimal_ ? "{coefficient:.0f}{prefix}{unit}"
|
||||
: "{coefficient:.1f}{prefix}{unit}";
|
||||
break;
|
||||
}
|
||||
return fmt::format_to(
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <json/value.h>
|
||||
|
||||
namespace waybar::util {
|
||||
bool valid_host(const Json::Value& config);
|
||||
} // namespace waybar::util
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <codecvt>
|
||||
#include <iostream>
|
||||
#include <locale>
|
||||
#include <memory>
|
||||
#include <regex>
|
||||
|
||||
#if (FMT_VERSION >= 90000)
|
||||
@@ -26,14 +27,19 @@ class JsonParser {
|
||||
Json::Value root;
|
||||
|
||||
// replace all occurrences of "\x" with "\u00", because JSON doesn't allow "\x" escape sequences
|
||||
std::string modifiedJsonStr = replaceHexadecimalEscape(jsonStr);
|
||||
std::string modifiedJsonStr;
|
||||
const std::string* json = &jsonStr;
|
||||
if (jsonStr.find("\\x") != std::string::npos) {
|
||||
modifiedJsonStr = replaceHexadecimalEscape(jsonStr);
|
||||
json = &modifiedJsonStr;
|
||||
}
|
||||
|
||||
std::istringstream jsonStream(modifiedJsonStr);
|
||||
std::string errs;
|
||||
// Use local CharReaderBuilder for thread safety - the IPC singleton's
|
||||
// parser can be called concurrently from multiple module threads
|
||||
Json::CharReaderBuilder readerBuilder;
|
||||
if (!Json::parseFromStream(readerBuilder, jsonStream, &root, &errs)) {
|
||||
auto reader = std::unique_ptr<Json::CharReader>(readerBuilder.newCharReader());
|
||||
if (!reader->parse(json->data(), json->data() + json->size(), &root, &errs)) {
|
||||
throw std::runtime_error("Error parsing JSON: " + errs);
|
||||
}
|
||||
return root;
|
||||
|
||||
@@ -79,6 +79,12 @@ class SleeperThread {
|
||||
auto sleep_for(std::chrono::system_clock::duration dur) {
|
||||
std::unique_lock lk(mutex_);
|
||||
CancellationGuard cancel_lock;
|
||||
|
||||
condvar_.wait(lk, [this] {
|
||||
return !is_paused_ || signal_.load(std::memory_order_relaxed) ||
|
||||
!do_run_.load(std::memory_order_relaxed);
|
||||
});
|
||||
|
||||
constexpr auto max_time_point = std::chrono::steady_clock::time_point::max();
|
||||
auto wait_end = max_time_point;
|
||||
auto now = std::chrono::steady_clock::now();
|
||||
@@ -95,6 +101,12 @@ class SleeperThread {
|
||||
time_point) {
|
||||
std::unique_lock lk(mutex_);
|
||||
CancellationGuard cancel_lock;
|
||||
|
||||
condvar_.wait(lk, [this] {
|
||||
return !is_paused_ || signal_.load(std::memory_order_relaxed) ||
|
||||
!do_run_.load(std::memory_order_relaxed);
|
||||
});
|
||||
|
||||
return condvar_.wait_until(lk, time_point, [this] {
|
||||
return signal_.load(std::memory_order_relaxed) || !do_run_.load(std::memory_order_relaxed);
|
||||
});
|
||||
@@ -122,6 +134,17 @@ class SleeperThread {
|
||||
}
|
||||
}
|
||||
|
||||
void pause() {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
is_paused_ = true;
|
||||
}
|
||||
|
||||
void resume() {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
is_paused_ = false;
|
||||
condvar_.notify_all();
|
||||
}
|
||||
|
||||
~SleeperThread() {
|
||||
connection_.disconnect();
|
||||
stop();
|
||||
@@ -137,6 +160,7 @@ class SleeperThread {
|
||||
std::atomic<bool> do_run_ = true;
|
||||
std::atomic<bool> signal_ = false;
|
||||
sigc::connection connection_;
|
||||
bool is_paused_{false};
|
||||
};
|
||||
|
||||
} // namespace waybar::util
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
namespace waybar::util {
|
||||
size_t utf8_width(const std::string& str);
|
||||
void utf8_truncate(std::string& s, const std::string& ellipsis, size_t max_len);
|
||||
} // namespace waybar::util
|
||||
@@ -27,6 +27,11 @@ The *battery* module displays the current capacity and state (eg. charging) of y
|
||||
default: false ++
|
||||
Option to use the battery design capacity instead of its current maximal capacity.
|
||||
|
||||
*full-at-plugged*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
When enabled, a battery that is *Full* while the adapter is online is reported with the *Plugged* status instead of *Full* (so you can style/format it separately). Disabled by default to preserve the existing *Full* behaviour.
|
||||
|
||||
*interval*: ++
|
||||
typeof: integer ++
|
||||
default: 60 ++
|
||||
|
||||
@@ -178,6 +178,9 @@ At the time of writing, the experimental features of BlueZ need to be turned on,
|
||||
|
||||
*{device_battery_percentage}*: Battery percentage of the displayed device if available. Use only in the config options defined below.
|
||||
|
||||
*{device_battery_percentage_peripheral}*: Battery percentage of the peripheral half of a split keyboard (e.g., ZMK keyboards with separate central and peripheral batteries). ++
|
||||
This is read from GATT Battery Service characteristics that have a User Description descriptor. Use only in the config options defined below.
|
||||
|
||||
## CONFIGURATION
|
||||
|
||||
*format-connected-battery*: ++
|
||||
@@ -220,6 +223,17 @@ At the time of writing, the experimental features of BlueZ need to be turned on,
|
||||
}
|
||||
```
|
||||
|
||||
Split keyboard with separate central/peripheral batteries (e.g., ZMK):
|
||||
|
||||
```
|
||||
"bluetooth": {
|
||||
"format-device-preference": [ "Keyball44" ],
|
||||
"format": "",
|
||||
"format-connected-battery": " {device_battery_percentage}%|{device_battery_percentage_peripheral}%",
|
||||
"tooltip-format-connected": "{device_alias}\\nCentral: {device_battery_percentage}%\\nPeripheral: {device_battery_percentage_peripheral}%"
|
||||
}
|
||||
```
|
||||
|
||||
# STYLE
|
||||
|
||||
- *#bluetooth*
|
||||
|
||||
@@ -138,6 +138,11 @@ View all valid format options in *strftime(3)* or have a look https://en.cpprefe
|
||||
:[ When enabled, the calendar follows the ISO 8601 standard: weeks begin on
|
||||
Monday, and the first week of the year is numbered 1. The default week format is
|
||||
'{:%V}'.
|
||||
|[ *first-day-of-week*
|
||||
:[ integer
|
||||
:[
|
||||
:[ The first day of the week, where 0 is Sunday and 6 is Saturday.
|
||||
When not set, the first day of the week is determined by the locale settings.
|
||||
|
||||
3. Addressed by *clock: calendar: format*
|
||||
[- *Option*
|
||||
@@ -180,6 +185,8 @@ View all valid format options in *strftime(3)* or have a look https://en.cpprefe
|
||||
:[ Switch to the next calendar month/year
|
||||
|[ *shift_down*
|
||||
:[ Switch to the previous calendar month/year
|
||||
|[ *exec <cmd>*
|
||||
:[ Execute the specified command
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
@@ -210,6 +217,7 @@ View all valid format options in *strftime(3)* or have a look https://en.cpprefe
|
||||
"mode" : "year",
|
||||
"mode-mon-col" : 3,
|
||||
"weeks-pos" : "right",
|
||||
"first-day-of-week": 1,
|
||||
"on-scroll" : 1,
|
||||
"on-click-right" : "mode",
|
||||
"format": {
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
waybar-cpu-graph(5)
|
||||
|
||||
# NAME
|
||||
|
||||
waybar - cpu graph module
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
The *cpu graph* module displays a line graph with the CPU utilization.
|
||||
|
||||
# CONFIGURATION
|
||||
|
||||
*interval*: ++
|
||||
typeof: integer ++
|
||||
default: 10 ++
|
||||
The interval in which the information gets polled.
|
||||
|
||||
*width*: ++
|
||||
typeof: integer ++
|
||||
The length in pixels the module should display.
|
||||
|
||||
*datapoints*: ++
|
||||
typeof: integer ++
|
||||
How many data points to show.
|
||||
|
||||
*on-click*: ++
|
||||
typeof: string ++
|
||||
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*: ++
|
||||
typeof: string ++
|
||||
Command to execute when you right-click on the module.
|
||||
|
||||
*on-update*: ++
|
||||
typeof: string ++
|
||||
Command to execute when the module is updated.
|
||||
|
||||
*on-scroll-up*: ++
|
||||
typeof: string ++
|
||||
Command to execute when scrolling up on the module.
|
||||
|
||||
*on-scroll-down*: ++
|
||||
typeof: string ++
|
||||
Command to execute when scrolling down on the module.
|
||||
|
||||
*smooth-scrolling-threshold*: ++
|
||||
typeof: double ++
|
||||
Threshold to be used when scrolling.
|
||||
|
||||
*tooltip*: ++
|
||||
typeof: bool ++
|
||||
default: true ++
|
||||
Option to disable tooltip on hover.
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Enables this module to consume all left over space dynamically.
|
||||
|
||||
# EXAMPLES
|
||||
|
||||
Basic configuration:
|
||||
|
||||
```
|
||||
"cpu_graph": {
|
||||
"interval": 2,
|
||||
"width": 10
|
||||
}
|
||||
```
|
||||
|
||||
# STYLE
|
||||
|
||||
- *#cpu_graph*
|
||||
- *.cpu-intensive*
|
||||
- *.cpu-high*
|
||||
- *.cpu-moderate*
|
||||
@@ -83,6 +83,18 @@ The *cpu* module displays the current CPU utilization.
|
||||
default: true ++
|
||||
Option to disable tooltip on hover.
|
||||
|
||||
*tooltip-format*: ++
|
||||
typeof: string ++
|
||||
The format of the tooltip shown on hover. Supports the same replacements as *format*.
|
||||
|
||||
*format-<state>*: ++
|
||||
typeof: string ++
|
||||
The format to use when the given *state* (see *states*) is active. Supports the same replacements as *format*.
|
||||
|
||||
*tooltip-format-<state>*: ++
|
||||
typeof: string ++
|
||||
The tooltip format to use when the given *state* (see *states*) is active. Takes precedence over *tooltip-format*.
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
@@ -92,6 +104,12 @@ The *cpu* module displays the current CPU utilization.
|
||||
|
||||
*{load}*: Current CPU load.
|
||||
|
||||
*{load1}*: CPU load average over the last minute.
|
||||
|
||||
*{load5}*: CPU load average over the last 5 minutes.
|
||||
|
||||
*{load15}*: CPU load average over the last 15 minutes.
|
||||
|
||||
*{usage}*: Current overall CPU usage.
|
||||
|
||||
*{usage*{n}*}*: Current CPU core n usage. Cores are numbered from zero, so first core will be {usage0} and 4th will be {usage3}.
|
||||
@@ -106,6 +124,8 @@ The *cpu* module displays the current CPU utilization.
|
||||
|
||||
*{icon*{n}*}*: Icon for CPU core n usage. Use like {icon0}.
|
||||
|
||||
*{icon0}{icon1}{icon2}{icon3}*: All per-core icons concatenated. Equivalent to {icon0}{icon1}...{icon*N*} but adapts to the number of cores automatically.
|
||||
|
||||
# EXAMPLES
|
||||
|
||||
Basic configuration:
|
||||
@@ -128,6 +148,16 @@ CPU usage per core rendered as icons:
|
||||
},
|
||||
```
|
||||
|
||||
Automatically determine number of icons according to number of logical cores:
|
||||
|
||||
```
|
||||
"cpu": {
|
||||
"interval": 1,
|
||||
"format": "{icons} {usage:>2}% ",
|
||||
"format-icons": ["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"],
|
||||
},
|
||||
```
|
||||
|
||||
# STYLE
|
||||
|
||||
- *#cpu*
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
waybar-custom-graph(5)
|
||||
# NAME
|
||||
|
||||
waybar - custom graph module
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
The *custom-graph* module displays a graph with the percentage output of a script.
|
||||
|
||||
# CONFIGURATION
|
||||
|
||||
Addressed by *custom-graph/<name>*
|
||||
|
||||
*exec*: ++
|
||||
typeof: string ++
|
||||
The path to the script, which should be executed.
|
||||
|
||||
*exec-if*: ++
|
||||
typeof: string ++
|
||||
The path to a script, which determines if the script in *exec* should be executed. ++
|
||||
*exec* will be executed if the exit code of *exec-if* equals 0.
|
||||
|
||||
*exec-on-event*: ++
|
||||
typeof: bool ++
|
||||
default: true ++
|
||||
If an event command is set (e.g. *on-click* or *on-scroll-up*) then re-execute the script after executing the event command.
|
||||
|
||||
*return-type*: ++
|
||||
typeof: string ++
|
||||
See *return-type*
|
||||
|
||||
*interval*: ++
|
||||
typeof: integer or float ++
|
||||
The interval (in seconds) in which the information gets polled. ++
|
||||
Minimum value is 0.001 (1ms). Values smaller than 1ms will be set to 1ms. ++
|
||||
Use *once* if you want to execute the module only on startup. ++
|
||||
You can update it manually with a signal. If no *interval* or *signal* is defined, it is assumed that the out script loops itself. ++
|
||||
If a *signal* is defined then the script will run once on startup and will only update with a signal.
|
||||
|
||||
*restart-interval*: ++
|
||||
typeof: integer or float ++
|
||||
The restart interval (in seconds). ++
|
||||
Minimum value is 0.001 (1ms). Values smaller than 1ms will be set to 1ms. ++
|
||||
Can't be used with the *interval* option, so only with continuous scripts. ++
|
||||
Once the script exits, it'll be re-executed after the *restart-interval*.
|
||||
|
||||
*signal*: ++
|
||||
typeof: integer ++
|
||||
The signal number used to update the module. ++
|
||||
The number is valid between 1 and N, where *SIGRTMIN+N* = *SIGRTMAX*. ++
|
||||
If no interval is defined then a signal will be the only way to update the module.
|
||||
|
||||
*format*: ++
|
||||
typeof: string ++
|
||||
default: {text} ++
|
||||
The format, how information should be displayed. On {text} data gets inserted.
|
||||
|
||||
*format-icons*: ++
|
||||
typeof: array ++
|
||||
Based on the set percentage, the corresponding icon gets selected. The order is *low* to *high*.
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer ++
|
||||
Positive value to rotate the text label (in 90 degree increments).
|
||||
|
||||
*on-click*: ++
|
||||
typeof: string ++
|
||||
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*: ++
|
||||
typeof: string ++
|
||||
Command to execute when you right-click on the module.
|
||||
|
||||
*on-update*: ++
|
||||
typeof: string ++
|
||||
Command to execute when the module is updated.
|
||||
|
||||
*on-scroll-up*: ++
|
||||
typeof: string ++
|
||||
Command to execute when scrolling up on the module.
|
||||
|
||||
*on-scroll-down*: ++
|
||||
typeof: string ++
|
||||
Command to execute when scrolling down on the module.
|
||||
|
||||
*smooth-scrolling-threshold*: ++
|
||||
typeof: double ++
|
||||
Threshold to be used when scrolling.
|
||||
|
||||
*tooltip*: ++
|
||||
typeof: bool ++
|
||||
default: true ++
|
||||
Option to disable tooltip on hover.
|
||||
|
||||
*tooltip-format*: ++
|
||||
typeof: string ++
|
||||
The tooltip format. If specified, overrides any tooltip output from the script in *exec*. ++
|
||||
Uses the same format replacements as *format*.
|
||||
|
||||
*escape*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Option to enable escaping of script output.
|
||||
|
||||
*menu*: ++
|
||||
typeof: string ++
|
||||
Action that popups the menu.
|
||||
|
||||
*menu-file*: ++
|
||||
typeof: string ++
|
||||
Location of the menu descriptor file. There need to be an element of type
|
||||
GtkMenu with id *menu*
|
||||
|
||||
*menu-actions*: ++
|
||||
typeof: array ++
|
||||
The actions corresponding to the buttons of the menu.
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Enables this module to consume all left over space dynamically.
|
||||
|
||||
# RETURN-TYPE
|
||||
|
||||
When *return-type* is set to *json*, Waybar expects the *exec*-script to output its data in JSON format.
|
||||
This should look like this:
|
||||
|
||||
```
|
||||
{"text": "$text", "tooltip": "$tooltip", "class": "$class", "percentage": $percentage }
|
||||
```
|
||||
|
||||
The *class* parameter also accepts an array of strings.
|
||||
|
||||
If nothing or an invalid option is specified, Waybar expects i3blocks style output. Values are *newline* separated.
|
||||
This should look like this:
|
||||
|
||||
```
|
||||
$text\\n$tooltip\\n$class*
|
||||
```
|
||||
|
||||
*class* is a CSS class, to apply different styles in *style.css*
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{text}*: Output of the script.
|
||||
|
||||
*{percentage}* Percentage which can be set via a json return type.
|
||||
|
||||
*{icon}*: An icon from 'format-icons' according to percentage.
|
||||
|
||||
# EXAMPLES
|
||||
|
||||
## Memory:
|
||||
|
||||
```
|
||||
"custom-graph/memory": {
|
||||
"interval": 60,
|
||||
"graph_type": "gauge",
|
||||
"width": 52,
|
||||
"exec": "/path/mem.sh",
|
||||
"signal": 8,
|
||||
"return-type": "json"
|
||||
},
|
||||
```
|
||||
|
||||
mem.sh:
|
||||
|
||||
```
|
||||
#!/bin/bash
|
||||
|
||||
mem_info=$(cat /proc/meminfo)
|
||||
mem_total=$(echo "$mem_info" | grep '^MemTotal:' | awk '{print $2}')
|
||||
mem_available=$(echo "$mem_info" | grep '^MemAvailable:' | awk '{print $2}')
|
||||
|
||||
mem_used=$((mem_total - mem_available))
|
||||
mem_percent=$((mem_used * 100 / mem_total))
|
||||
|
||||
echo "{\"text\": \"${mem_percent}%\", \"percentage\": ${mem_percent},\"tooltip\": \"Memory: ${mem_used}KB used / ${mem_total}KB total\"}'"
|
||||
```
|
||||
|
||||
# STYLE
|
||||
|
||||
- *#custom-graph-<name>*
|
||||
- *#custom-graph-<name>.<class>*
|
||||
- *<class>* can be set by the script. For more information see *return-type*
|
||||
+36
-9
@@ -6,17 +6,12 @@ waybar - disk module
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
The *disk* module displays the current disk space used.
|
||||
The *disk* module displays information of multiple disks.
|
||||
|
||||
# CONFIGURATION
|
||||
|
||||
Addressed by *disk*
|
||||
|
||||
*path*: ++
|
||||
typeof: string ++
|
||||
default: "/" ++
|
||||
Any path residing in the filesystem or mountpoint for which the information should be displayed.
|
||||
|
||||
*interval*: ++
|
||||
typeof: integer++
|
||||
default: 30 ++
|
||||
@@ -25,7 +20,7 @@ Addressed by *disk*
|
||||
*format*: ++
|
||||
typeof: string ++
|
||||
default: "{percentage_used}%" ++
|
||||
The format, how information should be displayed.
|
||||
The format, how information for each disk should be displayed.
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer ++
|
||||
@@ -75,6 +70,26 @@ Addressed by *disk*
|
||||
typeof: string ++
|
||||
Command to execute when scrolling down on the module.
|
||||
|
||||
*path*: ++
|
||||
typeof: string ++
|
||||
default: "/" ++
|
||||
Deprecated path of filesystem or mountpoint to monitor.
|
||||
|
||||
*paths*: ++
|
||||
typeof: array ++
|
||||
default: ["/"] ++
|
||||
Array of paths residing in the filesystem or mountpoint for which the information should be displayed.
|
||||
|
||||
*header*: ++
|
||||
typeof: string ++
|
||||
default: "" ++
|
||||
Text to appear before the disk information defined in the format.
|
||||
|
||||
*separator*: ++
|
||||
typeof: string ++
|
||||
default: " " ++
|
||||
Separator string between multiple disk information.
|
||||
|
||||
*smooth-scrolling-threshold*: ++
|
||||
typeof: double ++
|
||||
Threshold to be used when scrolling.
|
||||
@@ -123,7 +138,7 @@ Addressed by *disk*
|
||||
|
||||
*{free}*: Amount of available disk space for normal users. Automatically selects unit based on size remaining.
|
||||
|
||||
*{path}*: The path specified in the configuration.
|
||||
*{path}*: The path for each disk specified in the configuration.
|
||||
|
||||
*{specific_total}*: Total amount of space on the disk, partition, or mountpoint in a specific unit. Defaults to bytes.
|
||||
|
||||
@@ -143,10 +158,22 @@ Addressed by *disk*
|
||||
```
|
||||
"disk": {
|
||||
"interval": 30,
|
||||
"format": "{percentage_free}% free on {path}",
|
||||
"header": "Disks: ",
|
||||
"paths": ["/", "/home"],
|
||||
"separator": " ",
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
"disk": {
|
||||
"interval": 30,
|
||||
"paths": ["/"],
|
||||
"format": "{specific_free:0.2f} GB out of {specific_total:0.2f} GB available. Alternatively {free} out of {total} available",
|
||||
"unit": "GB"
|
||||
// 1434.25 GB out of 2000.00 GB available. Alternatively 1.4TiB out of 1.9TiB available.
|
||||
}
|
||||
|
||||
// 1434.25 GB out of 2000.00 GB available. Alternatively 1.4TiB out of 1.9TiB available.
|
||||
```
|
||||
|
||||
# STYLE
|
||||
|
||||
@@ -21,6 +21,11 @@ Addressed by *dwl/tags*
|
||||
typeof: array ++
|
||||
The label to display for each tag.
|
||||
|
||||
*hide-vacant*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
If set to true, tags without clients and that are not active will be hidden.
|
||||
|
||||
*disable-click*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
@@ -46,8 +51,9 @@ Addressed by *dwl/tags*
|
||||
- *#tags button.empty*
|
||||
- *#tags button.focused*
|
||||
- *#tags button.urgent*
|
||||
- *#tags button.output*
|
||||
|
||||
Note that occupied/focused/urgent status may overlap. That is, a tag may be
|
||||
Note that occupied/focused/urgent/output status may overlap. That is, a tag may be
|
||||
both occupied and focused at the same time.
|
||||
|
||||
# SEE ALSO
|
||||
|
||||
@@ -17,6 +17,16 @@ Addressed by *dwl/window*
|
||||
default: {title} ++
|
||||
The format, how information should be displayed.
|
||||
|
||||
*hide-empty*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Option to hide the module when the content would be empty.
|
||||
|
||||
*hide-inactive*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Option to hide the module when the window is unfocused.
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer ++
|
||||
Positive value to rotate the text label (in 90 degree increments).
|
||||
@@ -109,6 +119,10 @@ If no expression matches, the format output is left unchanged.
|
||||
|
||||
Invalid expressions (e.g., mismatched parentheses) are skipped.
|
||||
|
||||
# STYLE
|
||||
|
||||
- *#window.active*
|
||||
|
||||
# EXAMPLES
|
||||
|
||||
```
|
||||
|
||||
@@ -21,6 +21,10 @@ Addressed by *hyprland/language*
|
||||
typeof: string++
|
||||
Provide an alternative name to display per language where <lang> is the language of your choosing. Can be passed multiple times with multiple languages as shown by the example below.
|
||||
|
||||
*format-<lang>-<variant>* ++
|
||||
typeof: string ++
|
||||
Like *format-<lang>* but also matches the layout variant, taking precedence over *format-<lang>* when both the language and variant match.
|
||||
|
||||
*keyboard-name*: ++
|
||||
typeof: string ++
|
||||
Specifies which keyboard to use from hyprctl devices output. Using the option that begins with "at-translated-set..." is recommended.
|
||||
@@ -38,6 +42,24 @@ Addressed by *hyprland/language*
|
||||
typeof: array ++
|
||||
The actions corresponding to the buttons of the menu.
|
||||
|
||||
*tooltip*: ++
|
||||
typeof: boolean ++
|
||||
default: true ++
|
||||
Enables or disables the tooltip for the language module. By default, the tooltip is enabled. Set to *false* to disable.
|
||||
|
||||
*tooltip-format*: ++
|
||||
typeof: string ++
|
||||
default: {long} ++
|
||||
Specifies the format of the tooltip when it is enabled. It follows the same format replacement rules as the *format* key.
|
||||
|
||||
*tooltip-format-<lang>*: ++
|
||||
typeof: string ++
|
||||
Allows specifying a different tooltip format for each language. The *<lang>* should be replaced with the language code. This can be used to provide a custom tooltip for each language.
|
||||
|
||||
*tooltip-format-<lang>-<variant>*: ++
|
||||
typeof: string ++
|
||||
Like *tooltip-format-<lang>* but also matches the layout variant, taking precedence over *tooltip-format-<lang>* when both the language and variant match.
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
@@ -66,6 +88,28 @@ Addressed by *hyprland/language*
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
"hyprland/language": {
|
||||
"format": "{}",
|
||||
"format-en": "US",
|
||||
"format-es": "ES",
|
||||
"tooltip": true,
|
||||
"tooltip-format": "{long}"
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
"hyprland/language": {
|
||||
"format": "{}",
|
||||
"format-en": "US",
|
||||
"format-es": "ES",
|
||||
"tooltip": true,
|
||||
"tooltip-format": "{}",
|
||||
"tooltip-format-es": "{Español}",
|
||||
"tooltip-format-en": "{English (american)}"
|
||||
}
|
||||
```
|
||||
|
||||
# STYLE
|
||||
|
||||
- *#language*
|
||||
|
||||
@@ -25,6 +25,15 @@ Addressed by *hyprland/window*
|
||||
typeof: bool ++
|
||||
Show the active window of the monitor the bar belongs to, instead of the focused window.
|
||||
|
||||
*fallback*: ++
|
||||
typeof: string ++
|
||||
Text to display when the focused window title is empty (for example when no window is focused).
|
||||
|
||||
*tooltip-format*: ++
|
||||
typeof: string ++
|
||||
default: {title} ++
|
||||
The format of the tooltip shown on hover. Supports the same replacements as *format*. Requires *tooltip* to be enabled.
|
||||
|
||||
*icon*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
|
||||
@@ -41,6 +41,19 @@ This setting is ignored if *workspace-taskbar.enable* is set to true.
|
||||
The separator to be used between windows in a workspace. ++
|
||||
This setting is ignored if *workspace-taskbar.enable* is set to true.
|
||||
|
||||
*window-rewrite-group-threshold*: ++
|
||||
typeof: int ++
|
||||
default: 0 ++
|
||||
When a workspace contains at least this many windows with the same rewrite result, they are collapsed into a single one using *window-rewrite-group-format*. ++
|
||||
Set to 0 to disable grouping. ++
|
||||
This setting is ignored if *workspace-taskbar.enable* is set to true.
|
||||
|
||||
*window-rewrite-group-format*: ++
|
||||
typeof: string ++
|
||||
default: "{icon}×{count}" ++
|
||||
The format used to represent a group of collapsed windows. Available placeholders are {icon} (the icon being grouped) and {count} (how many windows share it). ++
|
||||
This setting is ignored if *workspace-taskbar.enable* is set to true.
|
||||
|
||||
*workspace-taskbar*: ++
|
||||
typeof: object ++
|
||||
Contains settings for the workspace taskbar, an alternative mode for the workspaces module which displays the window icons as images instead of text.
|
||||
@@ -98,6 +111,11 @@ This setting is ignored if *workspace-taskbar.enable* is set to true.
|
||||
- {button} Pressed button number, see https://api.gtkd.org/gdk.c.types.GdkEventButton.button.html. ++
|
||||
See https://github.com/Alexays/Waybar/wiki/Module:-Hyprland#workspace-taskbars-example for a full example.
|
||||
|
||||
*max-windows*: ++
|
||||
typeof: int ++
|
||||
default: 0 (unlimited) ++
|
||||
Maximum number of windows to show per workspace. When set, newest windows beyond the limit are not shown. Set to 0 for unlimited windows.
|
||||
|
||||
*show-special*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
@@ -113,6 +131,11 @@ This setting is ignored if *workspace-taskbar.enable* is set to true.
|
||||
default: false ++
|
||||
If set to true, only persistent workspaces will be shown on bar.
|
||||
|
||||
*persistent-workspaces*: ++
|
||||
typeof: object ++
|
||||
default: empty ++
|
||||
Lists workspaces that should always be shown, even when they do not exist. Keys are workspace names and values are arrays of output names on which the workspace should be shown (an empty array means all outputs). See the examples below.
|
||||
|
||||
*all-outputs*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
@@ -123,6 +146,11 @@ This setting is ignored if *workspace-taskbar.enable* is set to true.
|
||||
default: false ++
|
||||
If set to true, only the active workspace will be shown.
|
||||
|
||||
*hide-active*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
If set to true, the active workspace will be hidden. Unless a workspace is persistent or special.
|
||||
|
||||
*move-to-monitor*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
@@ -135,6 +163,14 @@ This setting is ignored if *workspace-taskbar.enable* is set to true.
|
||||
default: false ++
|
||||
If set to false, you can't scroll to cycle throughout workspaces from the entire bar. If set to true this behaviour is enabled.
|
||||
|
||||
*on-scroll-up*: ++
|
||||
typeof: string ++
|
||||
Command to execute when scrolling up on the module. This replaces the default behaviour of workspace cycling.
|
||||
|
||||
*on-scroll-down*: ++
|
||||
typeof: string ++
|
||||
Command to execute when scrolling down on the module. This replaces the default behaviour of workspace cycling.
|
||||
|
||||
*ignore-workspaces*: ++
|
||||
typeof: array ++
|
||||
default: [] ++
|
||||
|
||||
@@ -76,6 +76,17 @@ screensaver, also known as "presentation mode".
|
||||
typeof: double ++
|
||||
The number of minutes the inhibition should last.
|
||||
|
||||
*wait-for-activity*: ++
|
||||
typeof: bool ++
|
||||
default: *false* ++
|
||||
When enabled, the idle inhibitor remains active as long as there is keyboard or mouse activity on the bar. If there is no activity for the duration specified in *timeout*, the inhibitor will automatically toggle off. This option requires *timeout* to be set.
|
||||
|
||||
*signal*: ++
|
||||
typeof: integer ++
|
||||
The signal number used to toggle the idle inhibitor externally. ++
|
||||
The number is valid between 1 and N, where *SIGRTMIN+N* = *SIGRTMAX*. ++
|
||||
Use `pkill -SIGRTMIN+N waybar` to toggle the idle inhibitor from scripts or keybindings.
|
||||
|
||||
*tooltip*: ++
|
||||
typeof: bool ++
|
||||
default: true ++
|
||||
@@ -115,17 +126,46 @@ screensaver, also known as "presentation mode".
|
||||
|
||||
# EXAMPLES
|
||||
|
||||
Basic usage with timeout:
|
||||
|
||||
```
|
||||
"idle_inhibitor": {
|
||||
"format": "{icon}",
|
||||
"format-icons": {
|
||||
"activated": "",
|
||||
"deactivated": ""
|
||||
"activated": "",
|
||||
"deactivated": ""
|
||||
},
|
||||
"timeout": 30.5
|
||||
}
|
||||
```
|
||||
|
||||
With external control via signals (can be toggled with `pkill -SIGRTMIN+8 waybar`):
|
||||
|
||||
```
|
||||
"idle_inhibitor": {
|
||||
"format": "{icon}",
|
||||
"format-icons": {
|
||||
"activated": "",
|
||||
"deactivated": ""
|
||||
},
|
||||
"signal": 8
|
||||
}
|
||||
```
|
||||
|
||||
With wait-for-activity feature:
|
||||
|
||||
```
|
||||
"idle_inhibitor": {
|
||||
"format": "{icon}",
|
||||
"format-icons": {
|
||||
"activated": "",
|
||||
"deactivated": ""
|
||||
},
|
||||
"timeout": 5.0,
|
||||
"wait-for-activity": true
|
||||
}
|
||||
```
|
||||
|
||||
# STYLE
|
||||
|
||||
- *#idle_inhibitor*
|
||||
|
||||
@@ -26,7 +26,10 @@ You must be a member of the input group to use this module.
|
||||
*format-icons*: ++
|
||||
typeof: object ++
|
||||
default: {"locked": "locked", "unlocked": "unlocked"} ++
|
||||
Based on the keyboard state, the corresponding icon gets selected. The same set of icons is used for number, caps, and scroll lock, but the icon is selected from the set independently for each. See *icons*.
|
||||
Based on the keyboard state, the corresponding icon gets selected. Supports two syntaxes:
|
||||
- Common format-icons: "locked" and "unlocked" keys apply to all lock types.
|
||||
- Per-lock-type format-icons: per-lock-type objects with "numlock", "capslock", "scrolllock" keys, each containing "locked" and "unlocked" icons.
|
||||
See *icons*.
|
||||
|
||||
*numlock*: ++
|
||||
typeof: bool ++
|
||||
@@ -68,15 +71,21 @@ You must be a member of the input group to use this module.
|
||||
|
||||
The following *format-icons* can be set.
|
||||
|
||||
## Common format-icons for all lock types:
|
||||
- *locked*: Will be shown when the keyboard state is locked. Default "locked".
|
||||
- *unlocked*: Will be shown when the keyboard state is not locked. Default "unlocked"
|
||||
- *unlocked*: Will be shown when the keyboard state is not locked. Default "unlocked".
|
||||
|
||||
## Per-lock-type format-icons:
|
||||
- *numlock*, *capslock*, *scrolllock*: Object containing "locked" and "unlocked" keys for lock-type-specific icons. Defaults to {"locked": "locked", "unlocked": "unlocked"} for each lock type.
|
||||
|
||||
# EXAMPLE:
|
||||
|
||||
## Common format-icons for all lock types:
|
||||
```
|
||||
"keyboard-state": {
|
||||
"numlock": true,
|
||||
"capslock": true,
|
||||
"scrolllock": true,
|
||||
"format": "{name} {icon}",
|
||||
"format-icons": {
|
||||
"locked": "",
|
||||
@@ -85,6 +94,30 @@ The following *format-icons* can be set.
|
||||
}
|
||||
```
|
||||
|
||||
## Per-lock-type format-icons:
|
||||
```
|
||||
"keyboard-state": {
|
||||
"numlock": true,
|
||||
"capslock": true,
|
||||
"scrolllock": true,
|
||||
"format": "{name} {icon}",
|
||||
"format-icons": {
|
||||
"numlock": {
|
||||
"locked": "1",
|
||||
"unlocked": "0"
|
||||
},
|
||||
"capslock": {
|
||||
"locked": "A",
|
||||
"unlocked": "a"
|
||||
},
|
||||
"scrolllock": {
|
||||
"locked": "S",
|
||||
"unlocked": "s"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
# STYLE
|
||||
|
||||
- *#keyboard-state*
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
waybar-mango-keymode(5)
|
||||
|
||||
# NAME
|
||||
|
||||
waybar - mango keymode module
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
The *keymode* module displays the current keyboard mode (e.g. "resize", "default") in the Mango compositor. It is hidden when no mode is active.
|
||||
|
||||
# CONFIGURATION
|
||||
|
||||
Addressed by *mango/keymode*
|
||||
|
||||
*format*: ++
|
||||
typeof: string ++
|
||||
default: {} ++
|
||||
The format, how the mode should be displayed. *{mode}* is replaced by the current mode name.
|
||||
|
||||
*format-<mode>*: ++
|
||||
typeof: string ++
|
||||
Provide a custom format for a specific keymode. *<mode>* is the mode name as reported by Mango (e.g. "resize"). The value can contain *{mode}* as a placeholder.
|
||||
If this option is set, it overrides the main *format* for that mode.
|
||||
|
||||
*menu*: ++
|
||||
typeof: string ++
|
||||
Action that pops up a menu.
|
||||
|
||||
*menu-file*: ++
|
||||
typeof: string ++
|
||||
Location of the menu descriptor file.
|
||||
|
||||
*menu-actions*: ++
|
||||
typeof: array ++
|
||||
Actions for the menu buttons.
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Enables the module to consume all leftover space.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{mode}*: The name of the current keymode.
|
||||
|
||||
# EXAMPLES
|
||||
|
||||
```
|
||||
"mango/keymode": {
|
||||
"format": "[{mode}]",
|
||||
"format-resize": " Resizing"
|
||||
}
|
||||
```
|
||||
|
||||
# STYLE
|
||||
|
||||
- *#keymode*
|
||||
|
||||
A CSS class with the current mode name (e.g. *.resize*) is added to the widget, allowing per‑mode styling:
|
||||
|
||||
```
|
||||
#keymode.resize { background: #ff0000; }
|
||||
```
|
||||
@@ -0,0 +1,78 @@
|
||||
waybar-mango-language(5)
|
||||
|
||||
# NAME
|
||||
|
||||
waybar - mango language module
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
The *language* module displays the currently active keyboard layout in the Mango compositor.
|
||||
|
||||
# CONFIGURATION
|
||||
|
||||
Addressed by *mango/language*
|
||||
|
||||
*format*: ++
|
||||
typeof: string ++
|
||||
default: {} ++
|
||||
The format, how the layout should be displayed. See *FORMAT REPLACEMENTS*.
|
||||
|
||||
*format-<lang>*: ++
|
||||
typeof: string ++
|
||||
Provide an alternative format string for a given language.
|
||||
<lang> is the short description of the layout (e.g. "us", "de").
|
||||
The value is used as the replacement for *{}* in the main *format*.
|
||||
This option can be repeated for multiple languages.
|
||||
|
||||
*format-<lang>-<variant>*: ++
|
||||
typeof: string ++
|
||||
Like *format-<lang>* but also matches the layout variant, taking precedence over *format-<lang>* when both the language and variant match.
|
||||
|
||||
*menu*: ++
|
||||
typeof: string ++
|
||||
Action that pops up a menu.
|
||||
|
||||
*menu-file*: ++
|
||||
typeof: string ++
|
||||
Location of the menu descriptor file. It must contain an element of type GtkMenu with id *menu*.
|
||||
|
||||
*menu-actions*: ++
|
||||
typeof: array ++
|
||||
Actions corresponding to the buttons of the menu.
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Enables this module to consume all leftover space dynamically.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{short}*: Short name of the layout (e.g. "us"). This is also the default when no format is specified.
|
||||
|
||||
*{shortDescription}*: Short description of the layout (same as *{short}* in most cases).
|
||||
|
||||
*{long}*: Full name of the layout as reported by Mango (e.g. "English (US)").
|
||||
|
||||
*{variant}*: Variant of the layout, if any.
|
||||
|
||||
# EXAMPLES
|
||||
|
||||
```
|
||||
"mango/language": {
|
||||
"format": " {long} ",
|
||||
"format-us": "US",
|
||||
"format-de": "DE"
|
||||
}
|
||||
```
|
||||
|
||||
# STYLE
|
||||
|
||||
- *#language*
|
||||
|
||||
A CSS class matching the current layout's short name is added to the widget.
|
||||
This allows per‑layout styling:
|
||||
|
||||
```
|
||||
#language.us { color: #00ff00; }
|
||||
#language.de { color: #ff0000; }
|
||||
```
|
||||
@@ -0,0 +1,75 @@
|
||||
waybar-mango-layout(5)
|
||||
|
||||
# NAME
|
||||
|
||||
waybar - mango layout module
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
The *layout* module displays the current layout symbol of the monitor (e.g. "S", "M") in the Mango compositor.
|
||||
It supports dynamic CSS classes and custom formats based on the active layout symbol.
|
||||
|
||||
# CONFIGURATION
|
||||
|
||||
Addressed by *mango/layout*
|
||||
|
||||
*format*: ++
|
||||
typeof: string ++
|
||||
default: {symbol} ++
|
||||
The default format, how the layout symbol should be displayed. *{symbol}* is replaced by the current layout symbol.
|
||||
|
||||
*format-<symbol>*: ++
|
||||
typeof: string ++
|
||||
default: *none* ++
|
||||
The custom format to use when a specific layout symbol is active (e.g., *format-S*, *format-M*). Note that the symbol string is strictly case-sensitive. If no match is found, it falls back to *format*.
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Enables the module to consume all leftover space.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{symbol}*: The layout symbol reported by Mango (e.g., "S", "M", "Dwindle").
|
||||
|
||||
# CUSTOM FORMATS
|
||||
|
||||
You can define specific formats for different layouts by appending the exact layout symbol to the *format-* key in your configuration.
|
||||
|
||||
For example, if your Mango compositor reports the symbol "S" for a spiral layout and "M" for a master layout, you can use *format-S* and *format-M* to define unique icons or text for each. Keep in mind that JSON keys are case-sensitive, so if the compositor sends "S", the key must be exactly *format-S*.
|
||||
|
||||
# STYLE
|
||||
|
||||
The layout module provides dynamic CSS classes based on the current layout symbol, allowing you to style each layout differently.
|
||||
|
||||
* *#mango-layout*
|
||||
* *.<symbol>* - The current layout symbol is dynamically added as a CSS class name (e.g., *.S*, *.M*).
|
||||
|
||||
# EXAMPLES
|
||||
|
||||
```
|
||||
"mango/layout": {
|
||||
"format": "[] {symbol}",
|
||||
"format-S": " {symbol}",
|
||||
"format-M": " {symbol}"
|
||||
}
|
||||
```
|
||||
|
||||
## CSS Example
|
||||
|
||||
```
|
||||
#mango-layout {
|
||||
color: #ffffff;
|
||||
padding: 0 5px;
|
||||
}
|
||||
|
||||
/* Specific color for the "S" layout */
|
||||
#mango-layout.S {
|
||||
color: #a6e3a1;
|
||||
}
|
||||
|
||||
/* Specific color for the "M" layout */
|
||||
#mango-layout.M {
|
||||
color: #f38ba8;
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,70 @@
|
||||
waybar-mango-window(5)
|
||||
|
||||
# NAME
|
||||
|
||||
waybar - mango window module
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
The *window* module displays the title and app ID of the currently focused window in the Mango compositor.
|
||||
|
||||
# CONFIGURATION
|
||||
|
||||
Addressed by *mango/window*
|
||||
|
||||
*format*: ++
|
||||
typeof: string ++
|
||||
default: {title} ++
|
||||
The format string. See *FORMAT REPLACEMENTS*.
|
||||
|
||||
*rewrite*: ++
|
||||
typeof: object ++
|
||||
Rules to rewrite the window title. Each key is a regular expression and its value is the replacement string. Captures can be used with *$1*, *$2*, etc.
|
||||
|
||||
*icon*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Whether to show the application icon.
|
||||
|
||||
*icon-size*: ++
|
||||
typeof: integer ++
|
||||
default: 24 ++
|
||||
Size of the application icon in pixels.
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Enables the module to consume all leftover space.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{title}*: The current window title.
|
||||
|
||||
*{app_id}*: The app ID of the focused window.
|
||||
|
||||
# REWRITE RULES
|
||||
|
||||
If the title matches a regular expression from the *rewrite* object, it is replaced by the corresponding value. Regular expression syntax follows ECMAScript rules. Unmatched titles are left unchanged.
|
||||
|
||||
# EXAMPLES
|
||||
|
||||
```
|
||||
"mango/window": {
|
||||
"format": "{title}",
|
||||
"rewrite": {
|
||||
"(.*) - Mozilla Firefox": "🌎 $1",
|
||||
"(.*) - zsh": "> [$1]"
|
||||
},
|
||||
"icon": true,
|
||||
"icon-size": 20
|
||||
}
|
||||
```
|
||||
|
||||
# STYLE
|
||||
|
||||
- *#window*
|
||||
- *#window.empty* – applied when no window is focused (module hidden by default)
|
||||
- *#window.solo* – applied when only one window is present on the active workspace
|
||||
- *#window.<app-id>* – applied when a single window with the given app ID is on the workspace
|
||||
|
||||
The classes *.empty*, *.solo*, and the app‑ID class are set on the module’s event box.
|
||||
@@ -0,0 +1,112 @@
|
||||
waybar-mango-workspaces(5)
|
||||
|
||||
# NAME
|
||||
|
||||
waybar - mango workspaces module
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
The *workspaces* module displays the tags (workspaces) of the Mango compositor. It shows an overview button when the overview mode is active (active tag is 0), and individual tag buttons otherwise.
|
||||
|
||||
# CONFIGURATION
|
||||
|
||||
Addressed by *mango/workspaces*
|
||||
|
||||
*format*: ++
|
||||
typeof: string ++
|
||||
default: {value} ++
|
||||
The format for each tag button. See *FORMAT REPLACEMENTS*.
|
||||
|
||||
*format-icons*: ++
|
||||
typeof: object ++
|
||||
Icons to be used instead of the workspace index or name. Keys can be a workspace index (as a string), or one of the following special state keys: *default*, *active*, *urgent*, *empty*.
|
||||
|
||||
*disable-markup*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
If true, the button label will not be interpreted as Pango markup.
|
||||
|
||||
*current-only*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
If true, only the currently active workspace button is shown.
|
||||
|
||||
*hide-empty*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
If true, buttons for empty (client_count == 0) workspaces are hidden, unless the workspace is active.
|
||||
|
||||
*on-click*: ++
|
||||
typeof: string ++
|
||||
Command to execute on left click. Typically set to *activate* or *toggle*.
|
||||
|
||||
*on-click-middle*: ++
|
||||
typeof: string ++
|
||||
Command for middle click. Same actions as *on-click*.
|
||||
|
||||
*on-click-right*: ++
|
||||
typeof: string ++
|
||||
Command for right click. Same actions as *on-click*.
|
||||
|
||||
*overview-label*: ++
|
||||
typeof: string ++
|
||||
default: "OVERVIEW" ++
|
||||
Label shown on the overview button when the overview is active.
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Enables the module to consume leftover space.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{value}*: Workspace index (same as *{index}* for unnamed workspaces).
|
||||
|
||||
*{name}*: Workspace name (equal to the index for unnamed workspaces in Mango).
|
||||
|
||||
*{icon}*: Icon selected from *format-icons* based on workspace index and state.
|
||||
|
||||
*{index}*: Numeric index of the workspace.
|
||||
|
||||
*{output}*: Name of the output where the workspace is located.
|
||||
|
||||
# CLICK ACTIONS
|
||||
|
||||
When a tag button is clicked, the action from *on-click* (or its middle/right variants) is evaluated.
|
||||
Supported actions:
|
||||
|
||||
- *activate*: dispatch view,<index>
|
||||
- *toggle*: dispatch toggleview,<index>
|
||||
|
||||
When the overview button is clicked, the actions change to:
|
||||
|
||||
- *activate*: dispatch overview
|
||||
- *toggle*: dispatch toggleoverview
|
||||
|
||||
# EXAMPLES
|
||||
|
||||
```
|
||||
"mango/workspaces": {
|
||||
"format": "{icon}",
|
||||
"format-icons": {
|
||||
"1": "一",
|
||||
"2": "二",
|
||||
"active": "",
|
||||
"default": "",
|
||||
"urgent": "",
|
||||
"empty": ""
|
||||
},
|
||||
"on-click": "activate",
|
||||
"on-click-right": "toggle",
|
||||
"overview-label": ""
|
||||
}
|
||||
```
|
||||
|
||||
# STYLE
|
||||
|
||||
- *#workspaces button*
|
||||
- *#workspaces button.active* – the workspace is active (visible) on its output.
|
||||
- *#workspaces button.urgent* – the workspace has at least one urgent window.
|
||||
- *#workspaces button.empty* – the workspace contains no clients.
|
||||
- *#workspaces button.current_output* – the workspace belongs to the output where the bar is shown.
|
||||
- *#workspaces button.overview* – the overview button (visible in overview mode).
|
||||
@@ -29,6 +29,11 @@ Addressed by *mpd*
|
||||
default: 5 ++
|
||||
The interval in which the connection to the MPD server is retried
|
||||
|
||||
*playing-interval*: ++
|
||||
typeof: integer++
|
||||
default: 1000 ++
|
||||
The interval (in milliseconds) in which the playing state is updated.
|
||||
|
||||
*timeout*: ++
|
||||
typeof: integer++
|
||||
default: 30 ++
|
||||
|
||||
@@ -21,6 +21,10 @@ Addressed by *niri/language*
|
||||
typeof: string++
|
||||
Provide an alternative name to display per language where <lang> is the language of your choosing. Can be passed multiple times with multiple languages as shown by the example below.
|
||||
|
||||
*format-<lang>-<variant>* ++
|
||||
typeof: string ++
|
||||
Like *format-<lang>* but also matches the layout variant, taking precedence over *format-<lang>* when both the language and variant match.
|
||||
|
||||
*menu*: ++
|
||||
typeof: string ++
|
||||
Action that popups the menu.
|
||||
|
||||
@@ -48,6 +48,10 @@ See the output of "niri msg windows" for examples
|
||||
|
||||
*{app_id}*: The current app ID of the focused window.
|
||||
|
||||
*{col}*: The current column of the focused window in the workspace.
|
||||
|
||||
*{max_col}*: The maximum column inside the workspace of the focused window.
|
||||
|
||||
# REWRITE RULES
|
||||
|
||||
*rewrite* is an object where keys are regular expressions and values are
|
||||
|
||||
@@ -17,6 +17,28 @@ Addressed by *niri/workspaces*
|
||||
default: false ++
|
||||
If set to false, workspaces will only be shown on the output they are on. If set to true all workspaces will be shown on every output.
|
||||
|
||||
*sort-by-name*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Sort workspaces by name (numeric sort when all names are numbers). Unnamed workspaces fall back to their index on the output.
|
||||
|
||||
*sort-by-coordinates*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Sort workspaces by output and index. If both *sort-by-name* and *sort-by-coordinates* are true, sorting by name is applied.
|
||||
|
||||
*sort-by-id*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Sort workspaces by id, taking precedence over other sort options.
|
||||
|
||||
*sort-by-number*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Deprecated alias for *sort-by-id*; prefer *sort-by-id* instead.
|
||||
|
||||
If none of the sorting options are enabled, workspaces keep their output/index order.
|
||||
|
||||
*format*: ++
|
||||
typeof: string ++
|
||||
default: {value} ++
|
||||
@@ -31,6 +53,11 @@ Addressed by *niri/workspaces*
|
||||
default: false ++
|
||||
If set to false, you can click to change workspace. If set to true this behaviour is disabled.
|
||||
|
||||
*enable-bar-scroll*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
If set to false, you can't scroll to cycle throughout workspaces from the entire bar. If set to true this behaviour is enabled.
|
||||
|
||||
*disable-markup*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
@@ -41,6 +68,11 @@ Addressed by *niri/workspaces*
|
||||
default: false ++
|
||||
If set to true, only the active or focused workspace will be shown.
|
||||
|
||||
*hide-empty*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
If set to true, empty workspaces will not be shown.
|
||||
|
||||
*on-update*: ++
|
||||
typeof: string ++
|
||||
Command to execute when the module is updated.
|
||||
@@ -63,6 +95,8 @@ as defined by niri.
|
||||
|
||||
*{output}*: Output where the workspace is located.
|
||||
|
||||
*{total}*: The total number of workspaces.
|
||||
|
||||
# ICONS
|
||||
|
||||
Additional to workspace name matching, the following *format-icons* can be set.
|
||||
|
||||
@@ -25,8 +25,8 @@ $XDG_CONFIG_HOME/waybar/config
|
||||
:[ Message displayed on the bar. {icon} and {profile} are respectively substituted with the icon representing the active profile and its full name.
|
||||
|[ *tooltip-format*
|
||||
:[ string
|
||||
:[ "Power profile: {profile}\\nDriver: {driver}"
|
||||
:[ Messaged displayed in the module tooltip. {icon} and {profile} are respectively substituted with the icon representing the active profile and its full name.
|
||||
:[ "Power profile: {profile}\\nCPU driver: {cpu_driver}\\nPlatform driver: {platform_driver}"
|
||||
:[ Messaged displayed in the module tooltip. {icon} and {profile} are respectively substituted with the icon representing the active profile and its full name. {cpu_driver} and {platform_driver} are substituted with the CPU and platform drivers reported by recent power-profiles-daemon versions. {driver} is kept for backward compatibility: it resolves to the legacy single driver on older daemons and falls back to the CPU driver on recent ones.
|
||||
|[ *tooltip*
|
||||
:[ bool
|
||||
:[ true
|
||||
@@ -51,7 +51,7 @@ Compact display (default config):
|
||||
```
|
||||
"power-profiles-daemon": {
|
||||
"format": "{icon}",
|
||||
"tooltip-format": "Power profile: {profile}\nDriver: {driver}",
|
||||
"tooltip-format": "Power profile: {profile}\nCPU driver: {cpu_driver}\nPlatform driver: {platform_driver}",
|
||||
"tooltip": true,
|
||||
"format-icons": {
|
||||
"default": "",
|
||||
@@ -67,7 +67,7 @@ Display the full profile name:
|
||||
```
|
||||
"power-profiles-daemon": {
|
||||
"format": "{icon} {profile}",
|
||||
"tooltip-format": "Power profile: {profile}\nDriver: {driver}",
|
||||
"tooltip-format": "Power profile: {profile}\nCPU driver: {cpu_driver}\nPlatform driver: {platform_driver}",
|
||||
"tooltip": true,
|
||||
"format-icons": {
|
||||
"default": "",
|
||||
|
||||
@@ -38,16 +38,46 @@ The volume can be controlled by dragging the slider across the bar or clicking o
|
||||
default: false ++
|
||||
Enables this module to consume all left over space dynamically.
|
||||
|
||||
*zero-on-mute*: ++
|
||||
typeof: bool ++
|
||||
default: true ++
|
||||
`true` = The slider will be set to `min` when the source/sink is muted. ++
|
||||
`false` = The slider will continue to show the unmuted volume level when the source/sink is muted.
|
||||
|
||||
*unmute-on-volume-change*: ++
|
||||
typeof: bool ++
|
||||
default: true ++
|
||||
Specifies whether to unmute a muted souce/sink when its volume is changed by the user moving the slider.
|
||||
|
||||
*target*: ++
|
||||
typeof: string ++
|
||||
default: sink ++
|
||||
The audio target to control. Can be either `sink` (output/speakers) or `source` (input/microphone).
|
||||
|
||||
*ignored-sinks*: ++
|
||||
typeof: array ++
|
||||
default: empty ++
|
||||
A list of sink descriptions to ignore when tracking the default sink, so switching to those sinks does not update the slider.
|
||||
|
||||
# EXAMPLES
|
||||
|
||||
```
|
||||
"modules-right": [
|
||||
"pulseaudio/slider",
|
||||
"pulseaudio/slider#out",
|
||||
"pulseaudio/slider#in",
|
||||
],
|
||||
"pulseaudio/slider": {
|
||||
"pulseaudio/slider#out": {
|
||||
"min": 0,
|
||||
"max": 100,
|
||||
"orientation": "horizontal"
|
||||
"orientation": "horizontal",
|
||||
"zero-on-mute": false,
|
||||
"unmute-on-volume-change": false
|
||||
},
|
||||
"pulseaudio/slider#in": {
|
||||
"min": 0,
|
||||
"max": 100,
|
||||
"orientation": "horizontal",
|
||||
"target": "source"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -58,6 +88,9 @@ The slider is a component with multiple CSS Nodes, of which the following are ex
|
||||
*#pulseaudio-slider*: ++
|
||||
Controls the style of the box *around* the slider and bar.
|
||||
|
||||
*#pulseaudio-slider.muted*: ++
|
||||
Controls the style when the audio source/sink is muted.
|
||||
|
||||
*#pulseaudio-slider slider*: ++
|
||||
Controls the style of the slider handle.
|
||||
|
||||
@@ -91,4 +124,8 @@ The slider is a component with multiple CSS Nodes, of which the following are ex
|
||||
border-radius: 5px;
|
||||
background: green;
|
||||
}
|
||||
|
||||
#pulseaudio-slider.muted highlight {
|
||||
background-color: orange;
|
||||
}
|
||||
```
|
||||
|
||||
@@ -117,6 +117,10 @@ Additionally, you can control the volume by scrolling *up* or *down* while the c
|
||||
typeof: array ++
|
||||
Sinks in this list will not be shown as active sink by Waybar. Entries should be the sink's description field.
|
||||
|
||||
*sink-mapping*: ++
|
||||
typeof: object ++
|
||||
Sinks named by the values of this mapping will be considered to be the current sink instead of the sinks named by the respective keys.
|
||||
|
||||
*menu*: ++
|
||||
typeof: string ++
|
||||
Action that popups the menu.
|
||||
@@ -135,6 +139,11 @@ Additionally, you can control the volume by scrolling *up* or *down* while the c
|
||||
default: false ++
|
||||
Enables this module to consume all left over space dynamically.
|
||||
|
||||
*target*: ++
|
||||
typeof: string ++
|
||||
default: sink ++
|
||||
The audio target to control when scrolling. Can be either `sink` (output/speakers) or `source` (input/microphone).
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{desc}*: Pulseaudio port's description, for bluetooth it'll be the device name.
|
||||
|
||||
@@ -26,6 +26,14 @@ Addressed by *river/tags*
|
||||
default: false ++
|
||||
If set to false, you can left-click to set focused tag. Right-click to toggle tag focus. If set to true this behaviour is disabled.
|
||||
|
||||
*set-tags*: ++
|
||||
typeof: array ++
|
||||
An array of tag bitmasks, one per tag button. Left-clicking a tag sets the focused tags to the corresponding bitmask instead of the single tag. Requires *disable-click* to be false.
|
||||
|
||||
*toggle-tags*: ++
|
||||
typeof: array ++
|
||||
An array of tag bitmasks, one per tag button. Right-clicking a tag toggles the corresponding bitmask in the focused tags instead of the single tag. Requires *disable-click* to be false.
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
@@ -50,10 +58,14 @@ Addressed by *river/tags*
|
||||
- *#tags button.occupied*
|
||||
- *#tags button.focused*
|
||||
- *#tags button.urgent*
|
||||
- *#tags button.output*
|
||||
- *#tags button.tag-N*
|
||||
|
||||
Note that occupied/focused/urgent status may overlap. That is, a tag may be
|
||||
Note that occupied/focused/urgent/output status may overlap. That is, a tag may be
|
||||
both occupied and focused at the same time.
|
||||
|
||||
The *output* style is applied when the river output (e.g. monitor) of the current bar is focused.
|
||||
|
||||
# SEE ALSO
|
||||
|
||||
waybar(5), river(1)
|
||||
|
||||
+28
-16
@@ -8,13 +8,27 @@ waybar-styles - using stylesheets for waybar
|
||||
|
||||
Waybar uses Cascading Style Sheets (CSS) to configure its appearance.
|
||||
|
||||
It uses the first file found in this search order:
|
||||
When the system appearance is light, Waybar first looks for *style-light.css*.
|
||||
When the system appearance is dark, Waybar first looks for *style-dark.css*.
|
||||
If no appearance-specific stylesheet is found, it falls back to *style.css*.
|
||||
|
||||
- *$XDG_CONFIG_HOME/waybar/style.css*
|
||||
- *~/.config/waybar/style.css*
|
||||
- *~/waybar/style.css*
|
||||
- */etc/xdg/waybar/style.css*
|
||||
- *@sysconfdir@/xdg/waybar/style.css*
|
||||
Waybar uses the first file found in this search order for each stylesheet name:
|
||||
|
||||
- *$XDG_CONFIG_HOME/waybar/<stylesheet>*
|
||||
- *~/.config/waybar/<stylesheet>*
|
||||
- *~/waybar/<stylesheet>*
|
||||
- */etc/xdg/waybar/<stylesheet>*
|
||||
- *@sysconfdir@/xdg/waybar/<stylesheet>*
|
||||
|
||||
For example, a light theme is loaded from the first available file among:
|
||||
|
||||
- *$XDG_CONFIG_HOME/waybar/style-light.css*
|
||||
- *~/.config/waybar/style-light.css*
|
||||
- *~/waybar/style-light.css*
|
||||
- */etc/xdg/waybar/style-light.css*
|
||||
- *@sysconfdir@/xdg/waybar/style-light.css*
|
||||
|
||||
If no file is found there, Waybar repeats the same search using *style.css*.
|
||||
|
||||
# EXAMPLE
|
||||
|
||||
@@ -47,14 +61,13 @@ configured in your `config.jsonc`. If set to `false`, when hovering the module a
|
||||
will not be shown. Default behavior is to indicate an interaction event is
|
||||
available.
|
||||
|
||||
There are more cursor types to choose from by setting the `cursor` option to
|
||||
a number, see Gdk3 official docs for all possible cursor types:
|
||||
https://docs.gtk.org/gdk3/enum.CursorType.html.
|
||||
However, note that not all cursor options listed may be available on
|
||||
your system. If you attempt to use a cursor which is not available, the
|
||||
application will crash.
|
||||
If set to a string value, it must be a valid cursor name
|
||||
(e.g. `"pointer"`, `"default"`, `"grab"`, `"text"`, `"crosshair"`, etc.),
|
||||
see the cursor-shape-v1 protocol for all possible cursor types:
|
||||
https://wayland.app/protocols/cursor-shape-v1#wp_cursor_shape_device_v1:enum:shape.
|
||||
Depending on the compositor and cursor theme used, cursors not listed in the protocol may also work.
|
||||
|
||||
Example of disabling pointer(`Gdk::Hand2`) cursor type on a custom module:
|
||||
Example of disabling the cursor on a custom module:
|
||||
|
||||
```
|
||||
"custom/my-custom-module": {
|
||||
@@ -63,13 +76,12 @@ Example of disabling pointer(`Gdk::Hand2`) cursor type on a custom module:
|
||||
}
|
||||
```
|
||||
|
||||
Example of setting cursor type to `Gdk::Boat`(according to
|
||||
https://docs.gtk.org/gdk3/enum.CursorType.html#boat):
|
||||
Example of setting the cursor type to `"grab"`:
|
||||
|
||||
```
|
||||
"custom/my-custom-module": {
|
||||
...
|
||||
"cursor": 8,
|
||||
"cursor": "grab",
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -22,6 +22,11 @@ Addressed by *sway/workspaces*
|
||||
default: {value} ++
|
||||
The format, how information should be displayed.
|
||||
|
||||
*format-for-negative-index*: ++
|
||||
typeof: string ++
|
||||
default: *format* ++
|
||||
An alternative format, which will be used for workspaces with no explict or negative index ("num" in sway terms). Requires *format* to be set.
|
||||
|
||||
*format-icons*: ++
|
||||
typeof: array ++
|
||||
Based on the workspace name and state, the corresponding icon gets selected. See *icons*.
|
||||
@@ -65,6 +70,11 @@ Addressed by *sway/workspaces*
|
||||
default: false ++
|
||||
If set to true. Only focused workspaces will be shown.
|
||||
|
||||
*ignore-workspaces*: ++
|
||||
typeof: array ++
|
||||
default: empty ++
|
||||
List of regular expressions. Workspaces whose name matches any of the given patterns are not shown.
|
||||
|
||||
*persistent-workspaces*: ++
|
||||
typeof: json (see below) ++
|
||||
default: empty ++
|
||||
@@ -110,6 +120,12 @@ warp-on-scroll: ++
|
||||
default: false ++
|
||||
Enables this module to consume all left over space dynamically.
|
||||
|
||||
*output-classes*: ++
|
||||
typeof: array ++
|
||||
Specify additional CSS classes to be added to workspace indicators based on the output on which the associated workspace is located.
|
||||
Keys are output names and values are class names like *${output}: {output-class}*.
|
||||
Assignment in config is used to keep the stylesheet independent of the available outputs.
|
||||
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
@@ -147,6 +163,7 @@ an empty list denoting all outputs.
|
||||
"3": [], // Always show a workspace with name '3', on all outputs if it does not exist
|
||||
"4": ["eDP-1"], // Always show a workspace with name '4', on output 'eDP-1' if it does not exist
|
||||
"5": ["eDP-1", "DP-2"] // Always show a workspace with name '5', on outputs 'eDP-1' and 'DP-2' if it does not exist
|
||||
"6": ["MonitorMaker 3000 ABC0123"], // Always show a workspace with name '6' on outputs with an identifier 'MonitorMaker 3000 ABC0123' (usually a triple of vendor/model/serial)
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -187,6 +204,13 @@ n.b.: the list of outputs can be obtained from command line using *swaymsg -t ge
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
"sway/workspaces": {
|
||||
"format": "{index} - {name}",
|
||||
"format-for-negative-index": "{name}"
|
||||
}
|
||||
```
|
||||
|
||||
# Style
|
||||
|
||||
- *#workspaces button*
|
||||
@@ -197,3 +221,4 @@ n.b.: the list of outputs can be obtained from command line using *swaymsg -t ge
|
||||
- *#workspaces button.empty*
|
||||
- *#workspaces button.current_output*
|
||||
- *#workspaces button#sway-workspace-${name}*
|
||||
- *#workspaces button.${output-class}*
|
||||
|
||||
@@ -27,9 +27,20 @@ Addressed by *temperature*
|
||||
The path of the hwmon-directory of the device, e.g. */sys/devices/pci0000:00/0000:00:18.3/hwmon*. (Note that the subdirectory *hwmon/hwmon#*, where *#* is a number is not part of the path!) Has to be used together with *input-filename*.
|
||||
This can also be an array of strings, for which, it just works like *hwmon-path*.
|
||||
|
||||
*hwmon-name*: ++
|
||||
typeof: string ++
|
||||
Select a hwmon device by its name (from /sys/class/hwmon/\*/name), e.g. *amdgpu*.
|
||||
Requires *input-filename* to be set.
|
||||
Cannot be used together with *hwmon-path* or *hwmon-path-abs*.
|
||||
|
||||
*input-filename*: ++
|
||||
typeof: string ++
|
||||
The temperature filename of your *hwmon-path-abs*, e.g. *temp1_input*
|
||||
The temperature filename of your *hwmon-path-abs* (also used by *hwmon-by-name*), e.g. *temp1_input*
|
||||
|
||||
*hwmon-by-name*: ++
|
||||
typeof: string ++
|
||||
The substring to search for in */sys/class/hwmon/hwmonX/name* (where hwmonX is any folder in */sys/class/hwmon/*).
|
||||
Waybar will search for every directory in */sys/class/hwmon/* and uses the directory in which the *name* matches *hwmon-by-name*.
|
||||
|
||||
*warning-threshold*: ++
|
||||
typeof: integer ++
|
||||
|
||||
@@ -26,6 +26,16 @@ Addressed by *wayfire/workspaces*
|
||||
default: false ++
|
||||
If set to false, you can click to change workspace. If set to true this behaviour is disabled.
|
||||
|
||||
*disable-scroll*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
If set to false, you can scroll to cycle through workspaces. If set to true this behaviour is disabled.
|
||||
|
||||
*enable-bar-scroll*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
If set to false, you can't scroll to cycle through workspaces from the entire bar. If set to true this behaviour is enabled.
|
||||
|
||||
*disable-markup*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
|
||||
@@ -63,6 +63,11 @@ The *wireplumber* module displays the current volume reported by WirePlumber.
|
||||
default: 1.0 ++
|
||||
The speed at which to change the volume when scrolling.
|
||||
|
||||
*scroll-scale*: ++
|
||||
typeof: string ++
|
||||
default: cubic_percent
|
||||
The scale to use for the scrolling volume change. Options are 'linear', 'db', 'cubic', and 'cubic_percent'.
|
||||
|
||||
*on-click*: ++
|
||||
typeof: string ++
|
||||
Command to execute when clicked on the module.
|
||||
@@ -107,7 +112,13 @@ The *wireplumber* module displays the current volume reported by WirePlumber.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{volume}*: Volume in percentage.
|
||||
*{volume}*: Volume in percentage, cubic scale as integer.
|
||||
|
||||
*{volume_linear}*: Volume in linear scale as float.
|
||||
|
||||
*{volume_cubic}*: Volume in cubic scale as float.
|
||||
|
||||
*{volume_db}*: Volume in decibel scale as float.
|
||||
|
||||
*{node_name}*: The node's nickname as reported by WirePlumber (*node.nick* property)
|
||||
|
||||
@@ -143,6 +154,16 @@ The *wireplumber* module displays the current volume reported by WirePlumber.
|
||||
}
|
||||
```
|
||||
|
||||
## Use a Different Scale
|
||||
|
||||
```
|
||||
"wireplumber": {
|
||||
"format": "{volume_db:.2f}dB",
|
||||
"scroll-scale": "db",
|
||||
"scroll-step": 2.5
|
||||
}
|
||||
```
|
||||
|
||||
# STYLE
|
||||
|
||||
- *#wireplumber*
|
||||
|
||||
@@ -18,6 +18,13 @@ Addressed by *wlr/taskbar*
|
||||
default: false ++
|
||||
If set to false applications on the waybar's current output will be shown. Otherwise, all applications are shown.
|
||||
|
||||
*bar-css-states*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
If set to true, application state is exposed as CSS classes on the Waybar
|
||||
window. Maximized and fullscreen state is aggregated across applications
|
||||
known to belong to the active workspace. See *Bar state style* below.
|
||||
|
||||
*format*: ++
|
||||
typeof: string ++
|
||||
default: {icon} ++
|
||||
@@ -52,11 +59,26 @@ Addressed by *wlr/taskbar*
|
||||
default: false ++
|
||||
If set to true, always reorder the tasks in the taskbar so that the currently active one is first. Otherwise don't reorder.
|
||||
|
||||
*active-only*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
If set to true, only the currently active application button is shown.
|
||||
Other applications remain tracked and reappear when activated.
|
||||
|
||||
*sort-by-app-id*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
If set to true, group tasks by their app_id. Cannot be used with 'active-first'.
|
||||
|
||||
*justify*: ++
|
||||
typeof: string ++
|
||||
The alignment of the text within the module's box, allowing options 'left', 'right', or 'center' to define the positioning.
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
If set to true, task buttons stretch to fill the available space in the taskbar and long titles are ellipsized to fit. Only takes effect on a horizontal bar; on a vertical bar the buttons keep their content-based size. If set to false, buttons are sized to their content.
|
||||
|
||||
*on-click*: ++
|
||||
typeof: string ++
|
||||
The action which should be triggered when clicking on the application button with the left mouse button.
|
||||
@@ -156,3 +178,35 @@ Invalid expressions (e.g., mismatched parentheses) are skipped.
|
||||
- *#taskbar button.minimized*
|
||||
- *#taskbar button.active*
|
||||
- *#taskbar button.fullscreen*
|
||||
|
||||
# Bar state style
|
||||
|
||||
When *bar-css-states* is enabled, the following classes are added to
|
||||
*window#waybar*:
|
||||
|
||||
- *window#waybar.toplevel-active*
|
||||
- *window#waybar.toplevel-maximized*
|
||||
- *window#waybar.toplevel-minimized*
|
||||
- *window#waybar.toplevel-fullscreen*
|
||||
|
||||
The active, minimized classes describe the active application. The maximized
|
||||
and fullscreen classes are set if any non-minimized application known to belong
|
||||
to the active workspace has that state.
|
||||
|
||||
Workspace membership is learned when an application is activated and requires
|
||||
the compositor to support *ext-workspace-v1*. Before an application has been
|
||||
activated during the current Waybar session, its workspace may be unknown. On
|
||||
compositors without *ext-workspace-v1*, these classes fall back to the active
|
||||
application's state.
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
window#waybar {
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
window#waybar.toplevel-maximized {
|
||||
background-color: rgba(0, 0, 0, 1);
|
||||
}
|
||||
```
|
||||
|
||||
+9
-1
@@ -19,7 +19,7 @@ Valid locations for this file are:
|
||||
A good starting point is the default configuration found at https://github.com/Alexays/Waybar/blob/master/resources/config.jsonc
|
||||
Also, a minimal example configuration can be found at the bottom of this man page.
|
||||
|
||||
The visual display elements for waybar use a CSS stylesheet, see *waybar-styles(5)* for details.
|
||||
The visual display elements for waybar use a CSS stylesheet. Waybar supports *style.css* and the appearance-specific *style-light.css* and *style-dark.css* files; see *waybar-styles(5)* for details.
|
||||
|
||||
# BAR CONFIGURATION
|
||||
|
||||
@@ -168,6 +168,7 @@ The visual display elements for waybar use a CSS stylesheet, see *waybar-styles(
|
||||
# MODULE FORMAT
|
||||
|
||||
You can use PangoMarkupFormat (See https://developer.gnome.org/pango/stable/PangoMarkupFormat.html#PangoMarkupFormat).
|
||||
Tooltip appearance is generally controlled globally via CSS and cannot be truly scoped per module. Some modules (such as the clock) provide limited workarounds for customization.
|
||||
|
||||
e.g.
|
||||
|
||||
@@ -374,6 +375,13 @@ A group may hide all but one element, showing them only on mouse hover. In order
|
||||
Defines the direction of the transition animation. If true, the hidden elements will slide from left to right. If false, they will slide from right to left.
|
||||
When the bar is vertical, it reads as top-to-bottom.
|
||||
|
||||
*reveal-by-default*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Whether the child should be revealed when Waybar starts up. This has to be used with click-to-reveal to take effect.
|
||||
|
||||
Group drawers are also given the `.expanded` CSS class when they are expanded.
|
||||
|
||||
```
|
||||
"group/power": {
|
||||
"orientation": "inherit",
|
||||
|
||||
+31
-1
@@ -111,6 +111,10 @@ gtk_layer_shell = dependency('gtk-layer-shell-0', version: ['>=0.9.0'],
|
||||
default_options: ['introspection=false', 'vapi=false'],
|
||||
fallback: ['gtk-layer-shell', 'gtk_layer_shell'])
|
||||
systemd = dependency('systemd', required: get_option('systemd'))
|
||||
libsystemd = dependency('libsystemd', required: get_option('systemd'))
|
||||
if libsystemd.found()
|
||||
add_project_arguments('-DHAVE_LIBSYSTEMD', language: 'cpp')
|
||||
endif
|
||||
|
||||
cpp_lib_chrono = compiler.compute_int('__cpp_lib_chrono', prefix : '#include <chrono>')
|
||||
have_chrono_timezones = cpp_lib_chrono >= 201611
|
||||
@@ -159,11 +163,13 @@ endif
|
||||
|
||||
src_files = files(
|
||||
'src/factory.cpp',
|
||||
'src/AGraph.cpp',
|
||||
'src/AModule.cpp',
|
||||
'src/ALabel.cpp',
|
||||
'src/AIconLabel.cpp',
|
||||
'src/AAppIconLabel.cpp',
|
||||
'src/modules/custom.cpp',
|
||||
'src/modules/custom_graph.cpp',
|
||||
'src/modules/disk.cpp',
|
||||
'src/modules/idle_inhibitor.cpp',
|
||||
'src/modules/image.cpp',
|
||||
@@ -182,11 +188,13 @@ src_files = files(
|
||||
'src/util/ustring_clen.cpp',
|
||||
'src/util/sanitize_str.cpp',
|
||||
'src/util/rewrite_string.cpp',
|
||||
'src/util/hosts_check.cpp',
|
||||
'src/util/gtk_icon.cpp',
|
||||
'src/util/icon_loader.cpp',
|
||||
'src/util/regex_collection.cpp',
|
||||
'src/util/css_reload_helper.cpp',
|
||||
'src/util/transform_8bit_to_rgba.cpp'
|
||||
'src/util/transform_8bit_to_rgba.cpp',
|
||||
'src/util/utf8_string.cpp'
|
||||
)
|
||||
|
||||
man_files = files(
|
||||
@@ -210,6 +218,7 @@ if is_linux
|
||||
'src/modules/bluetooth.cpp',
|
||||
'src/modules/cffi.cpp',
|
||||
'src/modules/cpu.cpp',
|
||||
'src/modules/cpu_graph.cpp',
|
||||
'src/modules/cpu_frequency/common.cpp',
|
||||
'src/modules/cpu_frequency/linux.cpp',
|
||||
'src/modules/cpu_usage/common.cpp',
|
||||
@@ -234,6 +243,7 @@ elif is_dragonfly or is_freebsd or is_netbsd or is_openbsd
|
||||
src_files += files(
|
||||
'src/modules/cffi.cpp',
|
||||
'src/modules/cpu.cpp',
|
||||
'src/modules/cpu_graph.cpp',
|
||||
'src/modules/cpu_frequency/bsd.cpp',
|
||||
'src/modules/cpu_frequency/common.cpp',
|
||||
'src/modules/cpu_usage/bsd.cpp',
|
||||
@@ -348,6 +358,25 @@ if get_option('niri')
|
||||
)
|
||||
endif
|
||||
|
||||
if get_option('mango')
|
||||
add_project_arguments('-DHAVE_MANGO', language: 'cpp')
|
||||
src_files += files(
|
||||
'src/modules/mango/backend.cpp',
|
||||
'src/modules/mango/language.cpp',
|
||||
'src/modules/mango/keymode.cpp',
|
||||
'src/modules/mango/window.cpp',
|
||||
'src/modules/mango/workspaces.cpp',
|
||||
'src/modules/mango/layout.cpp'
|
||||
)
|
||||
man_files += files(
|
||||
'man/waybar-mango-language.5.scd',
|
||||
'man/waybar-mango-keymode.5.scd',
|
||||
'man/waybar-mango-window.5.scd',
|
||||
'man/waybar-mango-workspaces.5.scd',
|
||||
'man/waybar-mango-layout.5.scd'
|
||||
)
|
||||
endif
|
||||
|
||||
if true
|
||||
add_project_arguments('-DHAVE_WAYFIRE', language: 'cpp')
|
||||
src_files += files(
|
||||
@@ -550,6 +579,7 @@ executable(
|
||||
upower_glib,
|
||||
pipewire,
|
||||
playerctl,
|
||||
libsystemd,
|
||||
libpulse,
|
||||
libjack,
|
||||
libwireplumber,
|
||||
|
||||
+2
-1
@@ -12,7 +12,7 @@ option('dbusmenu-gtk', type: 'feature', value: 'auto', description: 'Enable supp
|
||||
option('man-pages', type: 'feature', value: 'auto', description: 'Generate and install man pages')
|
||||
option('mpd', type: 'feature', value: 'auto', description: 'Enable support for the Music Player Daemon')
|
||||
option('rfkill', type: 'feature', value: 'auto', description: 'Enable support for RFKILL')
|
||||
option('sndio', type: 'feature', value: 'auto', description: 'Enable support for sndio')
|
||||
option('sndio', type: 'feature', value: 'auto', description: 'Enable support for volume control via sndio')
|
||||
option('logind', type: 'feature', value: 'auto', description: 'Enable support for logind')
|
||||
option('tests', type: 'feature', value: 'auto', description: 'Enable tests')
|
||||
option('experimental', type : 'boolean', value : false, description: 'Enable experimental features')
|
||||
@@ -20,5 +20,6 @@ option('jack', type: 'feature', value: 'auto', description: 'Enable support for
|
||||
option('wireplumber', type: 'feature', value: 'auto', description: 'Enable support for WirePlumber')
|
||||
option('cava', type: 'feature', value: 'auto', description: 'Enable support for Cava')
|
||||
option('niri', type: 'boolean', description: 'Enable support for niri')
|
||||
option('mango', type: 'boolean', description: 'Enable support for mango')
|
||||
option('login-proxy', type: 'boolean', description: 'Enable interfacing with dbus login interface')
|
||||
option('gps', type: 'feature', value: 'auto', description: 'Enable support for gps')
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<protocol name="ext_idle_notify_v1">
|
||||
<copyright>
|
||||
Copyright © 2015 Martin Gräßlin
|
||||
Copyright © 2022 Simon Ser
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the next
|
||||
paragraph) shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
</copyright>
|
||||
|
||||
<interface name="ext_idle_notifier_v1" version="2">
|
||||
<description summary="idle notification manager">
|
||||
This interface allows clients to monitor user idle status.
|
||||
|
||||
After binding to this global, clients can create ext_idle_notification_v1
|
||||
objects to get notified when the user is idle for a given amount of time.
|
||||
</description>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="destroy the manager">
|
||||
Destroy the manager object. All objects created via this interface
|
||||
remain valid.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<request name="get_idle_notification">
|
||||
<description summary="create a notification object">
|
||||
Create a new idle notification object.
|
||||
|
||||
The notification object has a minimum timeout duration and is tied to a
|
||||
seat. The client will be notified if the seat is inactive for at least
|
||||
the provided timeout. See ext_idle_notification_v1 for more details.
|
||||
|
||||
A zero timeout is valid and means the client wants to be notified as
|
||||
soon as possible when the seat is inactive.
|
||||
</description>
|
||||
<arg name="id" type="new_id" interface="ext_idle_notification_v1"/>
|
||||
<arg name="timeout" type="uint" summary="minimum idle timeout in msec"/>
|
||||
<arg name="seat" type="object" interface="wl_seat"/>
|
||||
</request>
|
||||
|
||||
<!-- Version 2 additions -->
|
||||
|
||||
<request name="get_input_idle_notification" since="2">
|
||||
<description summary="create a notification object">
|
||||
Create a new idle notification object to track input from the
|
||||
user, such as keyboard and mouse movement. Because this object is
|
||||
meant to track user input alone, it ignores idle inhibitors.
|
||||
|
||||
The notification object has a minimum timeout duration and is tied to a
|
||||
seat. The client will be notified if the seat is inactive for at least
|
||||
the provided timeout. See ext_idle_notification_v1 for more details.
|
||||
|
||||
A zero timeout is valid and means the client wants to be notified as
|
||||
soon as possible when the seat is inactive.
|
||||
</description>
|
||||
<arg name="id" type="new_id" interface="ext_idle_notification_v1"/>
|
||||
<arg name="timeout" type="uint" summary="minimum idle timeout in msec"/>
|
||||
<arg name="seat" type="object" interface="wl_seat"/>
|
||||
</request>
|
||||
|
||||
</interface>
|
||||
|
||||
<interface name="ext_idle_notification_v1" version="2">
|
||||
<description summary="idle notification">
|
||||
This interface is used by the compositor to send idle notification events
|
||||
to clients.
|
||||
|
||||
Initially the notification object is not idle. The notification object
|
||||
becomes idle when no user activity has happened for at least the timeout
|
||||
duration, starting from the creation of the notification object. User
|
||||
activity may include input events or a presence sensor, but is
|
||||
compositor-specific.
|
||||
|
||||
How this notification responds to idle inhibitors depends on how
|
||||
it was constructed. If constructed from the
|
||||
get_idle_notification request, then if an idle inhibitor is
|
||||
active (e.g. another client has created a zwp_idle_inhibitor_v1
|
||||
on a visible surface), the compositor must not make the
|
||||
notification object idle. However, if constructed from the
|
||||
get_input_idle_notification request, then idle inhibitors are
|
||||
ignored, and only input from the user, e.g. from a keyboard or
|
||||
mouse, counts as activity.
|
||||
|
||||
When the notification object becomes idle, an idled event is sent. When
|
||||
user activity starts again, the notification object stops being idle,
|
||||
a resumed event is sent and the timeout is restarted.
|
||||
</description>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="destroy the notification object">
|
||||
Destroy the notification object.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<event name="idled">
|
||||
<description summary="notification object is idle">
|
||||
This event is sent when the notification object becomes idle.
|
||||
|
||||
It's a compositor protocol error to send this event twice without a
|
||||
resumed event in-between.
|
||||
</description>
|
||||
</event>
|
||||
|
||||
<event name="resumed">
|
||||
<description summary="notification object is no longer idle">
|
||||
This event is sent when the notification object stops being idle.
|
||||
|
||||
It's a compositor protocol error to send this event twice without an
|
||||
idled event in-between. It's a compositor protocol error to send this
|
||||
event prior to any idled event.
|
||||
</description>
|
||||
</event>
|
||||
</interface>
|
||||
</protocol>
|
||||
@@ -29,6 +29,7 @@ client_protocols = [
|
||||
['river-status-unstable-v1.xml'],
|
||||
['river-control-unstable-v1.xml'],
|
||||
['dwl-ipc-unstable-v2.xml'],
|
||||
['ext-idle-notify-v1.xml'],
|
||||
]
|
||||
|
||||
if wayland_protos.version().version_compare('>=1.39')
|
||||
|
||||
@@ -155,7 +155,7 @@
|
||||
},
|
||||
"power-profiles-daemon": {
|
||||
"format": "{icon}",
|
||||
"tooltip-format": "Power profile: {profile}\nDriver: {driver}",
|
||||
"tooltip-format": "Power profile: {profile}\nCPU driver: {cpu_driver}\nPlatform driver: {platform_driver}",
|
||||
"tooltip": true,
|
||||
"format-icons": {
|
||||
"default": "",
|
||||
|
||||
@@ -112,17 +112,19 @@ class PlayerManager:
|
||||
logger.debug(f"Metadata changed for player {player.props.player_name}")
|
||||
player_name = player.props.player_name
|
||||
artist = player.get_artist()
|
||||
artist = artist.replace("&", "&")
|
||||
artist = artist and artist.replace("&", "&")
|
||||
title = player.get_title()
|
||||
title = title.replace("&", "&")
|
||||
title = title and title.replace("&", "&")
|
||||
|
||||
track_info = ""
|
||||
if player_name == "spotify" and "mpris:trackid" in metadata.keys() and ":ad:" in player.props.metadata["mpris:trackid"]:
|
||||
track_info = "Advertisement"
|
||||
elif artist is not None and title is not None:
|
||||
track_info = f"{artist} - {title}"
|
||||
else:
|
||||
elif title is not None:
|
||||
track_info = title
|
||||
elif artist is not None:
|
||||
track_info = artist
|
||||
|
||||
if track_info:
|
||||
if player.props.status == "Playing":
|
||||
|
||||
+298
@@ -0,0 +1,298 @@
|
||||
#include "AGraph.hpp"
|
||||
|
||||
#include <cairomm/context.h>
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <util/command.hpp>
|
||||
|
||||
#include "config.hpp"
|
||||
|
||||
namespace waybar {
|
||||
|
||||
AGraph::AGraph(const Json::Value& config, const std::string& name, const std::string& id,
|
||||
uint16_t interval, bool enable_click, bool enable_scroll)
|
||||
: AModule(config, name, id,
|
||||
config["format-alt"].isString() || config["menu"].isString() || enable_click,
|
||||
enable_scroll),
|
||||
interval_(config_["interval"] == "once"
|
||||
? std::chrono::seconds::max()
|
||||
: std::chrono::seconds(
|
||||
config_["interval"].isUInt() ? config_["interval"].asUInt() : interval)) {
|
||||
graph_.signal_draw().connect(sigc::mem_fun(*this, &AGraph::onDraw));
|
||||
graph_.set_name(name);
|
||||
if (!id.empty()) {
|
||||
graph_.get_style_context()->add_class(id);
|
||||
}
|
||||
graph_.get_style_context()->add_class(MODULE_CLASS);
|
||||
if (config_["width"].isUInt()) {
|
||||
graph_.set_size_request(config_["width"].asUInt(), -1);
|
||||
} else {
|
||||
graph_.set_size_request(100, -1);
|
||||
}
|
||||
|
||||
event_box_.add(graph_);
|
||||
|
||||
if (config_["datapoints"].isUInt() && config_["datapoints"].asUInt() > 0) {
|
||||
datapoints_ = config_["datapoints"].asUInt();
|
||||
}
|
||||
|
||||
if (config_["graph_type"].isString()) {
|
||||
std::string type = config_["graph_type"].asString();
|
||||
if (type == "line") {
|
||||
graph_type_ = GraphType::LINE;
|
||||
} else if (type == "bar") {
|
||||
graph_type_ = GraphType::BAR;
|
||||
} else if (type == "gauge") {
|
||||
graph_type_ = GraphType::GAUGE;
|
||||
}
|
||||
}
|
||||
|
||||
// If a GTKMenu is requested in the config
|
||||
if (config_["menu"].isString()) {
|
||||
// Create the GTKMenu widget
|
||||
try {
|
||||
// Check that the file exists
|
||||
std::string menuFile = config_["menu-file"].asString();
|
||||
|
||||
// there might be "~" or "$HOME" in original path, try to expand it.
|
||||
auto result = Config::tryExpandPath(menuFile, "");
|
||||
if (result.empty()) {
|
||||
throw std::runtime_error("Failed to expand file: " + menuFile);
|
||||
}
|
||||
|
||||
menuFile = result.front();
|
||||
// Read the menu descriptor file
|
||||
std::ifstream file(menuFile);
|
||||
if (!file.is_open()) {
|
||||
throw std::runtime_error("Failed to open file: " + menuFile);
|
||||
}
|
||||
std::stringstream fileContent;
|
||||
fileContent << file.rdbuf();
|
||||
GtkBuilder* builder = gtk_builder_new();
|
||||
|
||||
// Make the GtkBuilder and check for errors in his parsing
|
||||
if (gtk_builder_add_from_string(builder, fileContent.str().c_str(), -1, nullptr) == 0U) {
|
||||
throw std::runtime_error("Error found in the file " + menuFile);
|
||||
}
|
||||
|
||||
menu_ = gtk_builder_get_object(builder, "menu");
|
||||
if (menu_ == nullptr) {
|
||||
throw std::runtime_error("Failed to get 'menu' object from GtkBuilder");
|
||||
}
|
||||
submenus_ = std::map<std::string, GtkMenuItem*>();
|
||||
menuActionsMap_ = std::map<std::string, std::string>();
|
||||
|
||||
// Linking actions to the GTKMenu based on
|
||||
for (Json::Value::const_iterator it = config_["menu-actions"].begin();
|
||||
it != config_["menu-actions"].end(); ++it) {
|
||||
std::string key = it.key().asString();
|
||||
submenus_[key] = GTK_MENU_ITEM(gtk_builder_get_object(builder, key.c_str()));
|
||||
menuActionsMap_[key] = it->asString();
|
||||
g_signal_connect(submenus_[key], "activate", G_CALLBACK(handleGtkMenuEvent),
|
||||
(gpointer)menuActionsMap_[key].c_str());
|
||||
}
|
||||
} catch (std::runtime_error& e) {
|
||||
spdlog::warn("Error while creating the menu : {}. Menu popup not activated.", e.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto AGraph::update() -> void {
|
||||
graph_.queue_draw();
|
||||
AModule::update();
|
||||
}
|
||||
|
||||
void AGraph::handleGtkMenuEvent(GtkMenuItem* /*menuitem*/, gpointer data) {
|
||||
waybar::util::command::res res = waybar::util::command::exec((char*)data, "GtkMenu");
|
||||
}
|
||||
|
||||
void AGraph::addValue(const int n) {
|
||||
if (datapoints_ > 0 && values_.size() >= datapoints_) {
|
||||
values_.pop_front();
|
||||
}
|
||||
values_.push_back(n);
|
||||
}
|
||||
|
||||
bool AGraph::onDraw(const Cairo::RefPtr<Cairo::Context>& cr) {
|
||||
const int width = graph_.get_allocated_width();
|
||||
const int height = graph_.get_allocated_height() - 1;
|
||||
|
||||
if (values_.empty() || width <= 0 || height <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto style_context = graph_.get_style_context();
|
||||
Gdk::RGBA fg_color = style_context->get_color(Gtk::STATE_FLAG_NORMAL);
|
||||
Gdk::RGBA bg_color = fg_color;
|
||||
bg_color.set_alpha(0.3);
|
||||
|
||||
cr->set_line_width(1.0);
|
||||
|
||||
const double step_width = static_cast<double>(width) / datapoints_;
|
||||
const int values_count = values_.size();
|
||||
const int empty_space = datapoints_ - values_count;
|
||||
|
||||
std::vector<std::pair<double, double>> points;
|
||||
points.reserve(values_count);
|
||||
|
||||
for (int i = empty_space; i < datapoints_; ++i) {
|
||||
double x = i * step_width;
|
||||
int value_index = i - empty_space;
|
||||
int value = values_[value_index];
|
||||
double y = height - (static_cast<double>(value) / 100.0 * height);
|
||||
points.emplace_back(x, y);
|
||||
}
|
||||
if (!points.empty()) {
|
||||
switch (graph_type_) {
|
||||
case GraphType::LINE:
|
||||
drawFilledArea(cr, points, height, bg_color);
|
||||
drawLine(cr, points, fg_color);
|
||||
break;
|
||||
case GraphType::BAR:
|
||||
drawBars(cr, width, height, values_.empty() ? 0 : values_.back(), fg_color);
|
||||
break;
|
||||
case GraphType::GAUGE:
|
||||
drawGauge(cr, width, height, values_.empty() ? 0 : values_.back(), fg_color);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
void AGraph::drawFilledArea(const Cairo::RefPtr<Cairo::Context>& cr,
|
||||
const std::vector<std::pair<double, double>>& points, double height,
|
||||
const Gdk::RGBA& bg_color) {
|
||||
if (points.empty()) return;
|
||||
|
||||
double first_x = points.front().first;
|
||||
double last_x = points.back().first;
|
||||
|
||||
drawPath(cr, points);
|
||||
|
||||
cr->line_to(last_x, height);
|
||||
cr->line_to(first_x, height);
|
||||
cr->close_path();
|
||||
|
||||
cr->set_source_rgba(bg_color.get_red(), bg_color.get_green(), bg_color.get_blue(),
|
||||
bg_color.get_alpha());
|
||||
cr->fill();
|
||||
}
|
||||
|
||||
void AGraph::drawLine(const Cairo::RefPtr<Cairo::Context>& cr,
|
||||
const std::vector<std::pair<double, double>>& points,
|
||||
const Gdk::RGBA& fg_color) {
|
||||
if (points.empty()) return;
|
||||
|
||||
cr->begin_new_path();
|
||||
drawPath(cr, points);
|
||||
|
||||
cr->set_source_rgba(fg_color.get_red(), fg_color.get_green(), fg_color.get_blue(),
|
||||
fg_color.get_alpha());
|
||||
cr->stroke();
|
||||
}
|
||||
|
||||
void AGraph::drawPath(const Cairo::RefPtr<Cairo::Context>& cr,
|
||||
const std::vector<std::pair<double, double>>& points) {
|
||||
if (points.empty()) return;
|
||||
|
||||
bool first_point = true;
|
||||
for (const auto& point : points) {
|
||||
if (first_point) {
|
||||
cr->move_to(point.first, point.second);
|
||||
first_point = false;
|
||||
} else {
|
||||
cr->line_to(point.first, point.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AGraph::drawBars(const Cairo::RefPtr<Cairo::Context>& cr, double width, double height,
|
||||
int current_value, const Gdk::RGBA& fg_color) {
|
||||
current_value = std::min(100, std::max(0, current_value));
|
||||
|
||||
double green_height = height * (std::min(current_value, 40) / 100.0);
|
||||
cr->set_source_rgba(fg_color.get_red(), fg_color.get_green(), fg_color.get_blue(), 0.5);
|
||||
cr->rectangle(0, height - green_height, width, green_height);
|
||||
cr->fill();
|
||||
|
||||
if (current_value > 40) {
|
||||
double yellow_height = height * (std::min(current_value, 75) - 40) / 100.0;
|
||||
cr->set_source_rgba(fg_color.get_red(), fg_color.get_green(), fg_color.get_blue(), 0.7);
|
||||
cr->rectangle(0, height - green_height - yellow_height, width, yellow_height);
|
||||
cr->fill();
|
||||
}
|
||||
|
||||
if (current_value > 75) {
|
||||
double orange_height = height * (std::min(current_value, 85) - 75) / 100.0;
|
||||
cr->set_source_rgba(fg_color.get_red(), fg_color.get_green(), fg_color.get_blue(), 0.85);
|
||||
double yellow_height = height * (std::min(current_value, 75) - 40) / 100.0;
|
||||
cr->rectangle(0, height - green_height - yellow_height - orange_height, width, orange_height);
|
||||
cr->fill();
|
||||
}
|
||||
|
||||
if (current_value > 85) {
|
||||
double red_height = height * (current_value - 85) / 100.0;
|
||||
cr->set_source_rgba(fg_color.get_red(), fg_color.get_green(), fg_color.get_blue(), 1.0);
|
||||
double yellow_height = height * (std::min(current_value, 75) - 40) / 100.0;
|
||||
double orange_height = height * (std::min(current_value, 85) - 75) / 100.0;
|
||||
cr->rectangle(0, height - green_height - yellow_height - orange_height - red_height, width,
|
||||
red_height);
|
||||
cr->fill();
|
||||
}
|
||||
|
||||
double value_height = height * (current_value / 100.0);
|
||||
cr->set_source_rgba(0.2, 0.2, 0.2, 0.8);
|
||||
cr->rectangle(0, height - value_height, width, 2);
|
||||
cr->fill();
|
||||
}
|
||||
|
||||
void AGraph::drawGauge(const Cairo::RefPtr<Cairo::Context>& cr, double width, double height,
|
||||
int current_value, const Gdk::RGBA& fg_color) {
|
||||
double center_x = width / 2.0;
|
||||
double center_y = height;
|
||||
double radius = height / 2.0;
|
||||
|
||||
cr->set_line_width(10.0);
|
||||
|
||||
double angle1 = M_PI;
|
||||
double angle2 = angle1 + 0.3 * angle1;
|
||||
|
||||
// Green section (0-33%)
|
||||
cr->set_source_rgba(fg_color.get_red(), fg_color.get_green(), fg_color.get_blue(), 0.5);
|
||||
cr->arc(center_x, center_y, radius, angle1, angle2);
|
||||
cr->stroke();
|
||||
|
||||
// Yellow section (33-66%)
|
||||
angle1 = angle2;
|
||||
angle2 = angle1 + 0.3 * angle1;
|
||||
cr->set_source_rgba(fg_color.get_red(), fg_color.get_green(), fg_color.get_blue(), 0.75);
|
||||
cr->arc(center_x, center_y, radius, angle1, angle2);
|
||||
cr->stroke();
|
||||
|
||||
// Red section (66-100%)
|
||||
angle1 = angle2;
|
||||
angle2 = 0.0;
|
||||
cr->set_source_rgba(fg_color.get_red(), fg_color.get_green(), fg_color.get_blue(), 1.0);
|
||||
cr->arc(center_x, center_y, radius, angle1, angle2);
|
||||
cr->stroke();
|
||||
|
||||
// Draw needle
|
||||
double percentage = std::min(100, std::max(0, current_value)) / 100.0;
|
||||
double needle_angle = M_PI * percentage;
|
||||
double needle_length = radius;
|
||||
|
||||
double needle_x = center_x - needle_length * cos(needle_angle);
|
||||
double needle_y = center_y - needle_length * sin(needle_angle);
|
||||
|
||||
cr->set_source_rgba(1.0, 1.0, 1.0, 1.0);
|
||||
cr->set_line_width(2.0);
|
||||
cr->begin_new_path();
|
||||
cr->move_to(center_x, center_y);
|
||||
cr->line_to(needle_x, needle_y);
|
||||
cr->stroke();
|
||||
}
|
||||
|
||||
} // namespace waybar
|
||||
+48
-1
@@ -2,6 +2,8 @@
|
||||
|
||||
#include <gdkmm/pixbuf.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <regex>
|
||||
#include <string>
|
||||
|
||||
namespace waybar {
|
||||
|
||||
@@ -9,6 +11,10 @@ AIconLabel::AIconLabel(const Json::Value& config, const std::string& name, const
|
||||
const std::string& format, uint16_t interval, bool ellipsize,
|
||||
bool enable_click, bool enable_scroll)
|
||||
: ALabel(config, name, id, format, interval, ellipsize, enable_click, enable_scroll) {
|
||||
if (config["icon-size"].isUInt()) {
|
||||
app_icon_size_ = config["icon-size"].asUInt();
|
||||
}
|
||||
image_.set_pixel_size(app_icon_size_);
|
||||
event_box_.remove();
|
||||
label_.unset_name();
|
||||
label_.get_style_context()->remove_class(MODULE_CLASS);
|
||||
@@ -55,13 +61,54 @@ AIconLabel::AIconLabel(const Json::Value& config, const std::string& name, const
|
||||
event_box_.add(box_);
|
||||
}
|
||||
|
||||
std::tuple<std::string, std::string> AIconLabel::extractIcon(const std::string& input) {
|
||||
std::string icon_result = "";
|
||||
std::string label_result = input;
|
||||
try {
|
||||
static const std::regex icon_search(R"((?=\\0icon\\1f).+?(?=\\n))");
|
||||
std::smatch icon_match;
|
||||
if (std::regex_search(input, icon_match, icon_search)) {
|
||||
icon_result = icon_match[0].str().substr(9);
|
||||
|
||||
static const std::regex clean_label_pattern(R"(\\0icon\\1f.+?\\n)");
|
||||
label_result = std::regex_replace(input, clean_label_pattern, "");
|
||||
}
|
||||
} catch (const std::exception& e) {
|
||||
spdlog::warn("Error while parsing icon from label. {}", e.what());
|
||||
}
|
||||
|
||||
return std::make_tuple(icon_result, label_result);
|
||||
}
|
||||
|
||||
auto AIconLabel::update() -> void {
|
||||
label_contains_icon = false;
|
||||
|
||||
auto [iconLabel, cleanLabel] = extractIcon(label_.get_label().c_str());
|
||||
label_contains_icon = iconLabel.length() > 0;
|
||||
|
||||
if (label_contains_icon) {
|
||||
label_.set_markup(cleanLabel);
|
||||
|
||||
if (iconLabel.front() == '/') {
|
||||
int scaled_icon_size = app_icon_size_ * image_.get_scale_factor();
|
||||
auto pixbuf = Gdk::Pixbuf::create_from_file(iconLabel, scaled_icon_size, scaled_icon_size);
|
||||
|
||||
auto surface = Gdk::Cairo::create_surface_from_pixbuf(pixbuf, image_.get_scale_factor(),
|
||||
image_.get_window());
|
||||
image_.set(surface);
|
||||
image_.set_visible(true);
|
||||
} else {
|
||||
image_.set_from_icon_name(iconLabel, Gtk::ICON_SIZE_INVALID);
|
||||
image_.set_visible(true);
|
||||
}
|
||||
}
|
||||
|
||||
image_.set_visible(image_.get_visible() && iconEnabled());
|
||||
ALabel::update();
|
||||
}
|
||||
|
||||
bool AIconLabel::iconEnabled() const {
|
||||
return config_["icon"].isBool() ? config_["icon"].asBool() : false;
|
||||
return label_contains_icon || (config_["icon"].isBool() ? config_["icon"].asBool() : false);
|
||||
}
|
||||
|
||||
} // namespace waybar
|
||||
|
||||
+29
-1
@@ -117,7 +117,7 @@ ALabel::ALabel(const Json::Value& config, const std::string& name, const std::st
|
||||
submenus_[key] = GTK_MENU_ITEM(item);
|
||||
menuActionsMap_[key] = it->asString();
|
||||
g_signal_connect(submenus_[key], "activate", G_CALLBACK(handleGtkMenuEvent),
|
||||
(gpointer)menuActionsMap_[key].c_str());
|
||||
(gpointer)g_strdup(menuActionsMap_[key].c_str()));
|
||||
}
|
||||
g_object_unref(builder);
|
||||
} catch (std::runtime_error& e) {
|
||||
@@ -139,6 +139,26 @@ ALabel::ALabel(const Json::Value& config, const std::string& name, const std::st
|
||||
|
||||
auto ALabel::update() -> void { AModule::update(); }
|
||||
|
||||
bool ALabel::setLabelMarkup(const Glib::ustring& markup) {
|
||||
if (last_label_markup_ == markup) {
|
||||
return false;
|
||||
}
|
||||
|
||||
label_.set_markup(markup);
|
||||
last_label_markup_ = markup;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ALabel::setTooltipMarkup(const Glib::ustring& markup) {
|
||||
if (last_tooltip_markup_ == markup) {
|
||||
return false;
|
||||
}
|
||||
|
||||
label_.set_tooltip_markup(markup);
|
||||
last_tooltip_markup_ = markup;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string ALabel::getIcon(uint16_t percentage, const std::string& alt, uint16_t max) {
|
||||
auto format_icons = config_["format-icons"];
|
||||
if (format_icons.isObject()) {
|
||||
@@ -189,6 +209,10 @@ std::string ALabel::getIcon(uint16_t percentage, const std::vector<std::string>&
|
||||
return "";
|
||||
}
|
||||
|
||||
void ALabel::copyToClipboard(const std::string& literal) {
|
||||
Gtk::Clipboard::get()->set_text(literal);
|
||||
}
|
||||
|
||||
bool waybar::ALabel::handleToggle(GdkEventButton* const& e) {
|
||||
if (config_["format-alt-click"].isUInt() && e->button == config_["format-alt-click"].asUInt()) {
|
||||
alt_ = !alt_;
|
||||
@@ -198,6 +222,10 @@ bool waybar::ALabel::handleToggle(GdkEventButton* const& e) {
|
||||
format_ = default_format_;
|
||||
}
|
||||
}
|
||||
|
||||
if (config_["on-click-copy"].isBool() && config_["on-click-copy"].asBool()) {
|
||||
copyToClipboard(label_.get_text());
|
||||
}
|
||||
return AModule::handleToggle(e);
|
||||
}
|
||||
|
||||
|
||||
+22
-11
@@ -17,10 +17,14 @@ AModule::AModule(const Json::Value& config, const std::string& name, const std::
|
||||
isTooltip{config_["tooltip"].isBool() ? config_["tooltip"].asBool() : true},
|
||||
isExpand{config_["expand"].isBool() ? config_["expand"].asBool() : false},
|
||||
distance_scrolled_y_(0.0),
|
||||
distance_scrolled_x_(0.0) {
|
||||
distance_scrolled_x_(0.0),
|
||||
cursor_timeout_conn_() {
|
||||
// Configure module action Map
|
||||
const Json::Value actions{config_["actions"]};
|
||||
|
||||
disable_on_sleep_ =
|
||||
config_["disable-on-sleep"].isBool() ? config_["disable-on-sleep"].asBool() : false;
|
||||
|
||||
for (Json::Value::const_iterator it = actions.begin(); it != actions.end(); ++it) {
|
||||
if (it.key().isString() && it->isString())
|
||||
if (!eventActionMap_.contains(it.key().asString())) {
|
||||
@@ -42,7 +46,7 @@ AModule::AModule(const Json::Value& config, const std::string& name, const std::
|
||||
std::find_if(eventMap_.cbegin(), eventMap_.cend(), [&config](const auto& eventEntry) {
|
||||
// True if there is any non-release type event
|
||||
return eventEntry.first.second != GdkEventType::GDK_BUTTON_RELEASE &&
|
||||
config[eventEntry.second].isString();
|
||||
(config[eventEntry.second].isString() || config[eventEntry.second].isBool());
|
||||
}) != eventMap_.cend();
|
||||
|
||||
if (enable_click || hasUserEvents) {
|
||||
@@ -72,10 +76,14 @@ AModule::AModule(const Json::Value& config, const std::string& name, const std::
|
||||
|
||||
// Respect user configuration of cursor
|
||||
if (config_.isMember("cursor")) {
|
||||
if (config_["cursor"].isBool() && config_["cursor"].asBool()) {
|
||||
setCursor(Gdk::HAND2);
|
||||
} else if (config_["cursor"].isInt()) {
|
||||
setCursor(Gdk::CursorType(config_["cursor"].asInt()));
|
||||
if (config_["cursor"].isBool()) {
|
||||
if (config_["cursor"].asBool()) {
|
||||
setCursor("pointer");
|
||||
} else {
|
||||
setCursor("default");
|
||||
}
|
||||
} else if (config_["cursor"].isString()) {
|
||||
setCursor(config_["cursor"].asString());
|
||||
} else {
|
||||
spdlog::warn("unknown cursor option configured on module {}", name_);
|
||||
}
|
||||
@@ -83,6 +91,9 @@ AModule::AModule(const Json::Value& config, const std::string& name, const std::
|
||||
}
|
||||
|
||||
AModule::~AModule() {
|
||||
if (cursor_timeout_conn_.connected()) {
|
||||
cursor_timeout_conn_.disconnect();
|
||||
}
|
||||
for (const auto& pid : pid_children_) {
|
||||
if (pid != -1) {
|
||||
killpg(pid, SIGTERM);
|
||||
@@ -110,15 +121,15 @@ auto AModule::doAction(const std::string& name) -> void {
|
||||
}
|
||||
}
|
||||
|
||||
void AModule::setCursor(Gdk::CursorType const& c) {
|
||||
void AModule::setCursor(std::string const& c) {
|
||||
auto gdk_window = event_box_.get_window();
|
||||
if (gdk_window) {
|
||||
auto cursor = Gdk::Cursor::create(c);
|
||||
auto cursor = Gdk::Cursor::create(gdk_window->get_display(), c);
|
||||
gdk_window->set_cursor(cursor);
|
||||
} else {
|
||||
// window may not be accessible yet, in this case,
|
||||
// schedule another call for setting the cursor in 1 sec
|
||||
Glib::signal_timeout().connect_seconds(
|
||||
cursor_timeout_conn_ = Glib::signal_timeout().connect_seconds(
|
||||
[this, c]() {
|
||||
setCursor(c);
|
||||
return false;
|
||||
@@ -134,7 +145,7 @@ bool AModule::handleMouseEnter(GdkEventCrossing* const& e) {
|
||||
|
||||
// Default behavior indicating event availability
|
||||
if (hasUserEvents_ && !config_.isMember("cursor")) {
|
||||
setCursor(Gdk::HAND2);
|
||||
setCursor("pointer");
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -147,7 +158,7 @@ bool AModule::handleMouseLeave(GdkEventCrossing* const& e) {
|
||||
|
||||
// Default behavior indicating event availability
|
||||
if (hasUserEvents_ && !config_.isMember("cursor")) {
|
||||
setCursor(Gdk::ARROW);
|
||||
setCursor("default");
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
+73
-2
@@ -3,12 +3,14 @@
|
||||
#include <gtk-layer-shell.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
#include <ostream>
|
||||
#include <type_traits>
|
||||
|
||||
#include "client.hpp"
|
||||
#include "factory.hpp"
|
||||
#include "group.hpp"
|
||||
#include "util/enum.hpp"
|
||||
#include "util/hosts_check.hpp"
|
||||
#include "util/kill_signal.hpp"
|
||||
|
||||
#ifdef HAVE_SWAY
|
||||
@@ -172,6 +174,10 @@ waybar::Bar::Bar(struct waybar_output* w_output, const Json::Value& w_config)
|
||||
right_.set_spacing(spacing);
|
||||
}
|
||||
|
||||
if (config.isMember("height") && !config["height"].isUInt()) {
|
||||
spdlog::warn("Invalid type for 'height', expected unsigned integer");
|
||||
}
|
||||
|
||||
height_ = config["height"].isUInt() ? config["height"].asUInt() : 0;
|
||||
width_ = config["width"].isUInt() ? config["width"].asUInt() : 0;
|
||||
|
||||
@@ -263,6 +269,16 @@ waybar::Bar::Bar(struct waybar_output* w_output, const Json::Value& w_config)
|
||||
|
||||
window.signal_map_event().connect_notify(sigc::mem_fun(*this, &Bar::onMap));
|
||||
|
||||
window.signal_unmap().connect([this]() {
|
||||
spdlog::debug("Output {} unmapped (DPMS off), suspending modules", output->name);
|
||||
toggleSuspend(true);
|
||||
});
|
||||
|
||||
window.signal_map().connect([this]() {
|
||||
spdlog::debug("Output {} mapped (DPMS on), resuming modules", output->name);
|
||||
toggleSuspend(false);
|
||||
});
|
||||
|
||||
#if HAVE_SWAY
|
||||
if (auto ipc = config["ipc"]; ipc.isBool() && ipc.asBool()) {
|
||||
bar_id = Client::inst()->bar_id;
|
||||
@@ -309,6 +325,19 @@ waybar::Bar::Bar(struct waybar_output* w_output, const Json::Value& w_config)
|
||||
setupWidgets();
|
||||
window.show_all();
|
||||
|
||||
/*
|
||||
* If gtk-layer-shell's synchronous wait for the initial configure timed out, show_all() can
|
||||
* return with a configured but not-yet-presented surface. Kick GTK/layer-shell once control has
|
||||
* returned to the main loop, when any late initial configure has been dispatched and widgets have
|
||||
* had a chance to allocate/draw.
|
||||
*/
|
||||
Glib::signal_idle().connect(sigc::track_obj([this] {
|
||||
window.queue_resize();
|
||||
window.queue_draw();
|
||||
forceLayerCommit();
|
||||
return false;
|
||||
}, *this));
|
||||
|
||||
if (spdlog::should_log(spdlog::level::debug)) {
|
||||
// Unfortunately, this function isn't in the C++ bindings, so we have to call the C version.
|
||||
char* gtk_tree = gtk_style_context_to_string(
|
||||
@@ -374,7 +403,14 @@ void waybar::Bar::setMode(const struct bar_mode& mode) {
|
||||
* gtk-layer-shell schedules a commit on the next frame event in GTK, but this could fail in
|
||||
* certain scenarios, such as fully occluded bar.
|
||||
*/
|
||||
forceLayerCommit();
|
||||
}
|
||||
|
||||
void waybar::Bar::forceLayerCommit() {
|
||||
auto* gtk_window = window.gobj();
|
||||
if (gtk_window != nullptr && gtk_widget_get_realized(GTK_WIDGET(gtk_window))) {
|
||||
gtk_layer_try_force_commit(gtk_window);
|
||||
}
|
||||
wl_display_flush(Client::inst()->wl_display);
|
||||
}
|
||||
|
||||
@@ -531,6 +567,11 @@ void waybar::Bar::getModules(const Factory& factory, const std::string& pos,
|
||||
for (const auto& name : module_list) {
|
||||
try {
|
||||
auto ref = name.asString();
|
||||
|
||||
if (config[ref].isMember("hosts") && !waybar::util::valid_host(config[ref])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
AModule* module;
|
||||
|
||||
if (ref.compare(0, 6, "group/") == 0 && ref.size() > 6) {
|
||||
@@ -545,8 +586,8 @@ void waybar::Bar::getModules(const Factory& factory, const std::string& pos,
|
||||
if (group_config["modules"].isNull()) {
|
||||
spdlog::warn("Group definition '{}' has not been found, group will be hidden", ref);
|
||||
}
|
||||
auto group_module = std::make_unique<waybar::Group>(
|
||||
id_name, class_name, group_config, vertical);
|
||||
auto group_module =
|
||||
std::make_unique<waybar::Group>(id_name, class_name, group_config, vertical);
|
||||
|
||||
getModules(factory, ref, group_module.get());
|
||||
module = group_module.release();
|
||||
@@ -652,6 +693,17 @@ void waybar::Bar::onConfigure(GdkEventConfigure* ev) {
|
||||
|
||||
configureGlobalOffset(ev->width, ev->height);
|
||||
spdlog::info(BAR_SIZE_MSG, ev->width, ev->height, output->name);
|
||||
|
||||
/*
|
||||
* gtk-layer-shell waits for the compositor's initial configure while realizing the window. On a
|
||||
* busy compositor (common during session startup) that wait can time out even though the initial
|
||||
* configure arrives shortly afterwards. In that case GTK may not schedule the frame commit that
|
||||
* presents the first layer-surface buffer, leaving an otherwise configured bar invisible. Force a
|
||||
* commit after every configure so late initial configures, and later compositor-driven resizes,
|
||||
* always result in a submitted surface state.
|
||||
*/
|
||||
window.queue_draw();
|
||||
forceLayerCommit();
|
||||
}
|
||||
|
||||
void waybar::Bar::configureGlobalOffset(int width, int height) {
|
||||
@@ -696,3 +748,22 @@ void waybar::Bar::configureGlobalOffset(int width, int height) {
|
||||
void waybar::Bar::onOutputGeometryChanged() {
|
||||
configureGlobalOffset(window.get_width(), window.get_height());
|
||||
}
|
||||
|
||||
void waybar::Bar::toggleSuspend(bool suspend) {
|
||||
auto process_modules = [suspend](Gtk::Box& module_box) {
|
||||
for (auto* widget : module_box.get_children()) {
|
||||
auto* module = dynamic_cast<waybar::AModule*>(widget);
|
||||
if (module && module->shouldSuspend()) {
|
||||
if (suspend) {
|
||||
module->suspend();
|
||||
} else {
|
||||
module->resume();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
process_modules(left_);
|
||||
process_modules(center_);
|
||||
process_modules(right_);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user