mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Style code (#25)
This commit is contained in:
@ -12,20 +12,22 @@
|
||||
|
||||
namespace waybar::modules {
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
class Battery : public IModule {
|
||||
public:
|
||||
Battery(Json::Value config);
|
||||
auto update() -> void;
|
||||
operator Gtk::Widget&();
|
||||
private:
|
||||
std::string _getIcon(uint16_t percentage);
|
||||
static inline const fs::path _data_dir = "/sys/class/power_supply/";
|
||||
std::vector<fs::path> _batteries;
|
||||
util::SleeperThread _thread;
|
||||
Gtk::Label _label;
|
||||
Json::Value _config;
|
||||
};
|
||||
class Battery : public IModule {
|
||||
public:
|
||||
Battery(Json::Value);
|
||||
auto update() -> void;
|
||||
operator Gtk::Widget&();
|
||||
private:
|
||||
std::string getIcon(uint16_t percentage);
|
||||
|
||||
static inline const fs::path data_dir_ = "/sys/class/power_supply/";
|
||||
|
||||
Gtk::Label label_;
|
||||
Json::Value config_;
|
||||
util::SleeperThread thread_;
|
||||
std::vector<fs::path> batteries_;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -8,15 +8,15 @@
|
||||
|
||||
namespace waybar::modules {
|
||||
|
||||
class Clock : public IModule {
|
||||
public:
|
||||
Clock(Json::Value config);
|
||||
auto update() -> void;
|
||||
operator Gtk::Widget &();
|
||||
private:
|
||||
Gtk::Label _label;
|
||||
waybar::util::SleeperThread _thread;
|
||||
Json::Value _config;
|
||||
};
|
||||
class Clock : public IModule {
|
||||
public:
|
||||
Clock(Json::Value);
|
||||
auto update() -> void;
|
||||
operator Gtk::Widget &();
|
||||
private:
|
||||
Gtk::Label label_;
|
||||
waybar::util::SleeperThread thread_;
|
||||
Json::Value config_;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -8,15 +8,15 @@
|
||||
|
||||
namespace waybar::modules {
|
||||
|
||||
class Cpu : public IModule {
|
||||
public:
|
||||
Cpu(Json::Value config);
|
||||
auto update() -> void;
|
||||
operator Gtk::Widget &();
|
||||
private:
|
||||
Gtk::Label _label;
|
||||
waybar::util::SleeperThread _thread;
|
||||
Json::Value _config;
|
||||
};
|
||||
class Cpu : public IModule {
|
||||
public:
|
||||
Cpu(Json::Value);
|
||||
auto update() -> void;
|
||||
operator Gtk::Widget &();
|
||||
private:
|
||||
Gtk::Label label_;
|
||||
waybar::util::SleeperThread thread_;
|
||||
Json::Value config_;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -7,16 +7,16 @@
|
||||
|
||||
namespace waybar::modules {
|
||||
|
||||
class Custom : public IModule {
|
||||
public:
|
||||
Custom(std::string name, Json::Value config);
|
||||
auto update() -> void;
|
||||
operator Gtk::Widget &();
|
||||
private:
|
||||
Gtk::Label _label;
|
||||
waybar::util::SleeperThread _thread;
|
||||
const std::string _name;
|
||||
Json::Value _config;
|
||||
};
|
||||
class Custom : public IModule {
|
||||
public:
|
||||
Custom(const std::string&, Json::Value);
|
||||
auto update() -> void;
|
||||
operator Gtk::Widget &();
|
||||
private:
|
||||
const std::string name_;
|
||||
Gtk::Label label_;
|
||||
waybar::util::SleeperThread thread_;
|
||||
Json::Value config_;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -8,15 +8,15 @@
|
||||
|
||||
namespace waybar::modules {
|
||||
|
||||
class Memory : public IModule {
|
||||
public:
|
||||
Memory(Json::Value config);
|
||||
auto update() -> void;
|
||||
operator Gtk::Widget &();
|
||||
private:
|
||||
Gtk::Label _label;
|
||||
waybar::util::SleeperThread _thread;
|
||||
Json::Value _config;
|
||||
};
|
||||
class Memory : public IModule {
|
||||
public:
|
||||
Memory(Json::Value);
|
||||
auto update() -> void;
|
||||
operator Gtk::Widget &();
|
||||
private:
|
||||
Gtk::Label label_;
|
||||
waybar::util::SleeperThread thread_;
|
||||
Json::Value config_;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -12,24 +12,26 @@
|
||||
|
||||
namespace waybar::modules {
|
||||
|
||||
class Network : public IModule {
|
||||
public:
|
||||
Network(Json::Value config);
|
||||
auto update() -> void;
|
||||
operator Gtk::Widget &();
|
||||
private:
|
||||
void _parseEssid(struct nlattr **bss);
|
||||
void _parseSignal(struct nlattr **bss);
|
||||
bool _associatedOrJoined(struct nlattr **bss);
|
||||
static int _scanCb(struct nl_msg *msg, void *data);
|
||||
auto _getInfo() -> void;
|
||||
Gtk::Label _label;
|
||||
waybar::util::SleeperThread _thread;
|
||||
Json::Value _config;
|
||||
std::size_t _ifid;
|
||||
std::string _essid;
|
||||
int _signalStrengthdBm;
|
||||
int _signalStrength;
|
||||
};
|
||||
class Network : public IModule {
|
||||
public:
|
||||
Network(Json::Value);
|
||||
auto update() -> void;
|
||||
operator Gtk::Widget &();
|
||||
private:
|
||||
static int scanCb(struct nl_msg*, void*);
|
||||
|
||||
void parseEssid(struct nlattr**);
|
||||
void parseSignal(struct nlattr**);
|
||||
bool associatedOrJoined(struct nlattr**);
|
||||
auto getInfo() -> void;
|
||||
|
||||
Gtk::Label label_;
|
||||
waybar::util::SleeperThread thread_;
|
||||
Json::Value config_;
|
||||
std::size_t ifid_;
|
||||
std::string essid_;
|
||||
int signal_strength_dbm_;
|
||||
uint16_t signal_strength_;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -8,29 +8,29 @@
|
||||
|
||||
namespace waybar::modules {
|
||||
|
||||
class Pulseaudio : public IModule {
|
||||
public:
|
||||
Pulseaudio(Json::Value config);
|
||||
auto update() -> void;
|
||||
operator Gtk::Widget &();
|
||||
private:
|
||||
std::string _getIcon(uint16_t percentage);
|
||||
static void _subscribeCb(pa_context *context,
|
||||
pa_subscription_event_type_t type, uint32_t idx, void *data);
|
||||
static void _contextStateCb(pa_context *c, void *data);
|
||||
static void _sinkInfoCb(pa_context *context, const pa_sink_info *i,
|
||||
int eol, void *data);
|
||||
static void _serverInfoCb(pa_context *context, const pa_server_info *i,
|
||||
void *data);
|
||||
Gtk::Label _label;
|
||||
Json::Value _config;
|
||||
pa_threaded_mainloop *_mainloop;
|
||||
pa_mainloop_api *_mainloop_api;
|
||||
pa_context *_context;
|
||||
uint32_t _sinkIdx{0};
|
||||
int _volume;
|
||||
bool _muted;
|
||||
std::string _desc;
|
||||
};
|
||||
class Pulseaudio : public IModule {
|
||||
public:
|
||||
Pulseaudio(Json::Value);
|
||||
auto update() -> void;
|
||||
operator Gtk::Widget &();
|
||||
private:
|
||||
static void subscribeCb(pa_context*, pa_subscription_event_type_t,
|
||||
uint32_t, void*);
|
||||
static void contextStateCb(pa_context*, void*);
|
||||
static void sinkInfoCb(pa_context*, const pa_sink_info*, int, void*);
|
||||
static void serverInfoCb(pa_context*, const pa_server_info*, void*);
|
||||
|
||||
std::string getIcon(uint16_t);
|
||||
|
||||
Gtk::Label label_;
|
||||
Json::Value config_;
|
||||
pa_threaded_mainloop* mainloop_;
|
||||
pa_mainloop_api* mainloop_api_;
|
||||
pa_context* context_;
|
||||
uint32_t sink_idx_{0};
|
||||
uint16_t volume_;
|
||||
bool muted_;
|
||||
std::string desc_;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -16,17 +16,17 @@ struct ipc_response {
|
||||
/**
|
||||
* Gets the path to the IPC socket from sway.
|
||||
*/
|
||||
std::string get_socketpath(void);
|
||||
std::string getSocketPath(void);
|
||||
/**
|
||||
* Opens the sway socket.
|
||||
*/
|
||||
int ipc_open_socket(std::string socket_path);
|
||||
int ipcOpenSocket(const std::string &socketPath);
|
||||
/**
|
||||
* Issues a single IPC command and returns the buffer. len will be updated with
|
||||
* the length of the buffer returned from sway.
|
||||
*/
|
||||
std::string ipc_single_command(int socketfd, uint32_t type, const char *payload, uint32_t *len);
|
||||
std::string ipcSingleCommand(int socketfd, uint32_t type, const char *payload, uint32_t *len);
|
||||
/**
|
||||
* Receives a single IPC response and returns an ipc_response.
|
||||
*/
|
||||
struct ipc_response ipc_recv_response(int socketfd);
|
||||
struct ipc_response ipcRecvResponse(int socketfd);
|
||||
|
@ -9,22 +9,23 @@
|
||||
|
||||
namespace waybar::modules::sway {
|
||||
|
||||
class Window : public IModule {
|
||||
public:
|
||||
Window(waybar::Bar &bar, Json::Value config);
|
||||
auto update() -> void;
|
||||
operator Gtk::Widget &();
|
||||
private:
|
||||
std::string _getFocusedNode(Json::Value nodes);
|
||||
void _getFocusedWindow();
|
||||
Bar &_bar;
|
||||
Json::Value _config;
|
||||
waybar::util::SleeperThread _thread;
|
||||
Gtk::Label _label;
|
||||
util::JsonParser _parser;
|
||||
int _ipcfd;
|
||||
int _ipcEventfd;
|
||||
std::string _window;
|
||||
};
|
||||
class Window : public IModule {
|
||||
public:
|
||||
Window(waybar::Bar&, Json::Value);
|
||||
auto update() -> void;
|
||||
operator Gtk::Widget &();
|
||||
private:
|
||||
std::string getFocusedNode(Json::Value nodes);
|
||||
void getFocusedWindow();
|
||||
|
||||
Bar& bar_;
|
||||
Json::Value config_;
|
||||
waybar::util::SleeperThread thread_;
|
||||
Gtk::Label label_;
|
||||
util::JsonParser parser_;
|
||||
int ipcfd_;
|
||||
int ipc_eventfd_;
|
||||
std::string window_;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -9,28 +9,29 @@
|
||||
|
||||
namespace waybar::modules::sway {
|
||||
|
||||
class Workspaces : public IModule {
|
||||
public:
|
||||
Workspaces(waybar::Bar &bar, Json::Value config);
|
||||
auto update() -> void;
|
||||
operator Gtk::Widget &();
|
||||
private:
|
||||
void _addWorkspace(Json::Value node);
|
||||
std::string _getIcon(std::string name);
|
||||
bool _handleScroll(GdkEventScroll *e);
|
||||
int _getPrevWorkspace();
|
||||
int _getNextWorkspace();
|
||||
Bar &_bar;
|
||||
Json::Value _config;
|
||||
waybar::util::SleeperThread _thread;
|
||||
Gtk::Box _box;
|
||||
util::JsonParser _parser;
|
||||
std::mutex _mutex;
|
||||
bool _scrolling;
|
||||
std::unordered_map<int, Gtk::Button> _buttons;
|
||||
Json::Value _workspaces;
|
||||
int _ipcfd;
|
||||
int _ipcEventfd;
|
||||
};
|
||||
class Workspaces : public IModule {
|
||||
public:
|
||||
Workspaces(waybar::Bar&, Json::Value);
|
||||
auto update() -> void;
|
||||
operator Gtk::Widget &();
|
||||
private:
|
||||
void addWorkspace(Json::Value);
|
||||
std::string getIcon(std::string);
|
||||
bool handleScroll(GdkEventScroll*);
|
||||
int getPrevWorkspace();
|
||||
int getNextWorkspace();
|
||||
|
||||
Bar& bar_;
|
||||
Json::Value config_;
|
||||
waybar::util::SleeperThread thread_;
|
||||
Gtk::Box box_;
|
||||
util::JsonParser parser_;
|
||||
std::mutex mutex_;
|
||||
bool scrolling_;
|
||||
std::unordered_map<int, Gtk::Button> buttons_;
|
||||
Json::Value workspaces_;
|
||||
int ipcfd_;
|
||||
int ipc_eventfd_;
|
||||
};
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user