forked from Alexays/Waybar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into update_flake_lock_action
- Loading branch information
Showing
73 changed files
with
1,335 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.