mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Merge branch 'master' into taskbar/remove-trim
This commit is contained in:
@ -10,7 +10,7 @@ namespace waybar {
|
||||
class ALabel : public AModule {
|
||||
public:
|
||||
ALabel(const Json::Value &, const std::string &, const std::string &, const std::string &format,
|
||||
uint16_t interval = 0, bool ellipsize = false);
|
||||
uint16_t interval = 0, bool ellipsize = false, bool enable_click = false, bool enable_scroll = false);
|
||||
virtual ~ALabel() = default;
|
||||
virtual auto update() -> void;
|
||||
virtual std::string getIcon(uint16_t, const std::string &alt = "", uint16_t max = 0);
|
||||
|
@ -53,13 +53,18 @@ class Bar {
|
||||
static void layerSurfaceHandleClosed(void *, struct zwlr_layer_surface_v1 *);
|
||||
|
||||
#ifdef HAVE_GTK_LAYER_SHELL
|
||||
/* gtk-layer-shell code */
|
||||
void initGtkLayerShell();
|
||||
void onConfigureGLS(GdkEventConfigure *ev);
|
||||
void onMapGLS(GdkEventAny *ev);
|
||||
#endif
|
||||
/* fallback layer-surface code */
|
||||
void onConfigure(GdkEventConfigure *ev);
|
||||
void onRealize();
|
||||
void onMap(GdkEventAny *ev);
|
||||
void setExclusiveZone(uint32_t width, uint32_t height);
|
||||
void setSurfaceSize(uint32_t width, uint32_t height);
|
||||
/* common code */
|
||||
void setExclusiveZone(uint32_t width, uint32_t height);
|
||||
auto setupWidgets() -> void;
|
||||
void getModules(const Factory &, const std::string &);
|
||||
void setupAltFormatKeyForModule(const std::string &module_name);
|
||||
|
@ -39,11 +39,16 @@
|
||||
#ifdef HAVE_LIBMPDCLIENT
|
||||
#include "modules/mpd.hpp"
|
||||
#endif
|
||||
#ifdef HAVE_LIBSNDIO
|
||||
#include "modules/sndio.hpp"
|
||||
#endif
|
||||
#include "bar.hpp"
|
||||
#include "modules/custom.hpp"
|
||||
#include "modules/temperature.hpp"
|
||||
#if defined(__linux__)
|
||||
#include "modules/bluetooth.hpp"
|
||||
# ifdef WANT_RFKILL
|
||||
# include "modules/bluetooth.hpp"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
namespace waybar {
|
||||
|
@ -28,9 +28,12 @@ class Clock : public ALabel {
|
||||
std::locale locale_;
|
||||
const date::time_zone* time_zone_;
|
||||
bool fixed_time_zone_;
|
||||
int time_zone_idx_;
|
||||
date::year_month_day cached_calendar_ymd_;
|
||||
std::string cached_calendar_text_;
|
||||
|
||||
bool handleScroll(GdkEventScroll* e);
|
||||
|
||||
auto calendar_text(const waybar_time& wtime) -> std::string;
|
||||
auto weekdays_header(const date::weekday& first_dow, std::ostream& os) -> void;
|
||||
auto first_day_of_week() -> date::weekday;
|
||||
|
@ -22,6 +22,7 @@ class Custom : public ALabel {
|
||||
void continuousWorker();
|
||||
void parseOutputRaw();
|
||||
void parseOutputJson();
|
||||
void handleEvent();
|
||||
bool handleScroll(GdkEventScroll* e);
|
||||
bool handleToggle(GdkEventButton* const& e);
|
||||
|
||||
|
@ -11,7 +11,9 @@
|
||||
#include <sys/epoll.h>
|
||||
#include "ALabel.hpp"
|
||||
#include "util/sleeper_thread.hpp"
|
||||
#ifdef WANT_RFKILL
|
||||
#include "util/rfkill.hpp"
|
||||
#endif
|
||||
|
||||
namespace waybar::modules {
|
||||
|
||||
@ -52,6 +54,8 @@ class Network : public ALabel {
|
||||
struct sockaddr_nl nladdr_ = {0};
|
||||
struct nl_sock* sock_ = nullptr;
|
||||
struct nl_sock* ev_sock_ = nullptr;
|
||||
int efd_;
|
||||
int ev_fd_;
|
||||
int nl80211_id_;
|
||||
std::mutex mutex_;
|
||||
|
||||
@ -70,9 +74,11 @@ class Network : public ALabel {
|
||||
|
||||
util::SleeperThread thread_;
|
||||
util::SleeperThread thread_timer_;
|
||||
#ifdef WANT_RFKILL
|
||||
util::SleeperThread thread_rfkill_;
|
||||
|
||||
util::Rfkill rfkill_;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace waybar::modules
|
||||
|
30
include/modules/sndio.hpp
Normal file
30
include/modules/sndio.hpp
Normal file
@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <sndio.h>
|
||||
#include <vector>
|
||||
#include "ALabel.hpp"
|
||||
#include "util/sleeper_thread.hpp"
|
||||
|
||||
namespace waybar::modules {
|
||||
|
||||
class Sndio : public ALabel {
|
||||
public:
|
||||
Sndio(const std::string&, const Json::Value&);
|
||||
~Sndio();
|
||||
auto update() -> void;
|
||||
auto set_desc(struct sioctl_desc *, unsigned int) -> void;
|
||||
auto put_val(unsigned int, unsigned int) -> void;
|
||||
bool handleScroll(GdkEventScroll *);
|
||||
bool handleToggle(GdkEventButton* const&);
|
||||
|
||||
private:
|
||||
auto connect_to_sndio() -> void;
|
||||
util::SleeperThread thread_;
|
||||
struct sioctl_hdl *hdl_;
|
||||
std::vector<struct pollfd> pfds_;
|
||||
unsigned int addr_;
|
||||
unsigned int volume_, old_volume_, maxval_;
|
||||
bool muted_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules
|
@ -7,6 +7,9 @@
|
||||
|
||||
#include <array>
|
||||
|
||||
extern std::mutex reap_mtx;
|
||||
extern std::list<pid_t> reap;
|
||||
|
||||
namespace waybar::util::command {
|
||||
|
||||
struct res {
|
||||
@ -32,10 +35,11 @@ inline std::string read(FILE* fp) {
|
||||
|
||||
inline int close(FILE* fp, pid_t pid) {
|
||||
int stat = -1;
|
||||
pid_t ret;
|
||||
|
||||
fclose(fp);
|
||||
do {
|
||||
waitpid(pid, &stat, WCONTINUED | WUNTRACED);
|
||||
ret = waitpid(pid, &stat, WCONTINUED | WUNTRACED);
|
||||
|
||||
if (WIFEXITED(stat)) {
|
||||
spdlog::debug("Cmd exited with code {}", WEXITSTATUS(stat));
|
||||
@ -45,6 +49,8 @@ inline int close(FILE* fp, pid_t pid) {
|
||||
spdlog::debug("Cmd stopped by {}", WSTOPSIG(stat));
|
||||
} else if (WIFCONTINUED(stat)) {
|
||||
spdlog::debug("Cmd continued");
|
||||
} else if (ret == -1) {
|
||||
spdlog::debug("waitpid failed: {}", strerror(errno));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@ -65,6 +71,12 @@ inline FILE* open(const std::string& cmd, int& pid) {
|
||||
}
|
||||
|
||||
if (!child_pid) {
|
||||
int err;
|
||||
sigset_t mask;
|
||||
sigfillset(&mask);
|
||||
// Reset sigmask
|
||||
err = pthread_sigmask(SIG_UNBLOCK, &mask, nullptr);
|
||||
if (err != 0) spdlog::error("pthread_sigmask in open failed: {}", strerror(err));
|
||||
::close(fd[0]);
|
||||
dup2(fd[1], 1);
|
||||
setpgid(child_pid, child_pid);
|
||||
@ -97,7 +109,7 @@ inline struct res execNoRead(const std::string& cmd) {
|
||||
inline int32_t forkExec(const std::string& cmd) {
|
||||
if (cmd == "") return -1;
|
||||
|
||||
int32_t pid = fork();
|
||||
pid_t pid = fork();
|
||||
|
||||
if (pid < 0) {
|
||||
spdlog::error("Unable to exec cmd {}, error {}", cmd.c_str(), strerror(errno));
|
||||
@ -106,12 +118,20 @@ inline int32_t forkExec(const std::string& cmd) {
|
||||
|
||||
// Child executes the command
|
||||
if (!pid) {
|
||||
int err;
|
||||
sigset_t mask;
|
||||
sigfillset(&mask);
|
||||
// Reset sigmask
|
||||
err = pthread_sigmask(SIG_UNBLOCK, &mask, nullptr);
|
||||
if (err != 0) spdlog::error("pthread_sigmask in forkExec failed: {}", strerror(err));
|
||||
setpgid(pid, pid);
|
||||
signal(SIGCHLD, SIG_DFL);
|
||||
execl("/bin/sh", "sh", "-c", cmd.c_str(), (char*)0);
|
||||
exit(0);
|
||||
} else {
|
||||
signal(SIGCHLD, SIG_IGN);
|
||||
reap_mtx.lock();
|
||||
reap.push_back(pid);
|
||||
reap_mtx.unlock();
|
||||
spdlog::debug("Added child to reap list: {}", pid);
|
||||
}
|
||||
|
||||
return pid;
|
||||
|
@ -23,7 +23,7 @@ namespace fmt {
|
||||
constexpr auto parse(ParseContext& ctx) -> decltype (ctx.begin()) {
|
||||
auto it = ctx.begin(), end = ctx.end();
|
||||
if (it != end && *it == ':') ++it;
|
||||
if (*it == '>' || *it == '<' || *it == '=') {
|
||||
if (it && (*it == '>' || *it == '<' || *it == '=')) {
|
||||
spec = *it;
|
||||
++it;
|
||||
}
|
||||
|
Reference in New Issue
Block a user