Compare commits
186 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8490a1d9b9 | ||
|
|
a3ee5f1125 | ||
|
|
0b87af9372 | ||
|
|
fe3dda4c23 | ||
|
|
0d8d42573b | ||
|
|
d098dbbeb0 | ||
|
|
533d5de243 | ||
|
|
d3c7ff6525 | ||
|
|
bcee548f5e | ||
|
|
37c6cd42f5 | ||
|
|
a4989cedae | ||
|
|
5b8839ab5c | ||
|
|
4be1f3bf42 | ||
|
|
6c4f0af2fe | ||
|
|
cc94278c4e | ||
|
|
0abb2166a4 | ||
|
|
c32d5e3883 | ||
|
|
834868e0b5 | ||
|
|
b2d11f9ec0 | ||
|
|
e32a678478 | ||
|
|
0d5a4f82ec | ||
|
|
8bdb5c1906 | ||
|
|
8a741f6ec7 | ||
|
|
481b01d9af | ||
|
|
90911a15b6 | ||
|
|
bb2c67ebad | ||
|
|
dc64b3542b | ||
|
|
ba12ca71c0 | ||
|
|
a4241d7008 | ||
|
|
ab0acd07fe | ||
|
|
4ec121822a | ||
|
|
0992bf1b87 | ||
|
|
369c81d6f2 | ||
|
|
6a29abb49e | ||
|
|
9d9f1d6819 | ||
|
|
865121b21d | ||
|
|
d1dac2854a | ||
|
|
ac08b752e3 | ||
|
|
fe2f847e6d | ||
|
|
3555417a4f | ||
|
|
884550964e | ||
|
|
5346649fc6 | ||
|
|
6ce881abd5 | ||
|
|
dbb708c88e | ||
|
|
8e276bb3f6 | ||
|
|
157ea44510 | ||
|
|
01ae117cfe | ||
|
|
8e0964ad15 | ||
|
|
8024df0430 | ||
|
|
43af1b9ea0 | ||
|
|
e959f1d230 | ||
|
|
347c44209d | ||
|
|
758c14c5d8 | ||
|
|
78d2ce3791 | ||
|
|
db943dae98 | ||
|
|
6bac784b51 | ||
|
|
6d28740896 | ||
|
|
3abac0abfd | ||
|
|
0e5728b533 | ||
|
|
4e05659109 | ||
|
|
20ca48c3b8 | ||
|
|
b863627c22 | ||
|
|
1e481b7ac0 | ||
|
|
f9acc1fed9 | ||
|
|
86ce9f7278 | ||
|
|
8645115619 | ||
|
|
63edb402ef | ||
|
|
52d582b93a | ||
|
|
724a4a5ed3 | ||
|
|
77b50b4c7a | ||
|
|
3f80e507fd | ||
|
|
5f260516af | ||
|
|
9d89ddae9b | ||
|
|
bb40e169fd | ||
|
|
dacecb9b26 | ||
|
|
92242f0b9d | ||
|
|
0e03c7a811 | ||
|
|
6df26ccba7 | ||
|
|
280f11e247 | ||
|
|
95eaffcfb1 | ||
|
|
e7b2d33d99 | ||
|
|
281911c9b3 | ||
|
|
e53497bab6 | ||
|
|
a1adf6847f | ||
|
|
6322fa28f3 | ||
|
|
e394485857 | ||
|
|
edab49f291 | ||
|
|
486b99c22f | ||
|
|
e46a1c6bfc | ||
|
|
d684a6de21 | ||
|
|
cad18f39f5 | ||
|
|
47f767b0ee | ||
|
|
04bda9f443 | ||
|
|
c88a86f510 | ||
|
|
07f75e303c | ||
|
|
b4e97eb2f4 | ||
|
|
773b1d4806 | ||
|
|
57156bce7e | ||
|
|
e3095c6d1d | ||
|
|
951b89ffcb | ||
|
|
d6bfeb5a44 | ||
|
|
8b1d73690d | ||
|
|
9c47b2e9dd | ||
|
|
dedee8cd14 | ||
|
|
21af48fdc9 | ||
|
|
b5395f4e6f | ||
|
|
3462769fc1 | ||
|
|
ac1a42291d | ||
|
|
a3e7031fe2 | ||
|
|
254111ff91 | ||
|
|
de170fa579 | ||
|
|
83992d29a0 | ||
|
|
3bb3c2d23f | ||
|
|
ff66b5dd57 | ||
|
|
9e8ebe668d | ||
|
|
9cfb1e38fa | ||
|
|
ae997ad73b | ||
|
|
085a1ede97 | ||
|
|
0d02f6877d | ||
|
|
e0be3ac178 | ||
|
|
45fec7bcbb | ||
|
|
7b23d58684 | ||
|
|
0006e4713a | ||
|
|
f60c291b82 | ||
|
|
8e2a742042 | ||
|
|
4a6af0da99 | ||
|
|
d177969f51 | ||
|
|
59b7715309 | ||
|
|
d56dd6ee7f | ||
|
|
1142979581 | ||
|
|
8a89706d03 | ||
|
|
a4d31ab10d | ||
|
|
34bfefcd2e | ||
|
|
fef0bb995c | ||
|
|
46e7ed35de | ||
|
|
d623a89cd1 | ||
|
|
1210bcd2b5 | ||
|
|
30f6ed05ec | ||
|
|
3ade275d10 | ||
|
|
4354da2849 | ||
|
|
6417782af6 | ||
|
|
64d99a5884 | ||
|
|
627e4a4a50 | ||
|
|
c2f1a7894b | ||
|
|
6560e32bc1 | ||
|
|
70f3c1d9e9 | ||
|
|
5b1826d2f6 | ||
|
|
1fa8019ad5 | ||
|
|
7a6960842a | ||
|
|
9b5c2dc7ed | ||
|
|
0ee519753c | ||
|
|
bf36f2abed | ||
|
|
5d184f74d8 | ||
|
|
4d89c64bed | ||
|
|
f665d1da52 | ||
|
|
29459371b9 | ||
|
|
26329b660a | ||
|
|
0fb1957dae | ||
|
|
c5a4266329 | ||
|
|
fd478bf2ab | ||
|
|
1f23b30b56 | ||
|
|
36497cd41a | ||
|
|
367f156eb0 | ||
|
|
ed40168d89 | ||
|
|
62cb61c670 | ||
|
|
21906f07b3 | ||
|
|
c468119f52 | ||
|
|
79d3a1a296 | ||
|
|
4ae144a724 | ||
|
|
fdc8431709 | ||
|
|
9d15c666b2 | ||
|
|
2131678f6b | ||
|
|
17f07b2452 | ||
|
|
05d69ae822 | ||
|
|
3ae81d62bc | ||
|
|
4efa123183 | ||
|
|
24a9886952 | ||
|
|
7ec1343ad5 | ||
|
|
7e1fffc455 | ||
|
|
f4608b3e31 | ||
|
|
003dd3a9a2 | ||
|
|
cece04e02f | ||
|
|
58e21e876e | ||
|
|
cb8fc1c10d | ||
|
|
a544f4b2cd | ||
|
|
ee0912a254 |
3
.github/workflows/clang-format.yml
vendored
3
.github/workflows/clang-format.yml
vendored
@@ -16,4 +16,5 @@ jobs:
|
||||
with:
|
||||
source: "."
|
||||
extensions: "hpp,h,cpp,c"
|
||||
clangFormatVersion: 16
|
||||
style: "file:.clang-format"
|
||||
clangFormatVersion: 19
|
||||
|
||||
1
.github/workflows/docker.yml
vendored
1
.github/workflows/docker.yml
vendored
@@ -8,6 +8,7 @@ on:
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository == 'Alexays/Waybar'
|
||||
strategy:
|
||||
fail-fast: false # don't fail the other jobs if one of the images fails to build
|
||||
matrix:
|
||||
|
||||
1
.github/workflows/nix-update-flake-lock.yml
vendored
1
.github/workflows/nix-update-flake-lock.yml
vendored
@@ -9,6 +9,7 @@ on:
|
||||
jobs:
|
||||
lockfile:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name != 'schedule' || github.repository == 'Alexays/Waybar'
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Alex
|
||||
Copyright (c) 2025 Alex
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
- Sway (Workspaces, Binding mode, Focused window name)
|
||||
- River (Mapping mode, Tags, Focused window name)
|
||||
- Hyprland (Window Icons, Workspaces, Focused window name)
|
||||
- DWL (Tags, Focused window name) [requires dwl ipc patch](https://github.com/djpohly/dwl/wiki/ipc)
|
||||
- Niri (Workspaces, Focused window name, Language)
|
||||
- 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
|
||||
- Battery
|
||||
|
||||
12
flake.lock
generated
12
flake.lock
generated
@@ -3,11 +3,11 @@
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1696426674,
|
||||
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
|
||||
"lastModified": 1733328505,
|
||||
"narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
|
||||
"rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -18,11 +18,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1720957393,
|
||||
"narHash": "sha256-oedh2RwpjEa+TNxhg5Je9Ch6d3W1NKi7DbRO1ziHemA=",
|
||||
"lastModified": 1738142207,
|
||||
"narHash": "sha256-NGqpVVxNAHwIicXpgaVqJEJWeyqzoQJ9oc8lnK9+WC4=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "693bc46d169f5af9c992095736e82c3488bf7dbb",
|
||||
"rev": "9d3ae807ebd2981d593cddd0080856873139aa40",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -16,13 +16,15 @@ class AModule : public IModule {
|
||||
|
||||
~AModule() override;
|
||||
auto update() -> void override;
|
||||
virtual auto refresh(int shouldRefresh) -> void{};
|
||||
virtual auto refresh(int shouldRefresh) -> void {};
|
||||
operator Gtk::Widget &() override;
|
||||
auto doAction(const std::string &name) -> void override;
|
||||
|
||||
/// Emitting on this dispatcher triggers a update() call
|
||||
Glib::Dispatcher dp;
|
||||
|
||||
bool expandEnabled() const;
|
||||
|
||||
protected:
|
||||
// Don't need to make an object directly
|
||||
// Derived classes are able to use it
|
||||
@@ -50,6 +52,7 @@ class AModule : public IModule {
|
||||
private:
|
||||
bool handleUserEvent(GdkEventButton *const &ev);
|
||||
const bool isTooltip;
|
||||
const bool isExpand;
|
||||
bool hasUserEvents_;
|
||||
std::vector<int> pid_;
|
||||
gdouble distance_scrolled_y_;
|
||||
|
||||
@@ -42,7 +42,7 @@ struct bar_margins {
|
||||
};
|
||||
|
||||
struct bar_mode {
|
||||
std::optional<bar_layer> layer;
|
||||
bar_layer layer;
|
||||
bool exclusive;
|
||||
bool passthrough;
|
||||
bool visible;
|
||||
@@ -54,7 +54,7 @@ class BarIpcClient;
|
||||
}
|
||||
#endif // HAVE_SWAY
|
||||
|
||||
class Bar {
|
||||
class Bar : public sigc::trackable {
|
||||
public:
|
||||
using bar_mode_map = std::map<std::string, struct bar_mode>;
|
||||
static const bar_mode_map PRESET_MODES;
|
||||
@@ -66,7 +66,7 @@ class Bar {
|
||||
~Bar();
|
||||
|
||||
void setMode(const std::string &mode);
|
||||
void setVisible(bool visible);
|
||||
void setVisible(bool value);
|
||||
void toggle();
|
||||
void handleSignal(int);
|
||||
|
||||
|
||||
@@ -20,6 +20,9 @@ class Config {
|
||||
static std::optional<std::string> findConfigPath(
|
||||
const std::vector<std::string> &names, const std::vector<std::string> &dirs = CONFIG_DIRS);
|
||||
|
||||
static std::vector<std::string> tryExpandPath(const std::string &base,
|
||||
const std::string &filename);
|
||||
|
||||
Config() = default;
|
||||
|
||||
void load(const std::string &config);
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace waybar {
|
||||
class Group : public AModule {
|
||||
public:
|
||||
Group(const std::string &, const std::string &, const Json::Value &, bool);
|
||||
virtual ~Group() = default;
|
||||
~Group() override = default;
|
||||
auto update() -> void override;
|
||||
operator Gtk::Widget &() override;
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@ class Cava final : public ALabel {
|
||||
util::SleeperThread thread_;
|
||||
util::SleeperThread thread_fetch_input_;
|
||||
|
||||
struct cava::error_s error_ {}; // cava errors
|
||||
struct cava::config_params prm_ {}; // cava parameters
|
||||
struct cava::audio_raw audio_raw_ {}; // cava handled raw audio data(is based on audio_data)
|
||||
struct cava::audio_data audio_data_ {}; // cava audio data
|
||||
struct cava::cava_plan* plan_; //{new cava_plan{}};
|
||||
struct cava::error_s error_{}; // cava errors
|
||||
struct cava::config_params prm_{}; // cava parameters
|
||||
struct cava::audio_raw audio_raw_{}; // cava handled raw audio data(is based on audio_data)
|
||||
struct cava::audio_data audio_data_{}; // cava audio data
|
||||
struct cava::cava_plan* plan_; //{new cava_plan{}};
|
||||
// Cava API to read audio source
|
||||
cava::ptr input_source_;
|
||||
// Delay to handle audio source
|
||||
@@ -39,11 +39,12 @@ class Cava final : public ALabel {
|
||||
std::chrono::seconds suspend_silence_delay_{0};
|
||||
bool silence_{false};
|
||||
bool hide_on_silence_{false};
|
||||
std::string format_silent_{""};
|
||||
int sleep_counter_{0};
|
||||
// Cava method
|
||||
void pause_resume();
|
||||
// ModuleActionMap
|
||||
static inline std::map<const std::string, void (waybar::modules::Cava::*const)()> actionMap_{
|
||||
static inline std::map<const std::string, void (waybar::modules::Cava::* const)()> actionMap_{
|
||||
{"mode", &waybar::modules::Cava::pause_resume}};
|
||||
};
|
||||
} // namespace waybar::modules
|
||||
|
||||
@@ -79,7 +79,7 @@ class Clock final : public ALabel {
|
||||
void tz_up();
|
||||
void tz_down();
|
||||
// Module Action Map
|
||||
static inline std::map<const std::string, void (waybar::modules::Clock::*const)()> actionMap_{
|
||||
static inline std::map<const std::string, void (waybar::modules::Clock::* const)()> actionMap_{
|
||||
{"mode", &waybar::modules::Clock::cldModeSwitch},
|
||||
{"shift_up", &waybar::modules::Clock::cldShift_up},
|
||||
{"shift_down", &waybar::modules::Clock::cldShift_down},
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
#include <filesystem>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
|
||||
#include "util/json.hpp"
|
||||
@@ -19,7 +19,9 @@ class EventHandler {
|
||||
|
||||
class IPC {
|
||||
public:
|
||||
IPC() { startIPC(); }
|
||||
IPC();
|
||||
~IPC();
|
||||
static IPC& inst();
|
||||
|
||||
void registerForIPC(const std::string& ev, EventHandler* ev_handler);
|
||||
void unregisterForIPC(EventHandler* handler);
|
||||
@@ -32,14 +34,16 @@ class IPC {
|
||||
static std::filesystem::path socketFolder_;
|
||||
|
||||
private:
|
||||
void startIPC();
|
||||
void socketListener();
|
||||
void parseIPC(const std::string&);
|
||||
|
||||
std::thread ipcThread_;
|
||||
std::mutex callbackMutex_;
|
||||
util::JsonParser parser_;
|
||||
std::list<std::pair<std::string, EventHandler*>> callbacks_;
|
||||
int socketfd_; // the hyprland socket file descriptor
|
||||
bool running_ = true;
|
||||
};
|
||||
|
||||
inline std::unique_ptr<IPC> gIPC;
|
||||
inline bool modulesReady = false;
|
||||
}; // namespace waybar::modules::hyprland
|
||||
|
||||
@@ -37,6 +37,8 @@ class Language : public waybar::ALabel, public EventHandler {
|
||||
util::JsonParser parser_;
|
||||
|
||||
Layout layout_;
|
||||
|
||||
IPC& m_ipc;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::hyprland
|
||||
|
||||
@@ -28,6 +28,8 @@ class Submap : public waybar::ALabel, public EventHandler {
|
||||
std::string submap_;
|
||||
bool always_on_ = false;
|
||||
std::string default_submap_ = "Default";
|
||||
|
||||
IPC& m_ipc;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::hyprland
|
||||
|
||||
@@ -60,6 +60,8 @@ class Window : public waybar::AAppIconLabel, public EventHandler {
|
||||
bool swallowing_;
|
||||
bool fullscreen_;
|
||||
bool focused_;
|
||||
|
||||
IPC& m_ipc;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::hyprland
|
||||
|
||||
@@ -83,6 +83,7 @@ class Workspace {
|
||||
Gtk::Button m_button;
|
||||
Gtk::Box m_content;
|
||||
Gtk::Label m_label;
|
||||
IPC& m_ipc;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::hyprland
|
||||
|
||||
@@ -150,6 +150,7 @@ class Workspaces : public AModule, public EventHandler {
|
||||
std::mutex m_mutex;
|
||||
const Bar& m_bar;
|
||||
Gtk::Box m_box;
|
||||
IPC& m_ipc;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::hyprland
|
||||
|
||||
@@ -50,7 +50,6 @@ class Network : public ALabel {
|
||||
std::optional<std::pair<unsigned long long, unsigned long long>> readBandwidthUsage();
|
||||
|
||||
int ifid_;
|
||||
sa_family_t family_;
|
||||
struct sockaddr_nl nladdr_ = {0};
|
||||
struct nl_sock* sock_ = nullptr;
|
||||
struct nl_sock* ev_sock_ = nullptr;
|
||||
|
||||
52
include/modules/niri/backend.hpp
Normal file
52
include/modules/niri/backend.hpp
Normal file
@@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "util/json.hpp"
|
||||
|
||||
namespace waybar::modules::niri {
|
||||
|
||||
class EventHandler {
|
||||
public:
|
||||
virtual void onEvent(const Json::Value& ev) = 0;
|
||||
virtual ~EventHandler() = default;
|
||||
};
|
||||
|
||||
class IPC {
|
||||
public:
|
||||
IPC() { startIPC(); }
|
||||
|
||||
void registerForIPC(const std::string& ev, EventHandler* ev_handler);
|
||||
void unregisterForIPC(EventHandler* handler);
|
||||
|
||||
static Json::Value send(const Json::Value& request);
|
||||
|
||||
// The data members are only safe to access while dataMutex_ is locked.
|
||||
std::lock_guard<std::mutex> lockData() { return std::lock_guard(dataMutex_); }
|
||||
const std::vector<Json::Value>& workspaces() const { return workspaces_; }
|
||||
const std::vector<Json::Value>& windows() const { return windows_; }
|
||||
const std::vector<std::string>& keyboardLayoutNames() const { return keyboardLayoutNames_; }
|
||||
unsigned keyboardLayoutCurrent() const { return keyboardLayoutCurrent_; }
|
||||
|
||||
private:
|
||||
void startIPC();
|
||||
static int connectToSocket();
|
||||
void parseIPC(const std::string&);
|
||||
|
||||
std::mutex dataMutex_;
|
||||
std::vector<Json::Value> workspaces_;
|
||||
std::vector<Json::Value> windows_;
|
||||
std::vector<std::string> keyboardLayoutNames_;
|
||||
unsigned keyboardLayoutCurrent_;
|
||||
|
||||
util::JsonParser parser_;
|
||||
std::mutex callbackMutex_;
|
||||
std::list<std::pair<std::string, EventHandler*>> callbacks_;
|
||||
};
|
||||
|
||||
inline std::unique_ptr<IPC> gIPC;
|
||||
|
||||
}; // namespace waybar::modules::niri
|
||||
38
include/modules/niri/language.hpp
Normal file
38
include/modules/niri/language.hpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "ALabel.hpp"
|
||||
#include "bar.hpp"
|
||||
#include "modules/niri/backend.hpp"
|
||||
|
||||
namespace waybar::modules::niri {
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
static Layout getLayout(const std::string &fullName);
|
||||
|
||||
std::mutex mutex_;
|
||||
const Bar &bar_;
|
||||
|
||||
std::vector<Layout> layouts_;
|
||||
unsigned current_idx_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::niri
|
||||
28
include/modules/niri/window.hpp
Normal file
28
include/modules/niri/window.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <gtkmm/button.h>
|
||||
#include <json/value.h>
|
||||
|
||||
#include "AAppIconLabel.hpp"
|
||||
#include "bar.hpp"
|
||||
#include "modules/niri/backend.hpp"
|
||||
|
||||
namespace waybar::modules::niri {
|
||||
|
||||
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_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::niri
|
||||
30
include/modules/niri/workspaces.hpp
Normal file
30
include/modules/niri/workspaces.hpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <gtkmm/button.h>
|
||||
#include <json/value.h>
|
||||
|
||||
#include "AModule.hpp"
|
||||
#include "bar.hpp"
|
||||
#include "modules/niri/backend.hpp"
|
||||
|
||||
namespace waybar::modules::niri {
|
||||
|
||||
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(const Json::Value &ws);
|
||||
std::string getIcon(const std::string &value, const Json::Value &ws);
|
||||
|
||||
const Bar &bar_;
|
||||
Gtk::Box box_;
|
||||
// Map from niri workspace id to button.
|
||||
std::unordered_map<uint64_t, Gtk::Button> buttons_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::niri
|
||||
@@ -49,7 +49,6 @@ class Workspaces : public AModule, public sigc::trackable {
|
||||
std::vector<std::string> workspaces_order_;
|
||||
Gtk::Box box_;
|
||||
std::string m_formatWindowSeperator;
|
||||
std::string m_windowRewriteDefault;
|
||||
util::RegexCollection m_windowRewriteRules;
|
||||
util::JsonParser parser_;
|
||||
std::unordered_map<std::string, Gtk::Button> buttons_;
|
||||
|
||||
@@ -18,6 +18,7 @@ class Temperature : public ALabel {
|
||||
private:
|
||||
float getTemperature();
|
||||
bool isCritical(uint16_t);
|
||||
bool isWarning(uint16_t);
|
||||
|
||||
std::string file_path_;
|
||||
util::SleeperThread thread_;
|
||||
|
||||
@@ -24,6 +24,10 @@
|
||||
|
||||
namespace waybar::modules::wlr {
|
||||
|
||||
struct widget_geometry {
|
||||
int x, y, w, h;
|
||||
};
|
||||
|
||||
class Taskbar;
|
||||
|
||||
class Task {
|
||||
@@ -42,6 +46,7 @@ class Task {
|
||||
};
|
||||
// made public so TaskBar can reorder based on configuration.
|
||||
Gtk::Button button;
|
||||
struct widget_geometry minimize_hint;
|
||||
|
||||
private:
|
||||
static uint32_t global_id;
|
||||
@@ -82,6 +87,8 @@ class Task {
|
||||
private:
|
||||
std::string repr() const;
|
||||
std::string state_string(bool = false) const;
|
||||
void set_minimize_hint();
|
||||
void on_button_size_allocated(Gtk::Allocation &alloc);
|
||||
void set_app_info_from_app_id_list(const std::string &app_id_list);
|
||||
bool image_load_icon(Gtk::Image &image, const Glib::RefPtr<Gtk::IconTheme> &icon_theme,
|
||||
Glib::RefPtr<Gio::DesktopAppInfo> app_info, int size);
|
||||
|
||||
@@ -38,6 +38,8 @@ class AudioBackend {
|
||||
std::string desc_;
|
||||
std::string monitor_;
|
||||
std::string current_sink_name_;
|
||||
std::string default_sink_name;
|
||||
bool default_sink_running_;
|
||||
bool current_sink_running_;
|
||||
// SOURCE
|
||||
uint32_t source_idx_{0};
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
class pow_format {
|
||||
public:
|
||||
pow_format(long long val, std::string&& unit, bool binary = false)
|
||||
: val_(val), unit_(unit), binary_(binary){};
|
||||
: val_(val), unit_(unit), binary_(binary) {};
|
||||
|
||||
long long val_;
|
||||
std::string unit_;
|
||||
|
||||
@@ -31,6 +31,11 @@ The brightness can be controlled by dragging the slider across the bar or clicki
|
||||
typeof: string ++
|
||||
The name of the preferred device to control. If left empty, a device will be chosen automatically.
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Enables this module to consume all left over space dynamically.
|
||||
|
||||
# EXAMPLES
|
||||
|
||||
```
|
||||
|
||||
@@ -38,7 +38,7 @@ The *backlight* module displays the current backlight level.
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer ++
|
||||
Positive value to rotate the text label.
|
||||
Positive value to rotate the text label (in 90 degree increments).
|
||||
|
||||
*states*: ++
|
||||
typeof: object ++
|
||||
@@ -81,6 +81,11 @@ The *backlight* module displays the current backlight level.
|
||||
default: 1.0 ++
|
||||
The speed at which to change the brightness when scrolling.
|
||||
|
||||
*min-brightness*: ++
|
||||
typeof: double ++
|
||||
default: 0.0 ++
|
||||
The minimum brightness of the backlight.
|
||||
|
||||
*menu*: ++
|
||||
typeof: string ++
|
||||
Action that popups the menu.
|
||||
@@ -94,6 +99,11 @@ The *backlight* module displays the current backlight level.
|
||||
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.
|
||||
|
||||
# EXAMPLE:
|
||||
|
||||
```
|
||||
|
||||
@@ -69,7 +69,7 @@ The *battery* module displays the current capacity and state (eg. charging) of y
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer++
|
||||
Positive value to rotate the text label.
|
||||
Positive value to rotate the text label (in 90 degree increments).
|
||||
|
||||
*on-click*: ++
|
||||
typeof: string ++
|
||||
@@ -122,6 +122,11 @@ The *battery* module displays the current capacity and state (eg. charging) of y
|
||||
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.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{capacity}*: Capacity in percentage
|
||||
|
||||
@@ -54,7 +54,7 @@ Addressed by *bluetooth*
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer ++
|
||||
Positive value to rotate the text label.
|
||||
Positive value to rotate the text label (in 90 degree increments).
|
||||
|
||||
*max-length*: ++
|
||||
typeof: integer ++
|
||||
@@ -142,6 +142,11 @@ Addressed by *bluetooth*
|
||||
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.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{status}*: Status of the bluetooth device.
|
||||
|
||||
@@ -64,6 +64,10 @@ libcava lives in:
|
||||
:[ bool
|
||||
:[ false
|
||||
:[ Hides the widget if no input (after sleep_timer elapsed)
|
||||
|[ *format_silent*
|
||||
:[ string
|
||||
:[
|
||||
:[ Widget's text after sleep_timer elapsed (hide_on_silence has to be false)
|
||||
|[ *method*
|
||||
:[ string
|
||||
:[ pulse
|
||||
@@ -196,3 +200,8 @@ In case when cava releases new version and you're wanna get it, it should be rai
|
||||
}
|
||||
},
|
||||
```
|
||||
# STYLE
|
||||
|
||||
- *#cava*
|
||||
- *#cava.silent* Applied after no sound has been detected for sleep_timer seconds
|
||||
- *#cava.updated* Applied when a new frame is shown
|
||||
|
||||
@@ -15,6 +15,11 @@ Addressed by *cffi/<name>*
|
||||
typeof: string ++
|
||||
The path to the dynamic library to load to control the widget.
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Enables this module to consume all left over space dynamically.
|
||||
|
||||
Some additional configuration may be required depending on the cffi dynamic library being used.
|
||||
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ $XDG_CONFIG_HOME/waybar/config ++
|
||||
|[ *rotate*
|
||||
:[ integer
|
||||
:[
|
||||
:[ Positive value to rotate the text label
|
||||
:[ Positive value to rotate the text label (in 90 degree increments)
|
||||
|[ *on-click*
|
||||
:[ string
|
||||
:[
|
||||
@@ -96,6 +96,10 @@ $XDG_CONFIG_HOME/waybar/config ++
|
||||
:[ array
|
||||
:[
|
||||
:[ The actions corresponding to the buttons of the menu.
|
||||
|[ *expand*:
|
||||
:[ bool
|
||||
:[ false
|
||||
:[ Enables this module to consume all left over space dynamically.
|
||||
|
||||
View all valid format options in *strftime(3)* or have a look https://en.cppreference.com/w/cpp/chrono/duration/formatter
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ The *cpu* module displays the current CPU utilization.
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer ++
|
||||
Positive value to rotate the text label.
|
||||
Positive value to rotate the text label (in 90 degree increments).
|
||||
|
||||
*states*: ++
|
||||
typeof: object ++
|
||||
@@ -82,6 +82,11 @@ The *cpu* module displays the current CPU utilization.
|
||||
default: true ++
|
||||
Option to disable tooltip on hover.
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Enables this module to consume all left over space dynamically.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{load}*: Current CPU load.
|
||||
|
||||
@@ -55,8 +55,8 @@ Addressed by *custom/<name>*
|
||||
|
||||
*format*: ++
|
||||
typeof: string ++
|
||||
default: {} ++
|
||||
The format, how information should be displayed. On {} data gets inserted.
|
||||
default: {text} ++
|
||||
The format, how information should be displayed. On {text} data gets inserted.
|
||||
|
||||
*format-icons*: ++
|
||||
typeof: array ++
|
||||
@@ -64,7 +64,7 @@ Addressed by *custom/<name>*
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer ++
|
||||
Positive value to rotate the text label.
|
||||
Positive value to rotate the text label (in 90 degree increments).
|
||||
|
||||
*max-length*: ++
|
||||
typeof: integer ++
|
||||
@@ -138,6 +138,11 @@ Addressed by *custom/<name>*
|
||||
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.
|
||||
@@ -160,7 +165,7 @@ $text\\n$tooltip\\n$class*
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{}*: Output of the script.
|
||||
*{text}*: Output of the script.
|
||||
|
||||
*{percentage}* Percentage which can be set via a json return type.
|
||||
|
||||
@@ -172,7 +177,7 @@ $text\\n$tooltip\\n$class*
|
||||
|
||||
```
|
||||
"custom/spotify": {
|
||||
"format": " {}",
|
||||
"format": " {text}",
|
||||
"max-length": 40,
|
||||
"interval": 30, // Remove this if your script is endless and write in loop
|
||||
"exec": "$HOME/.config/waybar/mediaplayer.sh 2> /dev/null", // Script in resources folder
|
||||
@@ -185,7 +190,7 @@ $text\\n$tooltip\\n$class*
|
||||
|
||||
```
|
||||
"custom/mpd": {
|
||||
"format": "♪ {}",
|
||||
"format": "♪ {text}",
|
||||
//"max-length": 15,
|
||||
"interval": 10,
|
||||
"exec": "mpc current",
|
||||
@@ -199,7 +204,7 @@ $text\\n$tooltip\\n$class*
|
||||
|
||||
```
|
||||
"custom/cmus": {
|
||||
"format": "♪ {}",
|
||||
"format": "♪ {text}",
|
||||
//"max-length": 15,
|
||||
"interval": 10,
|
||||
"exec": "cmus-remote -C \"format_print '%a - %t'\"", // artist - title
|
||||
@@ -214,7 +219,7 @@ $text\\n$tooltip\\n$class*
|
||||
```
|
||||
|
||||
"custom/pacman": {
|
||||
"format": "{} ",
|
||||
"format": "{text} ",
|
||||
"interval": "once",
|
||||
"exec": "pacman_packages",
|
||||
"on-click": "update-system",
|
||||
@@ -226,7 +231,7 @@ $text\\n$tooltip\\n$class*
|
||||
|
||||
```
|
||||
"custom/pacman": {
|
||||
"format": "{} ",
|
||||
"format": "{text} ",
|
||||
"interval": 3600, // every hour
|
||||
"exec": "checkupdates | wc -l", // # of updates
|
||||
"exec-if": "exit 0", // always run; consider advanced run conditions
|
||||
|
||||
@@ -29,7 +29,7 @@ Addressed by *disk*
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer ++
|
||||
Positive value to rotate the text label.
|
||||
Positive value to rotate the text label (in 90 degree increments).
|
||||
|
||||
*states*: ++
|
||||
typeof: object ++
|
||||
@@ -106,6 +106,11 @@ Addressed by *disk*
|
||||
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.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{percentage_used}*: Percentage of disk in use.
|
||||
|
||||
@@ -26,6 +26,11 @@ Addressed by *dwl/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.
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Enables this module to consume all left over space dynamically.
|
||||
|
||||
# EXAMPLE
|
||||
|
||||
```
|
||||
|
||||
@@ -19,7 +19,7 @@ Addressed by *dwl/window*
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer ++
|
||||
Positive value to rotate the text label.
|
||||
Positive value to rotate the text label (in 90 degree increments).
|
||||
|
||||
*max-length*: ++
|
||||
typeof: integer ++
|
||||
@@ -84,6 +84,11 @@ Addressed by *dwl/window*
|
||||
default: 24 ++
|
||||
Option to change the size of the application icon.
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Enables this module to consume all left over space dynamically.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{title}*: The title of the focused window.
|
||||
|
||||
@@ -61,6 +61,11 @@ Feral Gamemode optimizations.
|
||||
default: 4 ++
|
||||
Defines the spacing between the icon and the text.
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Enables this module to consume all left over space dynamically.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{glyph}*: The string icon glyph to use instead.
|
||||
|
||||
@@ -38,6 +38,11 @@ Addressed by *hyprland/language*
|
||||
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.
|
||||
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
@@ -54,9 +59,9 @@ Addressed by *hyprland/language*
|
||||
|
||||
```
|
||||
"hyprland/language": {
|
||||
"format": "Lang: {long}"
|
||||
"format-en": "AMERICA, HELL YEAH!"
|
||||
"format-tr": "As bayrakları"
|
||||
"format": "Lang: {long}",
|
||||
"format-en": "AMERICA, HELL YEAH!",
|
||||
"format-tr": "As bayrakları",
|
||||
"keyboard-name": "at-translated-set-2-keyboard"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -19,7 +19,7 @@ Addressed by *hyprland/submap*
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer ++
|
||||
Positive value to rotate the text label.
|
||||
Positive value to rotate the text label (in 90 degree increments).
|
||||
|
||||
*max-length*: ++
|
||||
typeof: integer ++
|
||||
@@ -93,6 +93,11 @@ Addressed by *hyprland/submap*
|
||||
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.
|
||||
|
||||
|
||||
# EXAMPLES
|
||||
|
||||
|
||||
@@ -35,6 +35,11 @@ Addressed by *hyprland/window*
|
||||
default: 24 ++
|
||||
Option to change the size of the application icon.
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Enables this module to consume all left over space dynamically.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
See the output of "hyprctl clients" for examples
|
||||
|
||||
|
||||
@@ -78,6 +78,11 @@ Addressed by *hyprland/workspaces*
|
||||
If set to id, workspaces will sort by id.
|
||||
If none of those, workspaces will sort with default behavior.
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Enables this module to consume all left over space dynamically.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{id}*: id of workspace assigned by compositor
|
||||
|
||||
@@ -21,7 +21,7 @@ screensaver, also known as "presentation mode".
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer ++
|
||||
Positive value to rotate the text label.
|
||||
Positive value to rotate the text label (in 90 degree increments).
|
||||
|
||||
*max-length*: ++
|
||||
typeof: integer ++
|
||||
@@ -102,6 +102,11 @@ screensaver, also known as "presentation mode".
|
||||
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.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{status}*: status (*activated* or *deactivated*)
|
||||
|
||||
@@ -64,6 +64,11 @@ The *image* module displays an image from a path.
|
||||
default: true ++
|
||||
Option to enable tooltip on hover.
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Enables this module to consume all left over space dynamically.
|
||||
|
||||
# SCRIPT OUTPUT
|
||||
|
||||
Similar to the *custom* module, output values of the script are *newline* separated.
|
||||
|
||||
@@ -25,7 +25,7 @@ See *systemd-inhibit*(1) for more information.
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer ++
|
||||
Positive value to rotate the text label.
|
||||
Positive value to rotate the text label (in 90 degree increments).
|
||||
|
||||
*max-length*: ++
|
||||
typeof: integer ++
|
||||
@@ -89,6 +89,11 @@ See *systemd-inhibit*(1) for more information.
|
||||
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.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{status}*: status (*activated* or *deactivated*)
|
||||
|
||||
@@ -51,7 +51,7 @@ Addressed by *jack*
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer ++
|
||||
Positive value to rotate the text label.
|
||||
Positive value to rotate the text label (in 90 degree increments).
|
||||
|
||||
*max-length*: ++
|
||||
typeof: integer ++
|
||||
@@ -98,6 +98,11 @@ Addressed by *jack*
|
||||
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.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{load}*: The current CPU load estimated by JACK.
|
||||
|
||||
@@ -53,6 +53,11 @@ You must be a member of the input group to use this module.
|
||||
default: [58, 69, 70] ++
|
||||
Customize the key to trigger this module, the key number can be found in /usr/include/linux/input-event-codes.h or running sudo libinput debug-events --show-keycodes.
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Enables this module to consume all left over space dynamically.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{name}*: Caps, Num, or Scroll.
|
||||
|
||||
@@ -29,7 +29,7 @@ Addressed by *memory*
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer ++
|
||||
Positive value to rotate the text label.
|
||||
Positive value to rotate the text label (in 90 degree increments).
|
||||
|
||||
*states*: ++
|
||||
typeof: object ++
|
||||
@@ -97,6 +97,11 @@ Addressed by *memory*
|
||||
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.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{percentage}*: Percentage of memory in use.
|
||||
|
||||
@@ -91,7 +91,7 @@ Addressed by *mpd*
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer ++
|
||||
Positive value to rotate the text label.
|
||||
Positive value to rotate the text label (in 90 degree increments).
|
||||
|
||||
*max-length*: ++
|
||||
typeof: integer ++
|
||||
@@ -175,6 +175,11 @@ Addressed by *mpd*
|
||||
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.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
## WHEN PLAYING/PAUSED
|
||||
|
||||
@@ -107,7 +107,7 @@ The *mpris* module displays currently playing media via libplayerctl.
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer ++
|
||||
Positive value to rotate the text label.
|
||||
Positive value to rotate the text label (in 90 degree increments).
|
||||
|
||||
*max-length*: ++
|
||||
typeof: integer ++
|
||||
@@ -148,6 +148,11 @@ The *mpris* module displays currently playing media via libplayerctl.
|
||||
typeof: map[string]string ++
|
||||
Allows setting _{status_icon}_ based on player status (playing, paused, stopped).
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Enables this module to consume all left over space dynamically.
|
||||
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ Addressed by *network*
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer ++
|
||||
Positive value to rotate the text label.
|
||||
Positive value to rotate the text label (in 90 degree increments).
|
||||
|
||||
*max-length*: ++
|
||||
typeof: integer ++
|
||||
@@ -142,6 +142,11 @@ Addressed by *network*
|
||||
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.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{ifname}*: Name of the network interface.
|
||||
|
||||
63
man/waybar-niri-language.5.scd
Normal file
63
man/waybar-niri-language.5.scd
Normal file
@@ -0,0 +1,63 @@
|
||||
waybar-niri-language(5)
|
||||
|
||||
# NAME
|
||||
|
||||
waybar - niri language module
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
The *language* module displays the currently selected language in niri.
|
||||
|
||||
# CONFIGURATION
|
||||
|
||||
Addressed by *niri/language*
|
||||
|
||||
*format*: ++
|
||||
typeof: string ++
|
||||
default: {} ++
|
||||
The format, how information should be displayed.
|
||||
|
||||
*format-<lang>* ++
|
||||
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.
|
||||
|
||||
*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.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{short}*: Short name of layout (e.g. "us"). Equals to {}.
|
||||
|
||||
*{shortDescription}*: Short description of layout (e.g. "en").
|
||||
|
||||
*{long}*: Long name of layout (e.g. "English (Dvorak)").
|
||||
|
||||
*{variant}*: Variant of layout (e.g. "dvorak").
|
||||
|
||||
# EXAMPLES
|
||||
|
||||
```
|
||||
"niri/language": {
|
||||
"format": "Lang: {long}"
|
||||
"format-en": "AMERICA, HELL YEAH!"
|
||||
"format-tr": "As bayrakları"
|
||||
}
|
||||
```
|
||||
|
||||
# STYLE
|
||||
|
||||
- *#language*
|
||||
86
man/waybar-niri-window.5.scd
Normal file
86
man/waybar-niri-window.5.scd
Normal file
@@ -0,0 +1,86 @@
|
||||
waybar-niri-window(5)
|
||||
|
||||
# NAME
|
||||
|
||||
waybar - niri window module
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
The *window* module displays the title of the currently focused window in niri.
|
||||
|
||||
# CONFIGURATION
|
||||
|
||||
Addressed by *niri/window*
|
||||
|
||||
*format*: ++
|
||||
typeof: string ++
|
||||
default: {title} ++
|
||||
The format, how information should be displayed. On {} the current window title is displayed.
|
||||
|
||||
*rewrite*: ++
|
||||
typeof: object ++
|
||||
Rules to rewrite window title. See *rewrite rules*.
|
||||
|
||||
*separate-outputs*: ++
|
||||
typeof: bool ++
|
||||
Show the active window of the monitor the bar belongs to, instead of the focused window.
|
||||
|
||||
*icon*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Option to hide the application icon.
|
||||
|
||||
*icon-size*: ++
|
||||
typeof: integer ++
|
||||
default: 24 ++
|
||||
Option to change the size of the application icon.
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Enables this module to consume all left over space dynamically.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
See the output of "niri msg windows" for examples
|
||||
|
||||
*{title}*: The current title of the focused window.
|
||||
|
||||
*{app_id}*: The current app ID of the focused window.
|
||||
|
||||
# REWRITE RULES
|
||||
|
||||
*rewrite* is an object where keys are regular expressions and values are
|
||||
rewrite rules if the expression matches. Rules may contain references to
|
||||
captures of the expression.
|
||||
|
||||
Regular expression and replacement follow ECMA-script rules.
|
||||
|
||||
If no expression matches, the title is left unchanged.
|
||||
|
||||
Invalid expressions (e.g., mismatched parentheses) are skipped.
|
||||
|
||||
# EXAMPLES
|
||||
|
||||
```
|
||||
"niri/window": {
|
||||
"format": "{}",
|
||||
"rewrite": {
|
||||
"(.*) - Mozilla Firefox": "🌎 $1",
|
||||
"(.*) - zsh": "> [$1]"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
# STYLE
|
||||
|
||||
- *#window*
|
||||
- *window#waybar.empty #window* When no windows are on the workspace
|
||||
|
||||
The following classes are applied to the entire Waybar rather than just the
|
||||
window widget:
|
||||
|
||||
- *window#waybar.empty* When no windows are in the workspace
|
||||
- *window#waybar.solo* When only one window is on the workspace
|
||||
- *window#waybar.<app-id>* Where *app-id* is the app ID of the only window on
|
||||
the workspace
|
||||
102
man/waybar-niri-workspaces.5.scd
Normal file
102
man/waybar-niri-workspaces.5.scd
Normal file
@@ -0,0 +1,102 @@
|
||||
waybar-niri-workspaces(5)
|
||||
|
||||
# NAME
|
||||
|
||||
waybar - niri workspaces module
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
The *workspaces* module displays the currently used workspaces in niri.
|
||||
|
||||
# CONFIGURATION
|
||||
|
||||
Addressed by *niri/workspaces*
|
||||
|
||||
*all-outputs*: ++
|
||||
typeof: bool ++
|
||||
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.
|
||||
|
||||
*format*: ++
|
||||
typeof: string ++
|
||||
default: {value} ++
|
||||
The format, how information should be displayed.
|
||||
|
||||
*format-icons*: ++
|
||||
typeof: array ++
|
||||
Based on the workspace name, index and state, the corresponding icon gets selected. See *icons*.
|
||||
|
||||
*disable-click*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
If set to false, you can click to change workspace. If set to true this behaviour is disabled.
|
||||
|
||||
*disable-markup*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
If set to true, button label will escape pango markup.
|
||||
|
||||
*current-only*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
If set to true, only the active or focused workspace will be shown.
|
||||
|
||||
*on-update*: ++
|
||||
typeof: string ++
|
||||
Command to execute when the module is updated.
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Enables this module to consume all left over space dynamically.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{value}*: Name of the workspace, or index for unnamed workspaces,
|
||||
as defined by niri.
|
||||
|
||||
*{name}*: Name of the workspace for named workspaces.
|
||||
|
||||
*{icon}*: Icon, as defined in *format-icons*.
|
||||
|
||||
*{index}*: Index of the workspace on its output.
|
||||
|
||||
*{output}*: Output where the workspace is located.
|
||||
|
||||
# ICONS
|
||||
|
||||
Additional to workspace name matching, the following *format-icons* can be set.
|
||||
|
||||
- *default*: Will be shown, when no string matches are found.
|
||||
- *focused*: Will be shown, when workspace is focused.
|
||||
- *active*: Will be shown, when workspace is active on its output.
|
||||
|
||||
# EXAMPLES
|
||||
|
||||
```
|
||||
"niri/workspaces": {
|
||||
"format": "{icon}",
|
||||
"format-icons": {
|
||||
// Named workspaces
|
||||
// (you need to configure them in niri)
|
||||
"browser": "",
|
||||
"discord": "",
|
||||
"chat": "<b></b>",
|
||||
|
||||
// Icons by state
|
||||
"active": "",
|
||||
"default": ""
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
# Style
|
||||
|
||||
- *#workspaces button*
|
||||
- *#workspaces button.focused*: The single focused workspace.
|
||||
- *#workspaces button.active*: The workspace is active (visible) on its output.
|
||||
- *#workspaces button.empty*: The workspace is empty.
|
||||
- *#workspaces button.current_output*: The workspace is from the same output as
|
||||
the bar that it is displayed on.
|
||||
- *#workspaces button#niri-workspace-<name>*: Workspaces named this, or index
|
||||
for unnamed workspaces.
|
||||
@@ -35,6 +35,13 @@ $XDG_CONFIG_HOME/waybar/config
|
||||
:[ object
|
||||
:[ See default value in the example below.
|
||||
:[ Icons used to represent the various power-profile. *Note*: the default configuration uses the font-awesome icons. You may want to override it if you don't have this font installed on your system.
|
||||
|[ *expand*:
|
||||
:[ bool
|
||||
:[ false
|
||||
:[ Enables this module to consume all left over space dynamically.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# CONFIGURATION EXAMPLES
|
||||
|
||||
@@ -32,6 +32,11 @@ the screen or playing audio.
|
||||
Which privacy modules to monitor. See *MODULES CONFIGURATION* for++
|
||||
more information.
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Enables this module to consume all left over space dynamically.
|
||||
|
||||
# MODULES CONFIGURATION
|
||||
|
||||
*type*: ++
|
||||
|
||||
@@ -27,6 +27,11 @@ The volume can be controlled by dragging the slider across the bar or clicking o
|
||||
default: horizontal ++
|
||||
The orientation of the slider. Can be either `horizontal` or `vertical`.
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Enables this module to consume all left over space dynamically.
|
||||
|
||||
# EXAMPLES
|
||||
|
||||
```
|
||||
|
||||
@@ -40,7 +40,7 @@ Additionally, you can control the volume by scrolling *up* or *down* while the c
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer ++
|
||||
Positive value to rotate the text label.
|
||||
Positive value to rotate the text label (in 90 degree increments).
|
||||
|
||||
*states*: ++
|
||||
typeof: object ++
|
||||
@@ -126,6 +126,11 @@ Additionally, you can control the volume by scrolling *up* or *down* while the c
|
||||
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.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{desc}*: Pulseaudio port's description, for bluetooth it'll be the device name.
|
||||
|
||||
@@ -21,7 +21,7 @@ Addressed by *river/layout*
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer ++
|
||||
Positive value to rotate the text label.
|
||||
Positive value to rotate the text label (in 90 degree increments).
|
||||
|
||||
*max-length*: ++
|
||||
typeof: integer ++
|
||||
@@ -64,6 +64,11 @@ Addressed by *river/layout*
|
||||
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.
|
||||
|
||||
# EXAMPLE
|
||||
|
||||
```
|
||||
|
||||
@@ -19,7 +19,7 @@ Addressed by *river/mode*
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer ++
|
||||
Positive value to rotate the text label.
|
||||
Positive value to rotate the text label (in 90 degree increments).
|
||||
|
||||
*max-length*: ++
|
||||
typeof: integer ++
|
||||
@@ -78,6 +78,11 @@ Addressed by *river/mode*
|
||||
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.
|
||||
|
||||
# EXAMPLES
|
||||
|
||||
```
|
||||
|
||||
@@ -26,6 +26,16 @@ 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.
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Enables this module to consume all left over space dynamically.
|
||||
|
||||
*hide-vacant*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Only show relevant tags: tags that are either focused or have a window on them.
|
||||
|
||||
# EXAMPLE
|
||||
|
||||
```
|
||||
|
||||
@@ -19,7 +19,7 @@ Addressed by *river/window*
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer ++
|
||||
Positive value to rotate the text label.
|
||||
Positive value to rotate the text label (in 90 degree increments).
|
||||
|
||||
*max-length*: ++
|
||||
typeof: integer ++
|
||||
@@ -62,6 +62,11 @@ Addressed by *river/window*
|
||||
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.
|
||||
|
||||
# EXAMPLES
|
||||
|
||||
```
|
||||
|
||||
@@ -20,7 +20,7 @@ cursor is over the module, and clicking on the module toggles mute.
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer ++
|
||||
Positive value to rotate the text label.
|
||||
Positive value to rotate the text label (in 90 degree increments).
|
||||
|
||||
*max-length*: ++
|
||||
typeof: integer ++
|
||||
@@ -87,6 +87,11 @@ cursor is over the module, and clicking on the module toggles mute.
|
||||
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.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{volume}*: Volume in percentage.
|
||||
|
||||
@@ -45,6 +45,11 @@ Addressed by *sway/language*
|
||||
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.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{short}*: Short name of layout (e.g. "us"). Equals to {}.
|
||||
|
||||
@@ -19,7 +19,7 @@ Addressed by *sway/mode*
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer ++
|
||||
Positive value to rotate the text label.
|
||||
Positive value to rotate the text label (in 90 degree increments).
|
||||
|
||||
*max-length*: ++
|
||||
typeof: integer ++
|
||||
@@ -83,6 +83,11 @@ Addressed by *sway/mode*
|
||||
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.
|
||||
|
||||
# EXAMPLES
|
||||
|
||||
```
|
||||
|
||||
@@ -49,6 +49,11 @@ Addressed by *sway/scratchpad*
|
||||
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.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{icon}*: Icon, as defined in *format-icons*.
|
||||
|
||||
@@ -19,7 +19,7 @@ Addressed by *sway/window*
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer ++
|
||||
Positive value to rotate the text label.
|
||||
Positive value to rotate the text label (in 90 degree increments).
|
||||
|
||||
*max-length*: ++
|
||||
typeof: integer ++
|
||||
@@ -103,6 +103,11 @@ Addressed by *sway/window*
|
||||
default: 24 ++
|
||||
Option to change the size of the application icon.
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Enables this module to consume all left over space dynamically.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{title}*: The title of the focused window.
|
||||
|
||||
@@ -88,6 +88,7 @@ warp-on-scroll: ++
|
||||
Keys are the rules, while the values are the methods of representation.
|
||||
Rules may specify `class<...>`, `title<...>`, or both in order to fine-tune the matching.
|
||||
You may assign an empty value to a rule to have it ignored from generating any representation in workspaces.
|
||||
For Wayland windows `class` is matched against the `app_id`, and for X11 windows against the `class` property.
|
||||
|
||||
*window-rewrite-default*:
|
||||
typeof: string ++
|
||||
@@ -99,6 +100,11 @@ warp-on-scroll: ++
|
||||
default: " " ++
|
||||
The separator to be used between windows in a workspace.
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Enables this module to consume all left over space dynamically.
|
||||
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
|
||||
@@ -49,6 +49,11 @@ Addressed by *systemd-failed-units*
|
||||
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.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{nr_failed_system}*: Number of failed units from systemwide (PID=1) systemd.
|
||||
|
||||
@@ -31,6 +31,10 @@ Addressed by *temperature*
|
||||
typeof: string ++
|
||||
The temperature filename of your *hwmon-path-abs*, e.g. *temp1_input*
|
||||
|
||||
*warning-threshold*: ++
|
||||
typeof: integer ++
|
||||
The threshold before it is considered warning (Celsius).
|
||||
|
||||
*critical-threshold*: ++
|
||||
typeof: integer ++
|
||||
The threshold before it is considered critical (Celsius).
|
||||
@@ -40,6 +44,10 @@ Addressed by *temperature*
|
||||
default: 10 ++
|
||||
The interval in which the information gets polled.
|
||||
|
||||
*format-warning*: ++
|
||||
typeof: string ++
|
||||
The format to use when temperature is considered warning
|
||||
|
||||
*format-critical*: ++
|
||||
typeof: string ++
|
||||
The format to use when temperature is considered critical
|
||||
@@ -60,7 +68,7 @@ Addressed by *temperature*
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer ++
|
||||
Positive value to rotate the text label.
|
||||
Positive value to rotate the text label (in 90 degree increments).
|
||||
|
||||
*max-length*: ++
|
||||
typeof: integer ++
|
||||
@@ -124,6 +132,11 @@ Addressed by *temperature*
|
||||
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.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{temperatureC}*: Temperature in Celsius.
|
||||
|
||||
@@ -37,6 +37,11 @@ Addressed by *tray*
|
||||
typeof: string ++
|
||||
Command to execute when the module is updated.
|
||||
|
||||
*expand*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Enables this module to consume all left over space dynamically.
|
||||
|
||||
# EXAMPLES
|
||||
|
||||
```
|
||||
|
||||
@@ -31,7 +31,7 @@ The *wireplumber* module displays the current volume reported by WirePlumber.
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer ++
|
||||
Positive value to rotate the text label.
|
||||
Positive value to rotate the text label (in 90 degree increments).
|
||||
|
||||
*states*: ++
|
||||
typeof: object ++
|
||||
|
||||
@@ -23,6 +23,21 @@ The visual display elements for waybar use a CSS stylesheet, see *waybar-styles(
|
||||
|
||||
# BAR CONFIGURATION
|
||||
|
||||
*expand-center* ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Enables the modules-center to consume all left over space dynamically.
|
||||
|
||||
*expand-left* ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Enables the modules-left to consume all left over space dynamically.
|
||||
|
||||
*expand-right* ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Enables the modules-left to consume all left over space dynamically.
|
||||
|
||||
*layer* ++
|
||||
typeof: string ++
|
||||
default: bottom ++
|
||||
@@ -68,6 +83,11 @@ The visual display elements for waybar use a CSS stylesheet, see *waybar-styles(
|
||||
typeof: integer ++
|
||||
Margins value without units.
|
||||
|
||||
*no-center* ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Option to disable the center modules fully usefull together with expand-\*.
|
||||
|
||||
*spacing* ++
|
||||
typeof: integer ++
|
||||
Size of gaps in between the different modules.
|
||||
@@ -181,6 +201,19 @@ A minimal *config* file could look like this:
|
||||
}
|
||||
```
|
||||
|
||||
# SIGNALS
|
||||
|
||||
Waybar accepts the following signals:
|
||||
|
||||
*SIGUSR1*
|
||||
Toggles the bar visibility (hides if shown, shows if hidden)
|
||||
*SIGUSR2*
|
||||
Reloads (resets) the bar
|
||||
*SIGINT*
|
||||
Quits the bar
|
||||
|
||||
For example, to toggle the bar programmatically, you can invoke `killall -SIGUSR1 waybar`.
|
||||
|
||||
# MULTI OUTPUT CONFIGURATION
|
||||
|
||||
## Limit a configuration to some outputs
|
||||
@@ -323,6 +356,9 @@ A group may hide all but one element, showing them only on mouse hover. In order
|
||||
- *waybar-hyprland-submap(5)*
|
||||
- *waybar-hyprland-window(5)*
|
||||
- *waybar-hyprland-workspaces(5)*
|
||||
- *waybar-niri-language(5)*
|
||||
- *waybar-niri-window(5)*
|
||||
- *waybar-niri-workspaces(5)*
|
||||
- *waybar-idle-inhibitor(5)*
|
||||
- *waybar-image(5)*
|
||||
- *waybar-inhibitor(5)*
|
||||
|
||||
23
meson.build
23
meson.build
@@ -1,6 +1,6 @@
|
||||
project(
|
||||
'waybar', 'cpp', 'c',
|
||||
version: '0.10.4',
|
||||
version: '0.12.0',
|
||||
license: 'MIT',
|
||||
meson_version: '>= 0.59.0',
|
||||
default_options : [
|
||||
@@ -69,7 +69,7 @@ is_openbsd = host_machine.system() == 'openbsd'
|
||||
|
||||
thread_dep = dependency('threads')
|
||||
fmt = dependency('fmt', version : ['>=8.1.1'], fallback : ['fmt', 'fmt_dep'])
|
||||
spdlog = dependency('spdlog', version : ['>=1.10.0'], fallback : ['spdlog', 'spdlog_dep'], default_options : ['external_fmt=enabled'])
|
||||
spdlog = dependency('spdlog', version : ['>=1.10.0'], fallback : ['spdlog', 'spdlog_dep'], default_options : ['external_fmt=enabled', 'std_format=disabled', 'tests=disabled'])
|
||||
wayland_client = dependency('wayland-client')
|
||||
wayland_cursor = dependency('wayland-cursor')
|
||||
wayland_protos = dependency('wayland-protocols')
|
||||
@@ -106,7 +106,7 @@ if libsndio.found()
|
||||
endif
|
||||
endif
|
||||
|
||||
gtk_layer_shell = dependency('gtk-layer-shell-0', version: ['>=0.6.0'],
|
||||
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'))
|
||||
@@ -318,6 +318,21 @@ if true
|
||||
)
|
||||
endif
|
||||
|
||||
if get_option('niri')
|
||||
add_project_arguments('-DHAVE_NIRI', language: 'cpp')
|
||||
src_files += files(
|
||||
'src/modules/niri/backend.cpp',
|
||||
'src/modules/niri/language.cpp',
|
||||
'src/modules/niri/window.cpp',
|
||||
'src/modules/niri/workspaces.cpp',
|
||||
)
|
||||
man_files += files(
|
||||
'man/waybar-niri-language.5.scd',
|
||||
'man/waybar-niri-window.5.scd',
|
||||
'man/waybar-niri-workspaces.5.scd',
|
||||
)
|
||||
endif
|
||||
|
||||
if libnl.found() and libnlgen.found()
|
||||
add_project_arguments('-DHAVE_LIBNL', language: 'cpp')
|
||||
src_files += files('src/modules/network.cpp')
|
||||
@@ -467,7 +482,7 @@ if get_option('experimental')
|
||||
endif
|
||||
|
||||
cava = dependency('cava',
|
||||
version : '>=0.10.2',
|
||||
version : '>=0.10.3',
|
||||
required: get_option('cava'),
|
||||
fallback : ['cava', 'cava_dep'],
|
||||
not_found_message: 'cava is not found. Building waybar without cava')
|
||||
|
||||
@@ -19,3 +19,4 @@ option('experimental', type : 'boolean', value : false, description: 'Enable exp
|
||||
option('jack', type: 'feature', value: 'auto', description: 'Enable support for JACK')
|
||||
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')
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
}:
|
||||
let
|
||||
libcava = rec {
|
||||
version = "0.10.2";
|
||||
version = "0.10.3";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "LukashonakV";
|
||||
repo = "cava";
|
||||
rev = version;
|
||||
hash = "sha256-jU7RQV2txruu/nUUl0TzjK4nai7G38J1rcTjO7UXumY=";
|
||||
hash = "sha256-ZDFbI69ECsUTjbhlw2kHRufZbQMu+FQSMmncCJ5pagg=";
|
||||
};
|
||||
};
|
||||
in
|
||||
@@ -25,6 +25,9 @@ in
|
||||
|
||||
mesonFlags = lib.remove "-Dgtk-layer-shell=enabled" oldAttrs.mesonFlags;
|
||||
|
||||
# downstream patch should not affect upstream
|
||||
patches = [];
|
||||
|
||||
buildInputs = (builtins.filter (p: p.pname != "wireplumber") oldAttrs.buildInputs) ++ [
|
||||
pkgs.wireplumber
|
||||
];
|
||||
|
||||
@@ -189,7 +189,7 @@
|
||||
"on-click": "pavucontrol"
|
||||
},
|
||||
"custom/media": {
|
||||
"format": "{icon} {}",
|
||||
"format": "{icon} {text}",
|
||||
"return-type": "json",
|
||||
"max-length": 40,
|
||||
"format-icons": {
|
||||
|
||||
@@ -154,6 +154,15 @@ void AAppIconLabel::updateAppIcon() {
|
||||
update_app_icon_ = false;
|
||||
if (app_icon_name_.empty()) {
|
||||
image_.set_visible(false);
|
||||
} else if (app_icon_name_.front() == '/') {
|
||||
auto pixbuf = Gdk::Pixbuf::create_from_file(app_icon_name_);
|
||||
int scaled_icon_size = app_icon_size_ * image_.get_scale_factor();
|
||||
pixbuf = Gdk::Pixbuf::create_from_file(app_icon_name_, 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(app_icon_name_, Gtk::ICON_SIZE_INVALID);
|
||||
image_.set_visible(true);
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include <iostream>
|
||||
#include <util/command.hpp>
|
||||
|
||||
#include "config.hpp"
|
||||
|
||||
namespace waybar {
|
||||
|
||||
ALabel::ALabel(const Json::Value& config, const std::string& name, const std::string& id,
|
||||
@@ -43,6 +45,8 @@ ALabel::ALabel(const Json::Value& config, const std::string& name, const std::st
|
||||
|
||||
if (config_["rotate"].isUInt()) {
|
||||
rotate = config["rotate"].asUInt();
|
||||
if (not(rotate == 0 || rotate == 90 || rotate == 180 || rotate == 270))
|
||||
spdlog::warn("'rotate' is only supported in 90 degree increments {} is not valid.", rotate);
|
||||
label_.set_angle(rotate);
|
||||
}
|
||||
|
||||
@@ -61,6 +65,14 @@ ALabel::ALabel(const Json::Value& config, const std::string& name, const std::st
|
||||
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()) {
|
||||
@@ -170,7 +182,7 @@ bool waybar::ALabel::handleToggle(GdkEventButton* const& e) {
|
||||
return AModule::handleToggle(e);
|
||||
}
|
||||
|
||||
void ALabel::handleGtkMenuEvent(GtkMenuItem* menuitem, gpointer data) {
|
||||
void ALabel::handleGtkMenuEvent(GtkMenuItem* /*menuitem*/, gpointer data) {
|
||||
waybar::util::command::res res = waybar::util::command::exec((char*)data, "GtkMenu");
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ AModule::AModule(const Json::Value& config, const std::string& name, const std::
|
||||
: name_(name),
|
||||
config_(config),
|
||||
isTooltip{config_["tooltip"].isBool() ? config_["tooltip"].asBool() : true},
|
||||
isExpand{config_["expand"].isBool() ? config_["expand"].asBool() : false},
|
||||
distance_scrolled_y_(0.0),
|
||||
distance_scrolled_x_(0.0) {
|
||||
// Configure module action Map
|
||||
@@ -273,6 +274,7 @@ bool AModule::handleScroll(GdkEventScroll* e) {
|
||||
}
|
||||
|
||||
bool AModule::tooltipEnabled() const { return isTooltip; }
|
||||
bool AModule::expandEnabled() const { return isExpand; }
|
||||
|
||||
AModule::operator Gtk::Widget&() { return event_box_; }
|
||||
|
||||
|
||||
65
src/bar.cpp
65
src/bar.cpp
@@ -37,19 +37,19 @@ const Bar::bar_mode_map Bar::PRESET_MODES = { //
|
||||
.visible = true}},
|
||||
{"hide",
|
||||
{//
|
||||
.layer = bar_layer::TOP,
|
||||
.layer = bar_layer::OVERLAY,
|
||||
.exclusive = false,
|
||||
.passthrough = false,
|
||||
.visible = true}},
|
||||
{"invisible",
|
||||
{//
|
||||
.layer = std::nullopt,
|
||||
.layer = bar_layer::BOTTOM,
|
||||
.exclusive = false,
|
||||
.passthrough = true,
|
||||
.visible = false}},
|
||||
{"overlay",
|
||||
{//
|
||||
.layer = bar_layer::TOP,
|
||||
.layer = bar_layer::OVERLAY,
|
||||
.exclusive = false,
|
||||
.passthrough = true,
|
||||
.visible = true}}};
|
||||
@@ -59,7 +59,7 @@ const std::string Bar::MODE_INVISIBLE = "invisible";
|
||||
const std::string_view DEFAULT_BAR_ID = "bar-0";
|
||||
|
||||
/* Deserializer for enum bar_layer */
|
||||
void from_json(const Json::Value& j, std::optional<bar_layer>& l) {
|
||||
void from_json(const Json::Value& j, bar_layer& l) {
|
||||
if (j == "bottom") {
|
||||
l = bar_layer::BOTTOM;
|
||||
} else if (j == "top") {
|
||||
@@ -132,6 +132,7 @@ void from_json(const Json::Value& j, std::map<Key, Value>& m) {
|
||||
waybar::Bar::Bar(struct waybar_output* w_output, const Json::Value& w_config)
|
||||
: output(w_output),
|
||||
config(w_config),
|
||||
surface(nullptr),
|
||||
window{Gtk::WindowType::WINDOW_TOPLEVEL},
|
||||
x_global(0),
|
||||
y_global(0),
|
||||
@@ -316,13 +317,13 @@ void waybar::Bar::setMode(const std::string& mode) {
|
||||
void waybar::Bar::setMode(const struct bar_mode& mode) {
|
||||
auto* gtk_window = window.gobj();
|
||||
|
||||
if (mode.layer == bar_layer::BOTTOM) {
|
||||
gtk_layer_set_layer(gtk_window, GTK_LAYER_SHELL_LAYER_BOTTOM);
|
||||
} else if (mode.layer == bar_layer::TOP) {
|
||||
gtk_layer_set_layer(gtk_window, GTK_LAYER_SHELL_LAYER_TOP);
|
||||
auto layer = GTK_LAYER_SHELL_LAYER_BOTTOM;
|
||||
if (mode.layer == bar_layer::TOP) {
|
||||
layer = GTK_LAYER_SHELL_LAYER_TOP;
|
||||
} else if (mode.layer == bar_layer::OVERLAY) {
|
||||
gtk_layer_set_layer(gtk_window, GTK_LAYER_SHELL_LAYER_OVERLAY);
|
||||
layer = GTK_LAYER_SHELL_LAYER_OVERLAY;
|
||||
}
|
||||
gtk_layer_set_layer(gtk_window, layer);
|
||||
|
||||
if (mode.exclusive) {
|
||||
gtk_layer_auto_exclusive_zone_enable(gtk_window);
|
||||
@@ -339,6 +340,13 @@ void waybar::Bar::setMode(const struct bar_mode& mode) {
|
||||
window.get_style_context()->add_class("hidden");
|
||||
window.set_opacity(0);
|
||||
}
|
||||
/*
|
||||
* All the changes above require `wl_surface_commit`.
|
||||
* gtk-layer-shell schedules a commit on the next frame event in GTK, but this could fail in
|
||||
* certain scenarios, such as fully occluded bar.
|
||||
*/
|
||||
gtk_layer_try_force_commit(gtk_window);
|
||||
wl_display_flush(Client::inst()->wl_display);
|
||||
}
|
||||
|
||||
void waybar::Bar::setPassThrough(bool passthrough) {
|
||||
@@ -404,7 +412,8 @@ void waybar::Bar::onMap(GdkEventAny* /*unused*/) {
|
||||
setPassThrough(passthrough_);
|
||||
}
|
||||
|
||||
void waybar::Bar::setVisible(bool visible) {
|
||||
void waybar::Bar::setVisible(bool value) {
|
||||
visible = value;
|
||||
if (auto mode = config.get("mode", {}); mode.isString()) {
|
||||
setMode(visible ? config["mode"].asString() : MODE_INVISIBLE);
|
||||
} else {
|
||||
@@ -525,13 +534,22 @@ void waybar::Bar::getModules(const Factory& factory, const std::string& pos,
|
||||
|
||||
auto waybar::Bar::setupWidgets() -> void {
|
||||
window.add(box_);
|
||||
box_.pack_start(left_, false, false);
|
||||
if (config["fixed-center"].isBool() ? config["fixed-center"].asBool() : true) {
|
||||
box_.set_center_widget(center_);
|
||||
} else {
|
||||
box_.pack_start(center_, true, false);
|
||||
|
||||
bool expand_left = config["expand-left"].isBool() ? config["expand-left"].asBool() : false;
|
||||
bool expand_center = config["expand-center"].isBool() ? config["expand-center"].asBool() : false;
|
||||
bool expand_right = config["expand-right"].isBool() ? config["expand-right"].asBool() : false;
|
||||
bool no_center = config["no-center"].isBool() ? config["no-center"].asBool() : false;
|
||||
|
||||
box_.pack_start(left_, expand_left, expand_left);
|
||||
if (!no_center) {
|
||||
if (config["fixed-center"].isBool() ? config["fixed-center"].asBool() : true) {
|
||||
box_.set_center_widget(center_);
|
||||
} else {
|
||||
spdlog::error("No fixed center_");
|
||||
box_.pack_start(center_, true, expand_center);
|
||||
}
|
||||
}
|
||||
box_.pack_end(right_, false, false);
|
||||
box_.pack_end(right_, expand_right, expand_right);
|
||||
|
||||
// Convert to button code for every module that is used.
|
||||
setupAltFormatKeyForModuleList("modules-left");
|
||||
@@ -540,14 +558,21 @@ auto waybar::Bar::setupWidgets() -> void {
|
||||
|
||||
Factory factory(*this, config);
|
||||
getModules(factory, "modules-left");
|
||||
getModules(factory, "modules-center");
|
||||
if (!no_center) {
|
||||
getModules(factory, "modules-center");
|
||||
}
|
||||
getModules(factory, "modules-right");
|
||||
|
||||
for (auto const& module : modules_left_) {
|
||||
left_.pack_start(*module, false, false);
|
||||
left_.pack_start(*module, module->expandEnabled(), module->expandEnabled());
|
||||
}
|
||||
for (auto const& module : modules_center_) {
|
||||
center_.pack_start(*module, false, false);
|
||||
|
||||
if (!no_center) {
|
||||
for (auto const& module : modules_center_) {
|
||||
center_.pack_start(*module, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
std::reverse(modules_right_.begin(), modules_right_.end());
|
||||
for (auto const& module : modules_right_) {
|
||||
right_.pack_end(*module, false, false);
|
||||
|
||||
@@ -21,7 +21,8 @@ const std::vector<std::string> Config::CONFIG_DIRS = {
|
||||
|
||||
const char *Config::CONFIG_PATH_ENV = "WAYBAR_CONFIG_DIR";
|
||||
|
||||
std::optional<std::string> tryExpandPath(const std::string &base, const std::string &filename) {
|
||||
std::vector<std::string> Config::tryExpandPath(const std::string &base,
|
||||
const std::string &filename) {
|
||||
fs::path path;
|
||||
|
||||
if (!filename.empty()) {
|
||||
@@ -32,33 +33,35 @@ std::optional<std::string> tryExpandPath(const std::string &base, const std::str
|
||||
|
||||
spdlog::debug("Try expanding: {}", path.string());
|
||||
|
||||
std::vector<std::string> results;
|
||||
wordexp_t p;
|
||||
if (wordexp(path.c_str(), &p, 0) == 0) {
|
||||
if (access(*p.we_wordv, F_OK) == 0) {
|
||||
std::string result = *p.we_wordv;
|
||||
wordfree(&p);
|
||||
spdlog::debug("Found config file: {}", path.string());
|
||||
return result;
|
||||
for (size_t i = 0; i < p.we_wordc; i++) {
|
||||
if (access(p.we_wordv[i], F_OK) == 0) {
|
||||
results.emplace_back(p.we_wordv[i]);
|
||||
spdlog::debug("Found config file: {}", p.we_wordv[i]);
|
||||
}
|
||||
}
|
||||
wordfree(&p);
|
||||
}
|
||||
return std::nullopt;
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
std::optional<std::string> Config::findConfigPath(const std::vector<std::string> &names,
|
||||
const std::vector<std::string> &dirs) {
|
||||
if (const char *dir = std::getenv(Config::CONFIG_PATH_ENV)) {
|
||||
for (const auto &name : names) {
|
||||
if (auto res = tryExpandPath(dir, name); res) {
|
||||
return res;
|
||||
if (auto res = tryExpandPath(dir, name); !res.empty()) {
|
||||
return res.front();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto &dir : dirs) {
|
||||
for (const auto &name : names) {
|
||||
if (auto res = tryExpandPath(dir, name); res) {
|
||||
return res;
|
||||
if (auto res = tryExpandPath(dir, name); !res.empty()) {
|
||||
return res.front();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,11 +94,15 @@ void Config::resolveConfigIncludes(Json::Value &config, int depth) {
|
||||
if (includes.isArray()) {
|
||||
for (const auto &include : includes) {
|
||||
spdlog::info("Including resource file: {}", include.asString());
|
||||
setupConfig(config, tryExpandPath(include.asString(), "").value_or(""), ++depth);
|
||||
for (const auto &match : tryExpandPath(include.asString(), "")) {
|
||||
setupConfig(config, match, depth + 1);
|
||||
}
|
||||
}
|
||||
} else if (includes.isString()) {
|
||||
spdlog::info("Including resource file: {}", includes.asString());
|
||||
setupConfig(config, tryExpandPath(includes.asString(), "").value_or(""), ++depth);
|
||||
for (const auto &match : tryExpandPath(includes.asString(), "")) {
|
||||
setupConfig(config, match, depth + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,11 @@
|
||||
#include "modules/hyprland/window.hpp"
|
||||
#include "modules/hyprland/workspaces.hpp"
|
||||
#endif
|
||||
#ifdef HAVE_NIRI
|
||||
#include "modules/niri/language.hpp"
|
||||
#include "modules/niri/window.hpp"
|
||||
#include "modules/niri/workspaces.hpp"
|
||||
#endif
|
||||
#if defined(__FreeBSD__) || defined(__linux__)
|
||||
#include "modules/battery.hpp"
|
||||
#endif
|
||||
@@ -205,6 +210,17 @@ waybar::AModule* waybar::Factory::makeModule(const std::string& name,
|
||||
if (ref == "hyprland/workspaces") {
|
||||
return new waybar::modules::hyprland::Workspaces(id, bar_, config_[name]);
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_NIRI
|
||||
if (ref == "niri/language") {
|
||||
return new waybar::modules::niri::Language(id, bar_, config_[name]);
|
||||
}
|
||||
if (ref == "niri/window") {
|
||||
return new waybar::modules::niri::Window(id, bar_, config_[name]);
|
||||
}
|
||||
if (ref == "niri/workspaces") {
|
||||
return new waybar::modules::niri::Workspaces(id, bar_, config_[name]);
|
||||
}
|
||||
#endif
|
||||
if (ref == "idle_inhibitor") {
|
||||
return new waybar::modules::IdleInhibitor(id, bar_, config_[name]);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
namespace waybar {
|
||||
|
||||
const Gtk::RevealerTransitionType getPreferredTransitionType(bool is_vertical) {
|
||||
Gtk::RevealerTransitionType getPreferredTransitionType(bool is_vertical) {
|
||||
/* The transition direction of a drawer is not actually determined by the transition type,
|
||||
* but rather by the order of 'box' and 'revealer_box':
|
||||
* 'REVEALER_TRANSITION_TYPE_SLIDE_LEFT' and 'REVEALER_TRANSITION_TYPE_SLIDE_RIGHT'
|
||||
@@ -102,7 +102,7 @@ bool Group::handleMouseEnter(GdkEventCrossing* const& e) {
|
||||
}
|
||||
|
||||
bool Group::handleMouseLeave(GdkEventCrossing* const& e) {
|
||||
if (!click_to_reveal) {
|
||||
if (!click_to_reveal && e->detail != GDK_NOTIFY_INFERIOR) {
|
||||
hide_group();
|
||||
}
|
||||
return false;
|
||||
@@ -112,7 +112,7 @@ bool Group::handleToggle(GdkEventButton* const& e) {
|
||||
if (!click_to_reveal || e->button != 1) {
|
||||
return false;
|
||||
}
|
||||
if (box.get_state_flags() & Gtk::StateFlags::STATE_FLAG_PRELIGHT) {
|
||||
if ((box.get_state_flags() & Gtk::StateFlags::STATE_FLAG_PRELIGHT) != 0U) {
|
||||
hide_group();
|
||||
} else {
|
||||
show_group();
|
||||
|
||||
@@ -107,6 +107,10 @@ int main(int argc, char* argv[]) {
|
||||
ret = client->main(argc, argv);
|
||||
} while (reload);
|
||||
|
||||
std::signal(SIGUSR1, SIG_IGN);
|
||||
std::signal(SIGUSR2, SIG_IGN);
|
||||
std::signal(SIGINT, SIG_IGN);
|
||||
|
||||
delete client;
|
||||
return ret;
|
||||
} catch (const std::exception& e) {
|
||||
|
||||
@@ -112,6 +112,14 @@ bool waybar::modules::Backlight::handleScroll(GdkEventScroll *e) {
|
||||
step = config_["scroll-step"].asDouble();
|
||||
}
|
||||
|
||||
double min_brightness = 0;
|
||||
if (config_["min-brightness"].isDouble()) {
|
||||
min_brightness = config_["min-brightness"].asDouble();
|
||||
}
|
||||
if (backend.get_scaled_brightness(preferred_device_) <= min_brightness &&
|
||||
ct == util::ChangeType::Decrease) {
|
||||
return true;
|
||||
}
|
||||
backend.set_brightness(preferred_device_, ct, step);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -273,14 +273,18 @@ waybar::modules::Battery::getInfos() {
|
||||
// Scale these by the voltage to get μW/μWh.
|
||||
|
||||
uint32_t current_now = 0;
|
||||
int32_t _current_now_int = 0;
|
||||
bool current_now_exists = false;
|
||||
if (fs::exists(bat / "current_now")) {
|
||||
current_now_exists = true;
|
||||
std::ifstream(bat / "current_now") >> current_now;
|
||||
std::ifstream(bat / "current_now") >> _current_now_int;
|
||||
} else if (fs::exists(bat / "current_avg")) {
|
||||
current_now_exists = true;
|
||||
std::ifstream(bat / "current_avg") >> current_now;
|
||||
std::ifstream(bat / "current_avg") >> _current_now_int;
|
||||
}
|
||||
// Documentation ABI allows a negative value when discharging, positive
|
||||
// value when charging.
|
||||
current_now = std::abs(_current_now_int);
|
||||
|
||||
if (fs::exists(bat / "time_to_empty_now")) {
|
||||
time_to_empty_now_exists = true;
|
||||
@@ -324,11 +328,15 @@ waybar::modules::Battery::getInfos() {
|
||||
}
|
||||
|
||||
uint32_t power_now = 0;
|
||||
int32_t _power_now_int = 0;
|
||||
bool power_now_exists = false;
|
||||
if (fs::exists(bat / "power_now")) {
|
||||
power_now_exists = true;
|
||||
std::ifstream(bat / "power_now") >> power_now;
|
||||
std::ifstream(bat / "power_now") >> _power_now_int;
|
||||
}
|
||||
// Some drivers (example: Qualcomm) exposes use a negative value when
|
||||
// discharging, positive value when charging.
|
||||
power_now = std::abs(_power_now_int);
|
||||
|
||||
uint32_t energy_now = 0;
|
||||
bool energy_now_exists = false;
|
||||
|
||||
@@ -59,6 +59,7 @@ waybar::modules::Cava::Cava(const std::string& id, const Json::Value& config)
|
||||
if (config_["input_delay"].isInt())
|
||||
fetch_input_delay_ = std::chrono::seconds(config_["input_delay"].asInt());
|
||||
if (config_["hide_on_silence"].isBool()) hide_on_silence_ = config_["hide_on_silence"].asBool();
|
||||
if (config_["format_silent"].isString()) format_silent_ = config_["format_silent"].asString();
|
||||
// Make cava parameters configuration
|
||||
plan_ = new cava::cava_plan{};
|
||||
|
||||
@@ -138,7 +139,7 @@ auto waybar::modules::Cava::update() -> void {
|
||||
}
|
||||
}
|
||||
|
||||
if (silence_ && prm_.sleep_timer) {
|
||||
if (silence_ && prm_.sleep_timer != 0) {
|
||||
if (sleep_counter_ <=
|
||||
(int)(std::chrono::milliseconds(prm_.sleep_timer * 1s) / frame_time_milsec_)) {
|
||||
++sleep_counter_;
|
||||
@@ -146,7 +147,7 @@ auto waybar::modules::Cava::update() -> void {
|
||||
}
|
||||
}
|
||||
|
||||
if (!silence_) {
|
||||
if (!silence_ || prm_.sleep_timer == 0) {
|
||||
downThreadDelay(frame_time_milsec_, suspend_silence_delay_);
|
||||
// Process: execute cava
|
||||
pthread_mutex_lock(&audio_data_.lock);
|
||||
@@ -172,10 +173,19 @@ auto waybar::modules::Cava::update() -> void {
|
||||
label_.set_markup(text_);
|
||||
label_.show();
|
||||
ALabel::update();
|
||||
label_.get_style_context()->add_class("updated");
|
||||
}
|
||||
|
||||
label_.get_style_context()->remove_class("silent");
|
||||
} else {
|
||||
upThreadDelay(frame_time_milsec_, suspend_silence_delay_);
|
||||
if (hide_on_silence_) label_.hide();
|
||||
if (hide_on_silence_)
|
||||
label_.hide();
|
||||
else if (config_["format_silent"].isString())
|
||||
label_.set_markup(format_silent_);
|
||||
|
||||
label_.get_style_context()->add_class("silent");
|
||||
label_.get_style_context()->remove_class("updated");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
|
||||
m_tlpFmt_{(config_["tooltip-format"].isString()) ? config_["tooltip-format"].asString() : ""},
|
||||
m_tooltip_{new Gtk::Label()},
|
||||
cldInTooltip_{m_tlpFmt_.find("{" + kCldPlaceholder + "}") != std::string::npos},
|
||||
cldYearShift_{January / 1 / 1900},
|
||||
tzInTooltip_{m_tlpFmt_.find("{" + kTZPlaceholder + "}") != std::string::npos},
|
||||
tzCurrIdx_{0},
|
||||
ordInTooltip_{m_tlpFmt_.find("{" + kOrdPlaceholder + "}") != std::string::npos} {
|
||||
@@ -163,15 +164,16 @@ auto waybar::modules::Clock::update() -> void {
|
||||
// std::vformat doesn't support named arguments.
|
||||
m_tlpText_ =
|
||||
std::regex_replace(m_tlpFmt_, std::regex("\\{" + kTZPlaceholder + "\\}"), tzText_);
|
||||
m_tlpText_ =
|
||||
std::regex_replace(m_tlpText_, std::regex("\\{" + kCldPlaceholder + "\\}"), cldText_);
|
||||
m_tlpText_ = std::regex_replace(
|
||||
m_tlpText_, std::regex("\\{" + kCldPlaceholder + "\\}"),
|
||||
fmt_lib::vformat(m_locale_, cldText_, fmt_lib::make_format_args(shiftedNow)));
|
||||
m_tlpText_ =
|
||||
std::regex_replace(m_tlpText_, std::regex("\\{" + kOrdPlaceholder + "\\}"), ordText_);
|
||||
} else {
|
||||
m_tlpText_ = m_tlpFmt_;
|
||||
}
|
||||
|
||||
m_tlpText_ = fmt_lib::vformat(m_locale_, m_tlpText_, fmt_lib::make_format_args(shiftedNow));
|
||||
m_tlpText_ = fmt_lib::vformat(m_locale_, m_tlpText_, fmt_lib::make_format_args(now));
|
||||
m_tooltip_->set_markup(m_tlpText_);
|
||||
label_.trigger_tooltip_query();
|
||||
}
|
||||
|
||||
@@ -61,9 +61,36 @@ std::tuple<std::vector<uint16_t>, std::string> waybar::modules::CpuUsage::getCpu
|
||||
std::vector<std::tuple<size_t, size_t>> curr_times = CpuUsage::parseCpuinfo();
|
||||
std::string tooltip;
|
||||
std::vector<uint16_t> usage;
|
||||
|
||||
if (curr_times.size() != prev_times.size()) {
|
||||
// The number of CPUs has changed, eg. due to CPU hotplug
|
||||
// We don't know which CPU came up or went down
|
||||
// so only give total usage (if we can)
|
||||
if (!curr_times.empty() && !prev_times.empty()) {
|
||||
auto [curr_idle, curr_total] = curr_times[0];
|
||||
auto [prev_idle, prev_total] = prev_times[0];
|
||||
const float delta_idle = curr_idle - prev_idle;
|
||||
const float delta_total = curr_total - prev_total;
|
||||
uint16_t tmp = 100 * (1 - delta_idle / delta_total);
|
||||
tooltip = fmt::format("Total: {}%\nCores: (pending)", tmp);
|
||||
usage.push_back(tmp);
|
||||
} else {
|
||||
tooltip = "(pending)";
|
||||
usage.push_back(0);
|
||||
}
|
||||
prev_times = curr_times;
|
||||
return {usage, tooltip};
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < curr_times.size(); ++i) {
|
||||
auto [curr_idle, curr_total] = curr_times[i];
|
||||
auto [prev_idle, prev_total] = prev_times[i];
|
||||
if (i > 0 && (curr_total == 0 || prev_total == 0)) {
|
||||
// This CPU is offline
|
||||
tooltip = tooltip + fmt::format("\nCore{}: offline", i - 1);
|
||||
usage.push_back(0);
|
||||
continue;
|
||||
}
|
||||
const float delta_idle = curr_idle - prev_idle;
|
||||
const float delta_total = curr_total - prev_total;
|
||||
uint16_t tmp = 100 * (1 - delta_idle / delta_total);
|
||||
|
||||
@@ -3,6 +3,23 @@
|
||||
#include "modules/cpu_usage.hpp"
|
||||
|
||||
std::vector<std::tuple<size_t, size_t>> waybar::modules::CpuUsage::parseCpuinfo() {
|
||||
// Get the "existing CPU count" from /sys/devices/system/cpu/present
|
||||
// Probably this is what the user wants the offline CPUs accounted from
|
||||
// For further details see:
|
||||
// https://www.kernel.org/doc/html/latest/core-api/cpu_hotplug.html
|
||||
const std::string sys_cpu_present_path = "/sys/devices/system/cpu/present";
|
||||
size_t cpu_present_last = 0;
|
||||
std::ifstream cpu_present_file(sys_cpu_present_path);
|
||||
std::string cpu_present_text;
|
||||
if (cpu_present_file.is_open()) {
|
||||
getline(cpu_present_file, cpu_present_text);
|
||||
// This is a comma-separated list of ranges, eg. 0,2-4,7
|
||||
size_t last_separator = cpu_present_text.find_last_of("-,");
|
||||
if (last_separator < cpu_present_text.size()) {
|
||||
std::stringstream(cpu_present_text.substr(last_separator + 1)) >> cpu_present_last;
|
||||
}
|
||||
}
|
||||
|
||||
const std::string data_dir_ = "/proc/stat";
|
||||
std::ifstream info(data_dir_);
|
||||
if (!info.is_open()) {
|
||||
@@ -10,14 +27,23 @@ std::vector<std::tuple<size_t, size_t>> waybar::modules::CpuUsage::parseCpuinfo(
|
||||
}
|
||||
std::vector<std::tuple<size_t, size_t>> cpuinfo;
|
||||
std::string line;
|
||||
size_t current_cpu_number = -1; // First line is total, second line is cpu 0
|
||||
while (getline(info, line)) {
|
||||
if (line.substr(0, 3).compare("cpu") != 0) {
|
||||
break;
|
||||
}
|
||||
size_t line_cpu_number;
|
||||
if (current_cpu_number >= 0) {
|
||||
std::stringstream(line.substr(3)) >> line_cpu_number;
|
||||
while (line_cpu_number > current_cpu_number) {
|
||||
// Fill in 0 for offline CPUs missing inside the lines of /proc/stat
|
||||
cpuinfo.emplace_back(0, 0);
|
||||
current_cpu_number++;
|
||||
}
|
||||
}
|
||||
std::stringstream sline(line.substr(5));
|
||||
std::vector<size_t> times;
|
||||
for (size_t time = 0; sline >> time; times.push_back(time))
|
||||
;
|
||||
for (size_t time = 0; sline >> time; times.push_back(time));
|
||||
|
||||
size_t idle_time = 0;
|
||||
size_t total_time = 0;
|
||||
@@ -27,6 +53,14 @@ std::vector<std::tuple<size_t, size_t>> waybar::modules::CpuUsage::parseCpuinfo(
|
||||
total_time = std::accumulate(times.begin(), times.end(), 0);
|
||||
}
|
||||
cpuinfo.emplace_back(idle_time, total_time);
|
||||
current_cpu_number++;
|
||||
}
|
||||
|
||||
while (cpu_present_last >= current_cpu_number) {
|
||||
// Fill in 0 for offline CPUs missing after the lines of /proc/stat
|
||||
cpuinfo.emplace_back(0, 0);
|
||||
current_cpu_number++;
|
||||
}
|
||||
|
||||
return cpuinfo;
|
||||
}
|
||||
|
||||
@@ -159,43 +159,52 @@ auto waybar::modules::Custom::update() -> void {
|
||||
parseOutputRaw();
|
||||
}
|
||||
|
||||
auto str = fmt::format(fmt::runtime(format_), 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()) {
|
||||
event_box_.hide();
|
||||
} else {
|
||||
label_.set_markup(str);
|
||||
if (tooltipEnabled()) {
|
||||
if (tooltip_format_enabled_) {
|
||||
auto tooltip = config_["tooltip-format"].asString();
|
||||
tooltip = fmt::format(fmt::runtime(tooltip), text_, fmt::arg("alt", alt_),
|
||||
fmt::arg("icon", getIcon(percentage_, alt_)),
|
||||
fmt::arg("percentage", percentage_));
|
||||
label_.set_tooltip_markup(tooltip);
|
||||
} else if (text_ == tooltip_) {
|
||||
if (label_.get_tooltip_markup() != str) {
|
||||
label_.set_tooltip_markup(str);
|
||||
}
|
||||
} else {
|
||||
if (label_.get_tooltip_markup() != tooltip_) {
|
||||
label_.set_tooltip_markup(tooltip_);
|
||||
try {
|
||||
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()) {
|
||||
event_box_.hide();
|
||||
} else {
|
||||
label_.set_markup(str);
|
||||
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("icon", getIcon(percentage_, alt_)), fmt::arg("percentage", percentage_));
|
||||
label_.set_tooltip_markup(tooltip);
|
||||
} else if (text_ == tooltip_) {
|
||||
if (label_.get_tooltip_markup() != str) {
|
||||
label_.set_tooltip_markup(str);
|
||||
}
|
||||
} else {
|
||||
if (label_.get_tooltip_markup() != tooltip_) {
|
||||
label_.set_tooltip_markup(tooltip_);
|
||||
}
|
||||
}
|
||||
}
|
||||
auto style = label_.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("text-button");
|
||||
style->add_class(MODULE_CLASS);
|
||||
event_box_.show();
|
||||
}
|
||||
auto style = label_.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("text-button");
|
||||
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
|
||||
|
||||
@@ -53,8 +53,8 @@ static void set_layout(void *data, zdwl_ipc_output_v2 *zdwl_output_v2, uint32_t
|
||||
// Intentionally empty
|
||||
}
|
||||
|
||||
static void appid(void *data, zdwl_ipc_output_v2 *zdwl_output_v2, const char *appid){
|
||||
// Intentionally empty
|
||||
static void appid(void *data, zdwl_ipc_output_v2 *zdwl_output_v2, const char *appid) {
|
||||
// Intentionally empty
|
||||
};
|
||||
|
||||
static const zdwl_ipc_output_v2_listener output_status_listener_impl{
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "client.hpp"
|
||||
#include "dwl-ipc-unstable-v2-client-protocol.h"
|
||||
#include "glibmm/markup.h"
|
||||
#include "util/rewrite_string.hpp"
|
||||
|
||||
namespace waybar::modules::dwl {
|
||||
@@ -97,11 +98,13 @@ Window::~Window() {
|
||||
}
|
||||
}
|
||||
|
||||
void Window::handle_title(const char *title) { title_ = title; }
|
||||
void Window::handle_title(const char *title) { title_ = Glib::Markup::escape_text(title); }
|
||||
|
||||
void Window::handle_appid(const char *appid) { appid_ = appid; }
|
||||
void Window::handle_appid(const char *appid) { appid_ = Glib::Markup::escape_text(appid); }
|
||||
|
||||
void Window::handle_layout_symbol(const char *layout_symbol) { layout_symbol_ = layout_symbol; }
|
||||
void Window::handle_layout_symbol(const char *layout_symbol) {
|
||||
layout_symbol_ = Glib::Markup::escape_text(layout_symbol);
|
||||
}
|
||||
|
||||
void Window::handle_layout(const uint32_t layout) { layout_ = layout; }
|
||||
|
||||
|
||||
@@ -11,13 +11,15 @@
|
||||
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
namespace waybar::modules::hyprland {
|
||||
|
||||
std::filesystem::path IPC::socketFolder_;
|
||||
|
||||
std::filesystem::path IPC::getSocketFolder(const char* instanceSig) {
|
||||
static std::mutex folderMutex;
|
||||
std::unique_lock lock(folderMutex);
|
||||
|
||||
// socket path, specified by EventManager of Hyprland
|
||||
if (!socketFolder_.empty()) {
|
||||
return socketFolder_;
|
||||
@@ -41,71 +43,96 @@ std::filesystem::path IPC::getSocketFolder(const char* instanceSig) {
|
||||
return socketFolder_;
|
||||
}
|
||||
|
||||
void IPC::startIPC() {
|
||||
IPC::IPC() {
|
||||
// will start IPC and relay events to parseIPC
|
||||
ipcThread_ = std::thread([this]() { socketListener(); });
|
||||
}
|
||||
|
||||
std::thread([&]() {
|
||||
// check for hyprland
|
||||
const char* his = getenv("HYPRLAND_INSTANCE_SIGNATURE");
|
||||
|
||||
if (his == nullptr) {
|
||||
spdlog::warn("Hyprland is not running, Hyprland IPC will not be available.");
|
||||
return;
|
||||
IPC::~IPC() {
|
||||
running_ = false;
|
||||
spdlog::info("Hyprland IPC stopping...");
|
||||
if (socketfd_ != -1) {
|
||||
spdlog::trace("Shutting down socket");
|
||||
if (shutdown(socketfd_, SHUT_RDWR) == -1) {
|
||||
spdlog::error("Hyprland IPC: Couldn't shutdown socket");
|
||||
}
|
||||
|
||||
if (!modulesReady) return;
|
||||
|
||||
spdlog::info("Hyprland IPC starting");
|
||||
|
||||
struct sockaddr_un addr;
|
||||
int socketfd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
|
||||
if (socketfd == -1) {
|
||||
spdlog::error("Hyprland IPC: socketfd failed");
|
||||
return;
|
||||
spdlog::trace("Closing socket");
|
||||
if (close(socketfd_) == -1) {
|
||||
spdlog::error("Hyprland IPC: Couldn't close socket");
|
||||
}
|
||||
}
|
||||
ipcThread_.join();
|
||||
}
|
||||
|
||||
addr.sun_family = AF_UNIX;
|
||||
IPC& IPC::inst() {
|
||||
static IPC ipc;
|
||||
return ipc;
|
||||
}
|
||||
|
||||
auto socketPath = IPC::getSocketFolder(his) / ".socket2.sock";
|
||||
strncpy(addr.sun_path, socketPath.c_str(), sizeof(addr.sun_path) - 1);
|
||||
void IPC::socketListener() {
|
||||
// check for hyprland
|
||||
const char* his = getenv("HYPRLAND_INSTANCE_SIGNATURE");
|
||||
|
||||
addr.sun_path[sizeof(addr.sun_path) - 1] = 0;
|
||||
if (his == nullptr) {
|
||||
spdlog::warn("Hyprland is not running, Hyprland IPC will not be available.");
|
||||
return;
|
||||
}
|
||||
|
||||
int l = sizeof(struct sockaddr_un);
|
||||
if (!modulesReady) return;
|
||||
|
||||
if (connect(socketfd, (struct sockaddr*)&addr, l) == -1) {
|
||||
spdlog::error("Hyprland IPC: Unable to connect?");
|
||||
return;
|
||||
}
|
||||
spdlog::info("Hyprland IPC starting");
|
||||
|
||||
auto* file = fdopen(socketfd, "r");
|
||||
struct sockaddr_un addr;
|
||||
socketfd_ = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
|
||||
while (true) {
|
||||
std::array<char, 1024> buffer; // Hyprland socket2 events are max 1024 bytes
|
||||
if (socketfd_ == -1) {
|
||||
spdlog::error("Hyprland IPC: socketfd failed");
|
||||
return;
|
||||
}
|
||||
|
||||
auto* receivedCharPtr = fgets(buffer.data(), buffer.size(), file);
|
||||
addr.sun_family = AF_UNIX;
|
||||
|
||||
if (receivedCharPtr == nullptr) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
continue;
|
||||
}
|
||||
auto socketPath = IPC::getSocketFolder(his) / ".socket2.sock";
|
||||
strncpy(addr.sun_path, socketPath.c_str(), sizeof(addr.sun_path) - 1);
|
||||
|
||||
std::string messageReceived(buffer.data());
|
||||
messageReceived = messageReceived.substr(0, messageReceived.find_first_of('\n'));
|
||||
spdlog::debug("hyprland IPC received {}", messageReceived);
|
||||
addr.sun_path[sizeof(addr.sun_path) - 1] = 0;
|
||||
|
||||
try {
|
||||
parseIPC(messageReceived);
|
||||
} catch (std::exception& e) {
|
||||
spdlog::warn("Failed to parse IPC message: {}, reason: {}", messageReceived, e.what());
|
||||
} catch (...) {
|
||||
throw;
|
||||
}
|
||||
int l = sizeof(struct sockaddr_un);
|
||||
|
||||
if (connect(socketfd_, (struct sockaddr*)&addr, l) == -1) {
|
||||
spdlog::error("Hyprland IPC: Unable to connect?");
|
||||
return;
|
||||
}
|
||||
auto* file = fdopen(socketfd_, "r");
|
||||
if (file == nullptr) {
|
||||
spdlog::error("Hyprland IPC: Couldn't open file descriptor");
|
||||
return;
|
||||
}
|
||||
while (running_) {
|
||||
std::array<char, 1024> buffer; // Hyprland socket2 events are max 1024 bytes
|
||||
|
||||
auto* receivedCharPtr = fgets(buffer.data(), buffer.size(), file);
|
||||
|
||||
if (receivedCharPtr == nullptr) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
continue;
|
||||
}
|
||||
}).detach();
|
||||
|
||||
std::string messageReceived(buffer.data());
|
||||
messageReceived = messageReceived.substr(0, messageReceived.find_first_of('\n'));
|
||||
spdlog::debug("hyprland IPC received {}", messageReceived);
|
||||
|
||||
try {
|
||||
parseIPC(messageReceived);
|
||||
} catch (std::exception& e) {
|
||||
spdlog::warn("Failed to parse IPC message: {}, reason: {}", messageReceived, e.what());
|
||||
} catch (...) {
|
||||
throw;
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
}
|
||||
spdlog::debug("Hyprland IPC stopped");
|
||||
}
|
||||
|
||||
void IPC::parseIPC(const std::string& ev) {
|
||||
@@ -148,22 +175,12 @@ void IPC::unregisterForIPC(EventHandler* ev_handler) {
|
||||
std::string IPC::getSocket1Reply(const std::string& rq) {
|
||||
// basically hyprctl
|
||||
|
||||
struct addrinfo aiHints;
|
||||
struct addrinfo* aiRes = nullptr;
|
||||
const auto serverSocket = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
|
||||
if (serverSocket < 0) {
|
||||
throw std::runtime_error("Hyprland IPC: Couldn't open a socket (1)");
|
||||
}
|
||||
|
||||
memset(&aiHints, 0, sizeof(struct addrinfo));
|
||||
aiHints.ai_family = AF_UNSPEC;
|
||||
aiHints.ai_socktype = SOCK_STREAM;
|
||||
|
||||
if (getaddrinfo("localhost", nullptr, &aiHints, &aiRes) != 0) {
|
||||
throw std::runtime_error("Hyprland IPC: Couldn't get host (2)");
|
||||
}
|
||||
|
||||
// get the instance signature
|
||||
auto* instanceSig = getenv("HYPRLAND_INSTANCE_SIGNATURE");
|
||||
|
||||
|
||||
@@ -10,13 +10,9 @@
|
||||
namespace waybar::modules::hyprland {
|
||||
|
||||
Language::Language(const std::string& id, const Bar& bar, const Json::Value& config)
|
||||
: ALabel(config, "language", id, "{}", 0, true), bar_(bar) {
|
||||
: ALabel(config, "language", id, "{}", 0, true), bar_(bar), m_ipc(IPC::inst()) {
|
||||
modulesReady = true;
|
||||
|
||||
if (!gIPC) {
|
||||
gIPC = std::make_unique<IPC>();
|
||||
}
|
||||
|
||||
// get the active layout when open
|
||||
initLanguage();
|
||||
|
||||
@@ -24,11 +20,11 @@ Language::Language(const std::string& id, const Bar& bar, const Json::Value& con
|
||||
update();
|
||||
|
||||
// register for hyprland ipc
|
||||
gIPC->registerForIPC("activelayout", this);
|
||||
m_ipc.registerForIPC("activelayout", this);
|
||||
}
|
||||
|
||||
Language::~Language() {
|
||||
gIPC->unregisterForIPC(this);
|
||||
m_ipc.unregisterForIPC(this);
|
||||
// wait for possible event handler to finish
|
||||
std::lock_guard<std::mutex> lg(mutex_);
|
||||
}
|
||||
@@ -85,7 +81,7 @@ void Language::onEvent(const std::string& ev) {
|
||||
}
|
||||
|
||||
void Language::initLanguage() {
|
||||
const auto inputDevices = gIPC->getSocket1Reply("devices");
|
||||
const auto inputDevices = m_ipc.getSocket1Reply("devices");
|
||||
|
||||
const auto kbName = config_["keyboard-name"].asString();
|
||||
|
||||
|
||||
@@ -7,15 +7,11 @@
|
||||
namespace waybar::modules::hyprland {
|
||||
|
||||
Submap::Submap(const std::string& id, const Bar& bar, const Json::Value& config)
|
||||
: ALabel(config, "submap", id, "{}", 0, true), bar_(bar) {
|
||||
: ALabel(config, "submap", id, "{}", 0, true), bar_(bar), m_ipc(IPC::inst()) {
|
||||
modulesReady = true;
|
||||
|
||||
parseConfig(config);
|
||||
|
||||
if (!gIPC) {
|
||||
gIPC = std::make_unique<IPC>();
|
||||
}
|
||||
|
||||
label_.hide();
|
||||
ALabel::update();
|
||||
|
||||
@@ -27,12 +23,12 @@ Submap::Submap(const std::string& id, const Bar& bar, const Json::Value& config)
|
||||
}
|
||||
|
||||
// register for hyprland ipc
|
||||
gIPC->registerForIPC("submap", this);
|
||||
m_ipc.registerForIPC("submap", this);
|
||||
dp.emit();
|
||||
}
|
||||
|
||||
Submap::~Submap() {
|
||||
gIPC->unregisterForIPC(this);
|
||||
m_ipc.unregisterForIPC(this);
|
||||
// wait for possible event handler to finish
|
||||
std::lock_guard<std::mutex> lg(mutex_);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user