Merge branch 'master' into feat-customizable-icon-thresholds
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;
|
||||
};
|
||||
|
||||
@@ -31,6 +31,7 @@ class ALabel : public AModule {
|
||||
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_;
|
||||
|
||||
+3
-2
@@ -45,7 +45,7 @@ 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);
|
||||
@@ -85,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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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_;
|
||||
|
||||
@@ -81,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;
|
||||
|
||||
@@ -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
|
||||
@@ -28,6 +28,8 @@ class MPD : public ALabel {
|
||||
|
||||
unsigned timeout_;
|
||||
|
||||
unsigned playing_interval_;
|
||||
|
||||
detail::unique_connection connection_;
|
||||
|
||||
detail::unique_status status_;
|
||||
@@ -63,6 +65,7 @@ class MPD : public ALabel {
|
||||
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,6 +198,7 @@ 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();
|
||||
|
||||
@@ -9,6 +9,7 @@ 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_ / 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_; }
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
@@ -47,6 +50,7 @@ class Host {
|
||||
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_;
|
||||
|
||||
@@ -19,11 +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;
|
||||
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);
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@ class Workspaces : public AModule, public sigc::trackable {
|
||||
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();
|
||||
@@ -50,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_;
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -27,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};
|
||||
@@ -55,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;
|
||||
|
||||
@@ -72,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_; }
|
||||
|
||||
@@ -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
|
||||
@@ -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*
|
||||
|
||||
+13
-5
@@ -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
|
||||
|
||||
@@ -207,11 +214,12 @@ View all valid format options in *strftime(3)* or have a look https://en.cpprefe
|
||||
"format-alt": "{:%A, %B %d, %Y (%R)} ",
|
||||
"tooltip-format": "<tt><small>{calendar}</small></tt>",
|
||||
"calendar": {
|
||||
"mode" : "year",
|
||||
"mode-mon-col" : 3,
|
||||
"weeks-pos" : "right",
|
||||
"on-scroll" : 1,
|
||||
"on-click-right": "mode",
|
||||
"mode" : "year",
|
||||
"mode-mon-col" : 3,
|
||||
"weeks-pos" : "right",
|
||||
"first-day-of-week": 1,
|
||||
"on-scroll" : 1,
|
||||
"on-click-right" : "mode",
|
||||
"format": {
|
||||
"months": "<span color='#ffead3'><b>{}</b></span>",
|
||||
"days": "<span color='#ecc6d9'><b>{}</b></span>",
|
||||
|
||||
@@ -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.
|
||||
@@ -52,6 +56,10 @@ Addressed by *hyprland/language*
|
||||
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 ++
|
||||
|
||||
@@ -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 ++
|
||||
|
||||
@@ -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": "",
|
||||
|
||||
@@ -43,18 +43,35 @@ The volume can be controlled by dragging the slider across the bar or clicking o
|
||||
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",
|
||||
"zero-on-mute": false,
|
||||
"unmute-on-volume-change": false
|
||||
},
|
||||
"pulseaudio/slider#in": {
|
||||
"min": 0,
|
||||
"max": 100,
|
||||
"orientation": "horizontal",
|
||||
"target": "source"
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -57,18 +57,17 @@ You can apply special styling to any module for when the cursor hovers it.
|
||||
|
||||
Most, if not all, module types support setting the `cursor` option. This is
|
||||
configured in your `config.jsonc`. If set to `false`, when hovering the module a
|
||||
"pointer"(as commonly known from web CSS styling `cursor: pointer`) style cursor
|
||||
"pointer" (as commonly known from web CSS styling `cursor: pointer`) style cursor
|
||||
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": {
|
||||
@@ -77,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,21 @@ 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 ++
|
||||
@@ -161,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);
|
||||
}
|
||||
```
|
||||
|
||||
@@ -375,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",
|
||||
|
||||
+29
@@ -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,6 +188,7 @@ 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',
|
||||
@@ -211,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',
|
||||
@@ -235,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',
|
||||
@@ -349,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(
|
||||
@@ -551,6 +579,7 @@ executable(
|
||||
upower_glib,
|
||||
pipewire,
|
||||
playerctl,
|
||||
libsystemd,
|
||||
libpulse,
|
||||
libjack,
|
||||
libwireplumber,
|
||||
|
||||
@@ -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": "",
|
||||
|
||||
+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
|
||||
|
||||
+9
-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) {
|
||||
@@ -247,6 +247,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_;
|
||||
@@ -256,6 +260,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);
|
||||
}
|
||||
|
||||
|
||||
+9
-9
@@ -46,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) {
|
||||
@@ -78,12 +78,12 @@ AModule::AModule(const Json::Value& config, const std::string& name, const std::
|
||||
if (config_.isMember("cursor")) {
|
||||
if (config_["cursor"].isBool()) {
|
||||
if (config_["cursor"].asBool()) {
|
||||
setCursor(Gdk::HAND2);
|
||||
setCursor("pointer");
|
||||
} else {
|
||||
setCursor(Gdk::ARROW);
|
||||
setCursor("default");
|
||||
}
|
||||
} else if (config_["cursor"].isInt()) {
|
||||
setCursor(Gdk::CursorType(config_["cursor"].asInt()));
|
||||
} else if (config_["cursor"].isString()) {
|
||||
setCursor(config_["cursor"].asString());
|
||||
} else {
|
||||
spdlog::warn("unknown cursor option configured on module {}", name_);
|
||||
}
|
||||
@@ -121,10 +121,10 @@ 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,
|
||||
@@ -145,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;
|
||||
@@ -158,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;
|
||||
|
||||
@@ -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
|
||||
@@ -565,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) {
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
#include <gtk-layer-shell.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <utility>
|
||||
|
||||
#include "gtkmm/icontheme.h"
|
||||
#include "ext-idle-notify-v1-client-protocol.h"
|
||||
#include "idle-inhibit-unstable-v1-client-protocol.h"
|
||||
#include "util/clara.hpp"
|
||||
#include "util/format.hpp"
|
||||
@@ -39,6 +41,12 @@ void waybar::Client::handleGlobal(void* data, struct wl_registry* registry, uint
|
||||
|
||||
client->idle_inhibit_manager = static_cast<struct zwp_idle_inhibit_manager_v1*>(
|
||||
wl_registry_bind(registry, name, &zwp_idle_inhibit_manager_v1_interface, 1));
|
||||
} else if (strcmp(interface, ext_idle_notifier_v1_interface.name) == 0) {
|
||||
// Bind version 2 if available (for get_input_idle_notification), otherwise version 1
|
||||
auto bind_version = std::min(version, 2u);
|
||||
client->idle_notifier = static_cast<struct ext_idle_notifier_v1 *>(
|
||||
wl_registry_bind(registry, name, &ext_idle_notifier_v1_interface, bind_version));
|
||||
spdlog::debug("Bound ext-idle-notifier-v1 at version {}", bind_version);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,13 @@
|
||||
#include "modules/niri/window.hpp"
|
||||
#include "modules/niri/workspaces.hpp"
|
||||
#endif
|
||||
#ifdef HAVE_MANGO
|
||||
#include "modules/mango/keymode.hpp"
|
||||
#include "modules/mango/language.hpp"
|
||||
#include "modules/mango/layout.hpp"
|
||||
#include "modules/mango/window.hpp"
|
||||
#include "modules/mango/workspaces.hpp"
|
||||
#endif
|
||||
#ifdef HAVE_WAYFIRE
|
||||
#include "modules/wayfire/window.hpp"
|
||||
#include "modules/wayfire/workspaces.hpp"
|
||||
@@ -52,6 +59,7 @@
|
||||
#if defined(HAVE_CPU_LINUX) || defined(HAVE_CPU_BSD)
|
||||
#include "modules/cpu.hpp"
|
||||
#include "modules/cpu_frequency.hpp"
|
||||
#include "modules/cpu_graph.hpp"
|
||||
#include "modules/cpu_usage.hpp"
|
||||
#include "modules/load.hpp"
|
||||
#endif
|
||||
@@ -117,6 +125,7 @@
|
||||
#include "modules/cava/cava_frontend.hpp"
|
||||
#include "modules/cffi.hpp"
|
||||
#include "modules/custom.hpp"
|
||||
#include "modules/custom_graph.hpp"
|
||||
#include "modules/image.hpp"
|
||||
#include "modules/temperature.hpp"
|
||||
#include "modules/user.hpp"
|
||||
@@ -231,6 +240,23 @@ waybar::AModule* waybar::Factory::makeModule(const std::string& name,
|
||||
return new waybar::modules::niri::Workspaces(id, bar_, config_[name]);
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_MANGO
|
||||
if (ref == "mango/window") {
|
||||
return new waybar::modules::mango::Window(id, bar_, config_[name]);
|
||||
}
|
||||
if (ref == "mango/workspaces") {
|
||||
return new waybar::modules::mango::Workspaces(id, bar_, config_[name]);
|
||||
}
|
||||
if (ref == "mango/language") {
|
||||
return new waybar::modules::mango::Language(id, bar_, config_[name]);
|
||||
}
|
||||
if (ref == "mango/keymode") {
|
||||
return new waybar::modules::mango::Keymode(id, bar_, config_[name]);
|
||||
}
|
||||
if (ref == "mango/layout") {
|
||||
return new waybar::modules::mango::Layout(id, bar_, config_[name]);
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_WAYFIRE
|
||||
if (ref == "wayfire/window") {
|
||||
return new waybar::modules::wayfire::Window(id, bar_, config_[name]);
|
||||
@@ -251,6 +277,9 @@ waybar::AModule* waybar::Factory::makeModule(const std::string& name,
|
||||
if (ref == "cpu") {
|
||||
return new waybar::modules::Cpu(id, config_[name]);
|
||||
}
|
||||
if (ref == "cpu_graph") {
|
||||
return new waybar::modules::CpuGraph(id, config_[name]);
|
||||
}
|
||||
#if defined(HAVE_CPU_LINUX)
|
||||
if (ref == "cpu_frequency") {
|
||||
return new waybar::modules::CpuFrequency(id, config_[name]);
|
||||
@@ -358,6 +387,9 @@ waybar::AModule* waybar::Factory::makeModule(const std::string& name,
|
||||
if (ref.compare(0, 7, "custom/") == 0 && ref.size() > 7) {
|
||||
return new waybar::modules::Custom(ref.substr(7), id, config_[name], bar_.output->name);
|
||||
}
|
||||
if (ref.compare(0, 13, "custom-graph/") == 0 && ref.size() > 13) {
|
||||
return new waybar::modules::CustomGraph(ref.substr(13), id, config_[name], bar_.output->name);
|
||||
}
|
||||
if (ref.compare(0, 5, "cffi/") == 0 && ref.size() > 5) {
|
||||
return new waybar::modules::CFFI(ref.substr(5), id, config_[name]);
|
||||
}
|
||||
|
||||
+29
-4
@@ -62,7 +62,12 @@ Group::Group(const std::string& name, const std::string& id, const Json::Value&
|
||||
const bool left_to_right = (drawer_config["transition-left-to-right"].isBool()
|
||||
? drawer_config["transition-left-to-right"].asBool()
|
||||
: true);
|
||||
const bool reveal_by_default =
|
||||
(drawer_config["reveal-by-default"].isBool() ? drawer_config["reveal-by-default"].asBool()
|
||||
: false);
|
||||
|
||||
click_to_reveal = drawer_config["click-to-reveal"].asBool();
|
||||
reveal_delay = drawer_config["reveal-delay"].asInt();
|
||||
|
||||
const bool start_expanded =
|
||||
(drawer_config["start-expanded"].isBool() ? drawer_config["start-expanded"].asBool()
|
||||
@@ -72,10 +77,11 @@ Group::Group(const std::string& name, const std::string& id, const Json::Value&
|
||||
|
||||
revealer.set_transition_type(transition_type);
|
||||
revealer.set_transition_duration(transition_duration);
|
||||
revealer.set_reveal_child(start_expanded);
|
||||
|
||||
if (start_expanded) {
|
||||
if ((click_to_reveal && reveal_by_default) || start_expanded) {
|
||||
box.set_state_flags(Gtk::StateFlags::STATE_FLAG_PRELIGHT);
|
||||
revealer.set_reveal_child(true);
|
||||
} else {
|
||||
revealer.set_reveal_child(false);
|
||||
}
|
||||
|
||||
revealer.get_style_context()->add_class("drawer");
|
||||
@@ -95,22 +101,41 @@ Group::Group(const std::string& name, const std::string& id, const Json::Value&
|
||||
void Group::show_group() {
|
||||
box.set_state_flags(Gtk::StateFlags::STATE_FLAG_PRELIGHT);
|
||||
revealer.set_reveal_child(true);
|
||||
box.get_style_context()->add_class("expanded");
|
||||
}
|
||||
|
||||
void Group::hide_group() {
|
||||
box.unset_state_flags(Gtk::StateFlags::STATE_FLAG_PRELIGHT);
|
||||
revealer.set_reveal_child(false);
|
||||
box.get_style_context()->remove_class("expanded");
|
||||
}
|
||||
|
||||
bool Group::handleMouseEnter(GdkEventCrossing* const& e) {
|
||||
if (!click_to_reveal) {
|
||||
show_group();
|
||||
if (reveal_delay > 0) {
|
||||
if (reveal_timeout_.connected()) {
|
||||
reveal_timeout_.disconnect();
|
||||
}
|
||||
|
||||
reveal_timeout_ = Glib::signal_timeout().connect(
|
||||
[this]() {
|
||||
show_group();
|
||||
return false;
|
||||
},
|
||||
reveal_delay);
|
||||
} else {
|
||||
show_group();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Group::handleMouseLeave(GdkEventCrossing* const& e) {
|
||||
if (!click_to_reveal && e->detail != GDK_NOTIFY_INFERIOR) {
|
||||
if (reveal_delay > 0 && reveal_timeout_.connected()) {
|
||||
reveal_timeout_.disconnect();
|
||||
}
|
||||
|
||||
hide_group();
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -7,6 +7,17 @@
|
||||
#include <list>
|
||||
#include <mutex>
|
||||
|
||||
#ifdef HAVE_LIBSYSTEMD
|
||||
#include <spdlog/sinks/systemd_sink.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <charconv>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <system_error>
|
||||
#endif
|
||||
|
||||
#include "bar.hpp"
|
||||
#include "client.hpp"
|
||||
#include "util/SafeSignal.hpp"
|
||||
@@ -162,7 +173,48 @@ static void handleSignalMainThread(int signum, bool& reload) {
|
||||
}
|
||||
}
|
||||
|
||||
static void logToJournalIfRunAsService() {
|
||||
#ifdef HAVE_LIBSYSTEMD
|
||||
/* Implementation of automatic protocol upgrading (from stderr to journal)
|
||||
** as described in https://systemd.io/JOURNAL_NATIVE_PROTOCOL */
|
||||
char const* journal_stream = std::getenv("JOURNAL_STREAM");
|
||||
|
||||
if (journal_stream != nullptr) {
|
||||
dev_t device;
|
||||
ino_t inode;
|
||||
size_t len = std::strlen(journal_stream);
|
||||
|
||||
auto result = std::from_chars(journal_stream, journal_stream + len, device);
|
||||
if (result.ec == std::errc{})
|
||||
result = std::from_chars(result.ptr + 1, journal_stream + len, inode);
|
||||
if (result.ec != std::errc{}) {
|
||||
spdlog::warn("malformed JOURNAL_STREAM (\"{}\"): {}, logging to console", journal_stream,
|
||||
std::make_error_condition(result.ec).message());
|
||||
}
|
||||
|
||||
struct stat f_stderr;
|
||||
|
||||
if (fstat(STDERR_FILENO, &f_stderr) != 0) {
|
||||
spdlog::warn("unable to check stderr device and inode numbers: {}", strerror(errno));
|
||||
} else if (device == f_stderr.st_dev && inode == f_stderr.st_ino) {
|
||||
auto journald = spdlog::systemd_logger_st("native_journal", "waybar", false);
|
||||
/* systemd_logger_st is thread-safe with enable_formatter = false
|
||||
** thanks to underlying sd_journal_send being thread-safe
|
||||
** https://github.com/gabime/spdlog/issues/2320#issuecomment-1079766037
|
||||
*/
|
||||
spdlog::set_default_logger(journald);
|
||||
} else {
|
||||
spdlog::info("JOURNAL_STREAM does not point to stderr, logging to console");
|
||||
}
|
||||
} else {
|
||||
spdlog::info("no JOURNAL_STREAM, logging to console");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
logToJournalIfRunAsService();
|
||||
|
||||
try {
|
||||
auto* client = waybar::Client::inst();
|
||||
|
||||
|
||||
@@ -36,9 +36,15 @@ auto waybar::modules::Backlight::update() -> void {
|
||||
|
||||
if (best->get_powered()) {
|
||||
event_box_.show();
|
||||
|
||||
const uint8_t percent =
|
||||
best->get_max() == 0 ? 100 : round(best->get_actual() * 100.0f / best->get_max());
|
||||
|
||||
const uint8_t percent_exp =
|
||||
best->get_max() == 0
|
||||
? 100
|
||||
: roundf(powf((float)best->get_actual() / best->get_max(), 1.0f / 2.718f) * 100);
|
||||
|
||||
// Get the state and apply state-specific format if available
|
||||
auto state = getState(percent);
|
||||
std::string current_format = format_;
|
||||
@@ -49,8 +55,10 @@ auto waybar::modules::Backlight::update() -> void {
|
||||
}
|
||||
}
|
||||
|
||||
std::string desc = fmt::format(fmt::runtime(current_format), fmt::arg("percent", percent),
|
||||
fmt::arg("icon", getIcon(percent)));
|
||||
std::string desc =
|
||||
fmt::format(fmt::runtime(current_format), fmt::arg("percent", percent),
|
||||
fmt::arg("percent_exp", percent_exp), fmt::arg("icon", getIcon(percent)),
|
||||
fmt::arg("icon_exp", getIcon(percent_exp)));
|
||||
label_.set_markup(desc);
|
||||
if (tooltipEnabled()) {
|
||||
std::string tooltip_format;
|
||||
|
||||
+29
-1
@@ -2,6 +2,9 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
|
||||
#include "util/command.hpp"
|
||||
#if defined(__FreeBSD__)
|
||||
@@ -33,6 +36,11 @@ waybar::modules::Battery::Battery(const std::string& id, const Bar& bar, const J
|
||||
}
|
||||
udev_monitor_enable_receiving(mon_.get());
|
||||
|
||||
if (config_["smooth-power"].isBool()) {
|
||||
smoothPowerEnable_ = config_["smooth-power"].asBool();
|
||||
if (smoothPowerEnable_ && config_["smooth-power-time-constant"].isNumeric())
|
||||
time_constant_s_ = std::max(1.0, config_["smooth-power-time-constant"].asDouble());
|
||||
}
|
||||
if (config_["weighted-average"].isBool()) weightedAverage_ = config_["weighted-average"].asBool();
|
||||
#endif
|
||||
spdlog::debug("battery: worker interval is {}", interval_.count());
|
||||
@@ -577,11 +585,31 @@ waybar::modules::Battery::getInfos() {
|
||||
if (online && current_status != "Discharging") status = "Plugged";
|
||||
}
|
||||
|
||||
if (total_energy_exists && total_power_exists && total_power != 0) {
|
||||
if (!smoothPowerEnable_) {
|
||||
smooth_power_ = total_power;
|
||||
} else {
|
||||
if (status != old_status_raw_) {
|
||||
smooth_power_ = total_power;
|
||||
last_t_ = std::chrono::steady_clock::now();
|
||||
} else {
|
||||
std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
|
||||
double dt_s =
|
||||
std::chrono::duration_cast<std::chrono::duration<double> >(now - last_t_).count();
|
||||
smooth_power_ = smooth_power_ + ((1 - std::exp(-dt_s / time_constant_s_)) *
|
||||
(total_power - smooth_power_));
|
||||
last_t_ = now;
|
||||
}
|
||||
|
||||
old_status_raw_ = status;
|
||||
}
|
||||
}
|
||||
|
||||
float time_remaining{0.0f};
|
||||
if (status == "Discharging" && time_to_empty_now_exists) {
|
||||
if (time_to_empty_now != 0) time_remaining = (float)time_to_empty_now / 3600.0f;
|
||||
} else if (status == "Discharging" && total_power_exists && total_energy_exists) {
|
||||
if (total_power != 0) time_remaining = (float)total_energy / total_power;
|
||||
if (smooth_power_ != 0) time_remaining = (float)total_energy / smooth_power_;
|
||||
} else if (status == "Charging" && time_to_full_now_exists) {
|
||||
if (time_to_full_now_exists && (time_to_full_now != 0))
|
||||
time_remaining = -(float)time_to_full_now / 3600.0f;
|
||||
|
||||
+151
-3
@@ -83,6 +83,68 @@ auto getUcharProperty(GDBusProxy* proxy, const char* property_name) -> unsigned
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto isChildPath(const std::string& child, const std::string& parent) -> bool {
|
||||
return child.starts_with(parent);
|
||||
}
|
||||
|
||||
auto readBatteryCharacteristicValue(GDBusProxy* proxy_char) -> std::optional<unsigned char> {
|
||||
GVariantBuilder builder;
|
||||
g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}"));
|
||||
|
||||
GError* error = nullptr;
|
||||
GVariant* gvar =
|
||||
g_dbus_proxy_call_sync(proxy_char, "ReadValue", g_variant_new("(a{sv})", &builder),
|
||||
G_DBUS_CALL_FLAGS_NONE, -1, nullptr, &error);
|
||||
if (error != nullptr) {
|
||||
g_error_free(error);
|
||||
return std::nullopt;
|
||||
}
|
||||
if (gvar == nullptr) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
GVariant* value_array = g_variant_get_child_value(gvar, 0);
|
||||
gsize n_elements;
|
||||
const auto* data = static_cast<const guchar*>(
|
||||
g_variant_get_fixed_array(value_array, &n_elements, sizeof(guchar)));
|
||||
|
||||
std::optional<unsigned char> result;
|
||||
if (data != nullptr && n_elements > 0) {
|
||||
result = data[0];
|
||||
}
|
||||
|
||||
g_variant_unref(value_array);
|
||||
g_variant_unref(gvar);
|
||||
return result;
|
||||
}
|
||||
|
||||
auto hasUserDescriptionDescriptor(GList* objects, const std::string& char_path,
|
||||
const std::string& user_description_uuid) -> bool {
|
||||
for (GList* n = objects; n != nullptr; n = n->next) {
|
||||
GDBusObject* desc_object = G_DBUS_OBJECT(n->data);
|
||||
std::string desc_path = g_dbus_object_get_object_path(desc_object);
|
||||
|
||||
if (!isChildPath(desc_path, char_path)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
GDBusProxy* proxy_desc =
|
||||
G_DBUS_PROXY(g_dbus_object_get_interface(desc_object, "org.bluez.GattDescriptor1"));
|
||||
if (proxy_desc == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto desc_uuid = getOptionalStringProperty(proxy_desc, "UUID");
|
||||
g_object_unref(proxy_desc);
|
||||
|
||||
if (desc_uuid.has_value() &&
|
||||
desc_uuid.value().find(user_description_uuid) != std::string::npos) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
waybar::modules::Bluetooth::Bluetooth(const std::string& id, const Json::Value& config)
|
||||
@@ -232,8 +294,9 @@ auto waybar::modules::Bluetooth::update() -> void {
|
||||
fmt::arg("device_address", cur_focussed_device_.address),
|
||||
fmt::arg("device_address_type", cur_focussed_device_.address_type),
|
||||
fmt::arg("device_alias", cur_focussed_device_.alias), fmt::arg("icon", icon_label),
|
||||
fmt::arg("device_battery_percentage",
|
||||
cur_focussed_device_.battery_percentage.value_or(0))));
|
||||
fmt::arg("device_battery_percentage", cur_focussed_device_.battery_percentage.value_or(0)),
|
||||
fmt::arg("device_battery_percentage_peripheral",
|
||||
cur_focussed_device_.battery_percentage_peripheral.value_or(0))));
|
||||
}
|
||||
|
||||
if (tooltipEnabled()) {
|
||||
@@ -258,7 +321,9 @@ auto waybar::modules::Bluetooth::update() -> void {
|
||||
fmt::runtime(enumerate_format), fmt::arg("device_address", dev.address),
|
||||
fmt::arg("device_address_type", dev.address_type),
|
||||
fmt::arg("device_alias", dev.alias), fmt::arg("icon", enumerate_icon),
|
||||
fmt::arg("device_battery_percentage", dev.battery_percentage.value_or(0)));
|
||||
fmt::arg("device_battery_percentage", dev.battery_percentage.value_or(0)),
|
||||
fmt::arg("device_battery_percentage_peripheral",
|
||||
dev.battery_percentage_peripheral.value_or(0)));
|
||||
}
|
||||
}
|
||||
device_enumerate_ = ss.str();
|
||||
@@ -278,6 +343,8 @@ auto waybar::modules::Bluetooth::update() -> void {
|
||||
fmt::arg("device_address_type", cur_focussed_device_.address_type),
|
||||
fmt::arg("device_alias", cur_focussed_device_.alias), fmt::arg("icon", icon_tooltip),
|
||||
fmt::arg("device_battery_percentage", cur_focussed_device_.battery_percentage.value_or(0)),
|
||||
fmt::arg("device_battery_percentage_peripheral",
|
||||
cur_focussed_device_.battery_percentage_peripheral.value_or(0)),
|
||||
fmt::arg("device_enumerate", device_enumerate_)));
|
||||
}
|
||||
|
||||
@@ -398,6 +465,85 @@ auto waybar::modules::Bluetooth::getDeviceBatteryPercentage(GDBusObject* object)
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
auto waybar::modules::Bluetooth::getDeviceGattBatteryLevels(
|
||||
GDBusObject* device_object, std::optional<unsigned char>& central_battery,
|
||||
std::optional<unsigned char>& peripheral_battery) -> void {
|
||||
const std::string BATTERY_SERVICE_UUID = "0000180f-0000-1000-8000-00805f9b34fb";
|
||||
const std::string BATTERY_LEVEL_UUID = "00002a19-0000-1000-8000-00805f9b34fb";
|
||||
const std::string USER_DESCRIPTION_UUID = "00002901-0000-1000-8000-00805f9b34fb";
|
||||
|
||||
GList* objects = g_dbus_object_manager_get_objects(manager_.get());
|
||||
std::string device_path = g_dbus_object_get_object_path(device_object);
|
||||
|
||||
for (GList* l = objects; l != nullptr; l = l->next) {
|
||||
GDBusObject* service_object = G_DBUS_OBJECT(l->data);
|
||||
std::string service_path = g_dbus_object_get_object_path(service_object);
|
||||
|
||||
if (!isChildPath(service_path, device_path)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
GDBusProxy* proxy_service =
|
||||
G_DBUS_PROXY(g_dbus_object_get_interface(service_object, "org.bluez.GattService1"));
|
||||
if (proxy_service == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto service_uuid = getOptionalStringProperty(proxy_service, "UUID");
|
||||
g_object_unref(proxy_service);
|
||||
|
||||
if (!service_uuid.has_value() ||
|
||||
service_uuid.value().find(BATTERY_SERVICE_UUID) == std::string::npos) {
|
||||
continue;
|
||||
}
|
||||
|
||||
processBatteryServiceCharacteristics(objects, service_path, BATTERY_LEVEL_UUID,
|
||||
USER_DESCRIPTION_UUID, central_battery,
|
||||
peripheral_battery);
|
||||
}
|
||||
|
||||
g_list_free_full(objects, g_object_unref);
|
||||
}
|
||||
|
||||
auto waybar::modules::Bluetooth::processBatteryServiceCharacteristics(
|
||||
GList* objects, const std::string& service_path, const std::string& battery_level_uuid,
|
||||
const std::string& user_description_uuid, std::optional<unsigned char>& central_battery,
|
||||
std::optional<unsigned char>& peripheral_battery) -> void {
|
||||
for (GList* m = objects; m != nullptr; m = m->next) {
|
||||
GDBusObject* char_object = G_DBUS_OBJECT(m->data);
|
||||
std::string char_path = g_dbus_object_get_object_path(char_object);
|
||||
|
||||
if (!isChildPath(char_path, service_path)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
GDBusProxy* proxy_char =
|
||||
G_DBUS_PROXY(g_dbus_object_get_interface(char_object, "org.bluez.GattCharacteristic1"));
|
||||
if (proxy_char == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto char_uuid = getOptionalStringProperty(proxy_char, "UUID");
|
||||
if (!char_uuid.has_value() || char_uuid.value().find(battery_level_uuid) == std::string::npos) {
|
||||
g_object_unref(proxy_char);
|
||||
continue;
|
||||
}
|
||||
|
||||
auto battery_value = readBatteryCharacteristicValue(proxy_char);
|
||||
g_object_unref(proxy_char);
|
||||
|
||||
if (!battery_value.has_value()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (hasUserDescriptionDescriptor(objects, char_path, user_description_uuid)) {
|
||||
peripheral_battery = battery_value.value();
|
||||
} else {
|
||||
central_battery = battery_value.value();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto waybar::modules::Bluetooth::getDeviceProperties(GDBusObject* object, DeviceInfo& device_info)
|
||||
-> bool {
|
||||
GDBusProxy* proxy_device = G_DBUS_PROXY(g_dbus_object_get_interface(object, "org.bluez.Device1"));
|
||||
@@ -418,6 +564,8 @@ auto waybar::modules::Bluetooth::getDeviceProperties(GDBusObject* object, Device
|
||||
g_object_unref(proxy_device);
|
||||
|
||||
device_info.battery_percentage = getDeviceBatteryPercentage(object);
|
||||
getDeviceGattBatteryLevels(object, device_info.battery_percentage,
|
||||
device_info.battery_percentage_peripheral);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <regex>
|
||||
#include <sstream>
|
||||
|
||||
#include "util/command.hpp"
|
||||
#include "util/ustring_clen.hpp"
|
||||
|
||||
#ifdef HAVE_LANGINFO_1STDAY
|
||||
@@ -187,6 +188,45 @@ auto waybar::modules::Clock::update() -> void {
|
||||
}
|
||||
|
||||
m_tlpText_ = fmt_lib::vformat(m_locale_, m_tlpText_, fmt_lib::make_format_args(now));
|
||||
|
||||
// Pango doesn't support CSS classes but to continue using it while staying
|
||||
// backwards compatible this approach uses post-posting to replace fake
|
||||
// classes with attributes Pango does understand.
|
||||
//
|
||||
// The benefit of this approach is anyone using the original styling choices
|
||||
// can continue doing that and folks can optionally opt into using classes.
|
||||
//
|
||||
// It's also forwards compatible to where if this implemention ever changes
|
||||
// to support proper classes anyone using them will continue to work.
|
||||
auto context = label_.get_style_context();
|
||||
|
||||
static const std::vector<std::pair<std::string, std::string>> calendar_class_map = {
|
||||
{"calendar-today", "class='today'"},
|
||||
{"calendar-days", "class='days'"},
|
||||
{"calendar-weeks", "class='weeks'"},
|
||||
{"calendar-weekdays", "class='weekdays'"},
|
||||
{"calendar-months", "class='months'"}};
|
||||
|
||||
for (const auto& [css_class, search_str] : calendar_class_map) {
|
||||
try {
|
||||
context->add_class(css_class);
|
||||
const Gdk::RGBA color = context->get_color();
|
||||
context->remove_class(css_class);
|
||||
|
||||
const std::string replace_str = fmt::format(
|
||||
"color='#{:02x}{:02x}{:02x}'", static_cast<int>(color.get_red() * 255),
|
||||
static_cast<int>(color.get_green() * 255), static_cast<int>(color.get_blue() * 255));
|
||||
|
||||
m_tlpText_ = std::regex_replace(m_tlpText_, std::regex(search_str), replace_str);
|
||||
} catch (const Glib::Error& e) {
|
||||
spdlog::warn("Clock: Failed to fetch CSS color for {}: {}", css_class, e.what().raw());
|
||||
continue;
|
||||
} catch (...) {
|
||||
// Catch-all for any other weirdness.
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
m_tooltip_->set_markup(m_tlpText_);
|
||||
label_.trigger_tooltip_query();
|
||||
}
|
||||
@@ -477,6 +517,8 @@ auto waybar::modules::Clock::local_zone() -> const time_zone* {
|
||||
auto waybar::modules::Clock::doAction(const std::string& name) -> void {
|
||||
if (actionMap_[name]) {
|
||||
(this->*actionMap_[name])();
|
||||
} else if (auto key = name.substr(0, name.find(" ")); actionWithArgsMap_[key]) {
|
||||
(this->*actionWithArgsMap_[key])(name);
|
||||
} else
|
||||
spdlog::error("Clock. Unsupported action \"{0}\"", name);
|
||||
}
|
||||
@@ -503,6 +545,10 @@ void waybar::modules::Clock::tz_down() {
|
||||
if (tzSize == 1) return;
|
||||
tzCurrIdx_ = (tzCurrIdx_ == 0) ? tzSize - 1 : tzCurrIdx_ - 1;
|
||||
}
|
||||
void waybar::modules::Clock::action_exec(const std::string& action) {
|
||||
auto cmd = action.substr(strlen("exec "));
|
||||
pid_children_.push_back(util::command::forkExec(cmd));
|
||||
}
|
||||
|
||||
#ifdef HAVE_LANGINFO_1STDAY
|
||||
template <auto fn>
|
||||
@@ -514,6 +560,18 @@ using deleting_unique_ptr = std::unique_ptr<T, deleter_from_fn<fn>>;
|
||||
|
||||
// Computations done similarly to Linux cal utility.
|
||||
auto waybar::modules::Clock::first_day_of_week() -> weekday {
|
||||
const auto firstdow = config_[kCldPlaceholder]["first-day-of-week"];
|
||||
if (firstdow.isInt()) {
|
||||
const int firstDay = firstdow.asInt();
|
||||
if (!(firstDay >= 0 && firstDay <= 6)) {
|
||||
spdlog::warn(
|
||||
"Clock calender configuration first-day-of-week = {0} must be in range [0, 6]. Default "
|
||||
"value is used instead",
|
||||
firstDay);
|
||||
} else {
|
||||
return weekday{static_cast<unsigned>(firstDay)};
|
||||
}
|
||||
}
|
||||
if (iso8601Calendar_) {
|
||||
return Monday;
|
||||
}
|
||||
|
||||
+8
-1
@@ -41,6 +41,9 @@ auto waybar::modules::Cpu::update() -> void {
|
||||
auto icons = std::vector<std::string>{state};
|
||||
fmt::dynamic_format_arg_store<fmt::format_context> store;
|
||||
store.push_back(fmt::arg("load", load1));
|
||||
store.push_back(fmt::arg("load1", load1));
|
||||
store.push_back(fmt::arg("load5", load5));
|
||||
store.push_back(fmt::arg("load15", load15));
|
||||
store.push_back(fmt::arg("usage", total_usage));
|
||||
store.push_back(fmt::arg("icon", getIcon(total_usage, icons)));
|
||||
store.push_back(fmt::arg("max_frequency", max_frequency));
|
||||
@@ -48,13 +51,17 @@ auto waybar::modules::Cpu::update() -> void {
|
||||
store.push_back(fmt::arg("avg_frequency", avg_frequency));
|
||||
std::vector<std::string> arg_names;
|
||||
arg_names.reserve(cpu_usage.size() * 2);
|
||||
std::string all_icons;
|
||||
for (size_t i = 1; i < cpu_usage.size(); ++i) {
|
||||
auto core_i = i - 1;
|
||||
arg_names.push_back(fmt::format("usage{}", core_i));
|
||||
store.push_back(fmt::arg(arg_names.back().c_str(), cpu_usage[i]));
|
||||
auto core_icon = getIcon(cpu_usage[i], icons);
|
||||
all_icons += core_icon;
|
||||
arg_names.push_back(fmt::format("icon{}", core_i));
|
||||
store.push_back(fmt::arg(arg_names.back().c_str(), getIcon(cpu_usage[i], icons)));
|
||||
store.push_back(fmt::arg(arg_names.back().c_str(), core_icon));
|
||||
}
|
||||
store.push_back(fmt::arg("icons", all_icons));
|
||||
label_.set_markup(fmt::vformat(format, store));
|
||||
|
||||
if (tooltipEnabled()) {
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
#include "modules/cpu_graph.hpp"
|
||||
|
||||
#include "modules/cpu_frequency.hpp"
|
||||
#include "modules/cpu_usage.hpp"
|
||||
#include "modules/load.hpp"
|
||||
|
||||
// In the 80000 version of fmt library authors decided to optimize imports
|
||||
// and moved declarations required for fmt::dynamic_format_arg_store in new
|
||||
// header fmt/args.h
|
||||
#if (FMT_VERSION >= 80000)
|
||||
#include <fmt/args.h>
|
||||
#else
|
||||
#include <fmt/core.h>
|
||||
#endif
|
||||
|
||||
waybar::modules::CpuGraph::CpuGraph(const std::string& id, const Json::Value& config)
|
||||
: AGraph(config, "cpu_graph", id, 5) {
|
||||
thread_ = [this] {
|
||||
dp.emit();
|
||||
thread_.sleep_for(interval_);
|
||||
};
|
||||
}
|
||||
|
||||
auto waybar::modules::CpuGraph::update() -> void {
|
||||
// TODO: as creating dynamic fmt::arg arrays is buggy we have to calc both
|
||||
auto [cpu_usage, tooltip] = CpuUsage::getCpuUsage(prev_times_);
|
||||
if (tooltipEnabled()) {
|
||||
graph_.set_tooltip_text(tooltip);
|
||||
}
|
||||
auto total_usage = cpu_usage.empty() ? 0 : cpu_usage[0];
|
||||
addValue(total_usage);
|
||||
|
||||
graph_.get_style_context()->remove_class(MODERATE_CLASS);
|
||||
graph_.get_style_context()->remove_class(HIGH_CLASS);
|
||||
graph_.get_style_context()->remove_class(INTENSIVE_CLASS);
|
||||
|
||||
if (total_usage > 90) {
|
||||
graph_.get_style_context()->add_class(INTENSIVE_CLASS);
|
||||
} else if (total_usage > 70) {
|
||||
graph_.get_style_context()->add_class(HIGH_CLASS);
|
||||
} else if (total_usage > 30) {
|
||||
graph_.get_style_context()->add_class(MODERATE_CLASS);
|
||||
}
|
||||
|
||||
// Call parent update
|
||||
AGraph::update();
|
||||
}
|
||||
@@ -38,13 +38,17 @@ auto waybar::modules::CpuUsage::update() -> void {
|
||||
store.push_back(fmt::arg("icon", getIcon(total_usage, icons)));
|
||||
std::vector<std::string> arg_names;
|
||||
arg_names.reserve(cpu_usage.size() * 2);
|
||||
std::string all_icons;
|
||||
for (size_t i = 1; i < cpu_usage.size(); ++i) {
|
||||
auto core_i = i - 1;
|
||||
arg_names.push_back(fmt::format("usage{}", core_i));
|
||||
store.push_back(fmt::arg(arg_names.back().c_str(), cpu_usage[i]));
|
||||
auto core_icon = getIcon(cpu_usage[i], icons);
|
||||
all_icons += core_icon;
|
||||
arg_names.push_back(fmt::format("icon{}", core_i));
|
||||
store.push_back(fmt::arg(arg_names.back().c_str(), getIcon(cpu_usage[i], icons)));
|
||||
store.push_back(fmt::arg(arg_names.back().c_str(), core_icon));
|
||||
}
|
||||
store.push_back(fmt::arg("icons", all_icons));
|
||||
label_.set_markup(fmt::vformat(format, store));
|
||||
|
||||
if (tooltipEnabled()) {
|
||||
|
||||
+26
-3
@@ -8,7 +8,7 @@
|
||||
|
||||
waybar::modules::Custom::Custom(const std::string& name, const std::string& id,
|
||||
const Json::Value& config, const std::string& output_name)
|
||||
: ALabel(config, "custom-" + name, id, "{}"),
|
||||
: AIconLabel(config, "custom-" + name, id, "{}"),
|
||||
name_(name),
|
||||
output_name_(output_name),
|
||||
id_(id),
|
||||
@@ -28,6 +28,15 @@ waybar::modules::Custom::Custom(const std::string& name, const std::string& id,
|
||||
} else if (config_["exec"].isString()) {
|
||||
continuousWorker();
|
||||
}
|
||||
if (config_["image-path"].isString()) {
|
||||
image_path_ = config_["image-path"].asString();
|
||||
}
|
||||
if (config_["image-name"].isString()) {
|
||||
image_name_ = config_["image-name"].asString();
|
||||
}
|
||||
if (config["icon-size"].isUInt()) {
|
||||
app_icon_size_ = config["icon-size"].asUInt();
|
||||
}
|
||||
}
|
||||
|
||||
waybar::modules::Custom::~Custom() {
|
||||
@@ -184,7 +193,8 @@ auto waybar::modules::Custom::update() -> void {
|
||||
auto str = fmt::format(fmt::runtime(format_), fmt::arg("text", text_), fmt::arg("alt", alt_),
|
||||
fmt::arg("icon", getIcon(percentage_, alt_)),
|
||||
fmt::arg("percentage", percentage_));
|
||||
if ((config_["hide-empty-text"].asBool() && text_.empty()) || str.empty()) {
|
||||
if ((config_["hide-empty-text"].asBool() && text_.empty()) ||
|
||||
(str.empty() && image_path_.empty() && image_name_.empty())) {
|
||||
event_box_.hide();
|
||||
} else {
|
||||
label_.set_markup(str);
|
||||
@@ -219,7 +229,19 @@ auto waybar::modules::Custom::update() -> void {
|
||||
style->add_class("flat");
|
||||
style->add_class("text-button");
|
||||
style->add_class(MODULE_CLASS);
|
||||
auto image_style = image_.get_style_context();
|
||||
image_style->add_class("image-button");
|
||||
event_box_.show();
|
||||
if (!image_path_.empty()) {
|
||||
auto pixbuf = Gdk::Pixbuf::create_from_file(image_path_, app_icon_size_, app_icon_size_);
|
||||
image_.set(pixbuf);
|
||||
} else if (!image_name_.empty()) {
|
||||
image_.set_from_icon_name(image_name_, Gtk::ICON_SIZE_INVALID);
|
||||
image_.set_pixel_size(app_icon_size_);
|
||||
}
|
||||
|
||||
image_.set_visible(!image_name_.empty() || !image_path_.empty());
|
||||
label_.set_visible(!str.empty());
|
||||
}
|
||||
} catch (const fmt::format_error& e) {
|
||||
if (std::strcmp(e.what(), "cannot switch from manual to automatic argument indexing") != 0)
|
||||
@@ -231,7 +253,7 @@ auto waybar::modules::Custom::update() -> void {
|
||||
}
|
||||
}
|
||||
// Call parent update
|
||||
ALabel::update();
|
||||
AIconLabel::update();
|
||||
}
|
||||
|
||||
void waybar::modules::Custom::parseOutputRaw() {
|
||||
@@ -297,6 +319,7 @@ void waybar::modules::Custom::parseOutputJson() {
|
||||
class_.push_back(c.asString());
|
||||
}
|
||||
}
|
||||
|
||||
if (!parsed["percentage"].asString().empty() && parsed["percentage"].isNumeric()) {
|
||||
percentage_ = (int)lround(parsed["percentage"].asFloat());
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,281 @@
|
||||
#include "modules/custom_graph.hpp"
|
||||
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
#include "util/scope_guard.hpp"
|
||||
|
||||
waybar::modules::CustomGraph::CustomGraph(const std::string& name, const std::string& id,
|
||||
const Json::Value& config, const std::string& output_name)
|
||||
: AGraph(config, "custom-graph-" + name, id),
|
||||
name_(name),
|
||||
output_name_(output_name),
|
||||
id_(id),
|
||||
tooltip_format_enabled_{config_["tooltip-format"].isString()},
|
||||
percentage_(0),
|
||||
fp_(nullptr),
|
||||
pid_(-1) {
|
||||
if (config.isNull()) {
|
||||
spdlog::warn("There is no configuration for 'custom-graph/{}', element will be hidden", name);
|
||||
}
|
||||
dp.emit();
|
||||
if (!config_["signal"].empty() && config_["interval"].empty() &&
|
||||
config_["restart-interval"].empty()) {
|
||||
waitingWorker();
|
||||
} else if (interval_.count() > 0) {
|
||||
delayWorker();
|
||||
} else if (config_["exec"].isString()) {
|
||||
continuousWorker();
|
||||
}
|
||||
}
|
||||
|
||||
waybar::modules::CustomGraph::~CustomGraph() {
|
||||
if (pid_ != -1) {
|
||||
killpg(pid_, SIGTERM);
|
||||
waitpid(pid_, NULL, 0);
|
||||
pid_ = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void waybar::modules::CustomGraph::delayWorker() {
|
||||
thread_ = [this] {
|
||||
for (int i : this->pid_children_) {
|
||||
int status;
|
||||
waitpid(i, &status, 0);
|
||||
}
|
||||
|
||||
this->pid_children_.clear();
|
||||
|
||||
bool can_update = true;
|
||||
if (config_["exec-if"].isString()) {
|
||||
output_ = util::command::execNoRead(config_["exec-if"].asString());
|
||||
if (output_.exit_code != 0) {
|
||||
can_update = false;
|
||||
dp.emit();
|
||||
}
|
||||
}
|
||||
if (can_update) {
|
||||
if (config_["exec"].isString()) {
|
||||
output_ = util::command::exec(config_["exec"].asString(), output_name_);
|
||||
}
|
||||
dp.emit();
|
||||
}
|
||||
thread_.sleep_for(interval_);
|
||||
};
|
||||
}
|
||||
|
||||
void waybar::modules::CustomGraph::continuousWorker() {
|
||||
auto cmd = config_["exec"].asString();
|
||||
pid_ = -1;
|
||||
fp_ = util::command::open(cmd, pid_, output_name_);
|
||||
if (!fp_) {
|
||||
throw std::runtime_error("Unable to open " + cmd);
|
||||
}
|
||||
thread_ = [this, cmd] {
|
||||
char* buff = nullptr;
|
||||
waybar::util::ScopeGuard buff_deleter([&buff]() {
|
||||
if (buff) {
|
||||
free(buff);
|
||||
}
|
||||
});
|
||||
size_t len = 0;
|
||||
if (getline(&buff, &len, fp_) == -1) {
|
||||
int exit_code = 1;
|
||||
if (fp_) {
|
||||
exit_code = WEXITSTATUS(util::command::close(fp_, pid_));
|
||||
fp_ = nullptr;
|
||||
}
|
||||
if (exit_code != 0) {
|
||||
output_ = {exit_code, ""};
|
||||
dp.emit();
|
||||
spdlog::error("{} stopped unexpectedly, is it endless?", name_);
|
||||
}
|
||||
if (config_["restart-interval"].isUInt()) {
|
||||
pid_ = -1;
|
||||
thread_.sleep_for(std::chrono::seconds(config_["restart-interval"].asUInt()));
|
||||
fp_ = util::command::open(cmd, pid_, output_name_);
|
||||
if (!fp_) {
|
||||
throw std::runtime_error("Unable to open " + cmd);
|
||||
}
|
||||
} else {
|
||||
thread_.stop();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
std::string output = buff;
|
||||
|
||||
// Remove last newline
|
||||
if (!output.empty() && output[output.length() - 1] == '\n') {
|
||||
output.erase(output.length() - 1);
|
||||
}
|
||||
output_ = {0, output};
|
||||
dp.emit();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void waybar::modules::CustomGraph::waitingWorker() {
|
||||
thread_ = [this] {
|
||||
bool can_update = true;
|
||||
if (config_["exec-if"].isString()) {
|
||||
output_ = util::command::execNoRead(config_["exec-if"].asString());
|
||||
if (output_.exit_code != 0) {
|
||||
can_update = false;
|
||||
dp.emit();
|
||||
}
|
||||
}
|
||||
if (can_update) {
|
||||
if (config_["exec"].isString()) {
|
||||
output_ = util::command::exec(config_["exec"].asString(), output_name_);
|
||||
}
|
||||
dp.emit();
|
||||
}
|
||||
thread_.sleep();
|
||||
};
|
||||
}
|
||||
|
||||
void waybar::modules::CustomGraph::refresh(int sig) {
|
||||
if (sig == SIGRTMIN + config_["signal"].asInt()) {
|
||||
thread_.wake_up();
|
||||
}
|
||||
}
|
||||
|
||||
void waybar::modules::CustomGraph::handleEvent() {
|
||||
if (!config_["exec-on-event"].isBool() || config_["exec-on-event"].asBool()) {
|
||||
thread_.wake_up();
|
||||
}
|
||||
}
|
||||
|
||||
bool waybar::modules::CustomGraph::handleScroll(GdkEventScroll* e) {
|
||||
auto ret = AGraph::handleScroll(e);
|
||||
handleEvent();
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool waybar::modules::CustomGraph::handleToggle(GdkEventButton* const& e) {
|
||||
auto ret = AGraph::handleToggle(e);
|
||||
handleEvent();
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto waybar::modules::CustomGraph::update() -> void {
|
||||
// Hide label if output is empty
|
||||
if ((config_["exec"].isString() || config_["exec-if"].isString()) &&
|
||||
(output_.out.empty() || output_.exit_code != 0)) {
|
||||
event_box_.hide();
|
||||
} else {
|
||||
if (config_["return-type"].asString() == "json") {
|
||||
parseOutputJson();
|
||||
} else {
|
||||
parseOutputRaw();
|
||||
}
|
||||
|
||||
try {
|
||||
addValue(percentage_);
|
||||
|
||||
if (tooltipEnabled()) {
|
||||
if (tooltip_format_enabled_) {
|
||||
auto tooltip = config_["tooltip-format"].asString();
|
||||
tooltip = fmt::format(fmt::runtime(tooltip), fmt::arg("text", text_),
|
||||
fmt::arg("alt", alt_), fmt::arg("percentage", percentage_));
|
||||
graph_.set_tooltip_markup(tooltip);
|
||||
} else {
|
||||
if (graph_.get_tooltip_markup() != tooltip_) {
|
||||
graph_.set_tooltip_markup(tooltip_);
|
||||
}
|
||||
}
|
||||
}
|
||||
auto style = graph_.get_style_context();
|
||||
auto classes = style->list_classes();
|
||||
for (auto const& c : classes) {
|
||||
if (c == id_) continue;
|
||||
style->remove_class(c);
|
||||
}
|
||||
for (auto const& c : class_) {
|
||||
style->add_class(c);
|
||||
}
|
||||
style->add_class("flat");
|
||||
style->add_class(MODULE_CLASS);
|
||||
event_box_.show();
|
||||
} catch (const fmt::format_error& e) {
|
||||
if (std::strcmp(e.what(), "cannot switch from manual to automatic argument indexing") != 0)
|
||||
throw;
|
||||
|
||||
throw fmt::format_error(
|
||||
"mixing manual and automatic argument indexing is no longer supported; "
|
||||
"try replacing \"{}\" with \"{text}\" in your format specifier");
|
||||
}
|
||||
}
|
||||
// Call parent update
|
||||
AGraph::update();
|
||||
}
|
||||
|
||||
void waybar::modules::CustomGraph::parseOutputRaw() {
|
||||
std::istringstream output(output_.out);
|
||||
std::string line;
|
||||
int i = 0;
|
||||
while (getline(output, line)) {
|
||||
Glib::ustring validated_line = line;
|
||||
if (!validated_line.validate()) {
|
||||
validated_line = validated_line.make_valid();
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
if (config_["escape"].isBool() && config_["escape"].asBool()) {
|
||||
text_ = Glib::Markup::escape_text(validated_line);
|
||||
tooltip_ = Glib::Markup::escape_text(validated_line);
|
||||
} else {
|
||||
text_ = validated_line;
|
||||
tooltip_ = validated_line;
|
||||
}
|
||||
class_.clear();
|
||||
} else if (i == 1) {
|
||||
if (config_["escape"].isBool() && config_["escape"].asBool()) {
|
||||
tooltip_ = Glib::Markup::escape_text(validated_line);
|
||||
} else {
|
||||
tooltip_ = validated_line;
|
||||
}
|
||||
} else if (i == 2) {
|
||||
class_.push_back(validated_line);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void waybar::modules::CustomGraph::parseOutputJson() {
|
||||
std::istringstream output(output_.out);
|
||||
std::string line;
|
||||
class_.clear();
|
||||
while (getline(output, line)) {
|
||||
auto parsed = parser_.parse(line);
|
||||
if (config_["escape"].isBool() && config_["escape"].asBool()) {
|
||||
text_ = Glib::Markup::escape_text(parsed["text"].asString());
|
||||
} else {
|
||||
text_ = parsed["text"].asString();
|
||||
}
|
||||
if (config_["escape"].isBool() && config_["escape"].asBool()) {
|
||||
alt_ = Glib::Markup::escape_text(parsed["alt"].asString());
|
||||
} else {
|
||||
alt_ = parsed["alt"].asString();
|
||||
}
|
||||
if (config_["escape"].isBool() && config_["escape"].asBool()) {
|
||||
tooltip_ = Glib::Markup::escape_text(parsed["tooltip"].asString());
|
||||
} else {
|
||||
tooltip_ = parsed["tooltip"].asString();
|
||||
}
|
||||
if (parsed["class"].isString()) {
|
||||
class_.push_back(parsed["class"].asString());
|
||||
} else if (parsed["class"].isArray()) {
|
||||
for (auto const& c : parsed["class"]) {
|
||||
class_.push_back(c.asString());
|
||||
}
|
||||
}
|
||||
if (!parsed["percentage"].asString().empty() && parsed["percentage"].isNumeric()) {
|
||||
percentage_ = (int)lround(parsed["percentage"].asFloat());
|
||||
} else {
|
||||
percentage_ = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user