Skip to content

Commit

Permalink
Merge branch 'Alexays:master' into sway-hide-updated
Browse files Browse the repository at this point in the history
  • Loading branch information
emirror-de authored Oct 21, 2021
2 parents 09da1f0 + 6eb9606 commit 8549996
Show file tree
Hide file tree
Showing 40 changed files with 609 additions and 245 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/freebsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ jobs:
export CPPFLAGS=-isystem/usr/local/include LDFLAGS=-L/usr/local/lib # sndio
sed -i '' 's/quarterly/latest/' /etc/pkg/FreeBSD.conf
pkg install -y git # subprojects/date
pkg install -y evdev-proto gtk-layer-shell gtkmm30 jsoncpp libdbusmenu \
libevdev libfmt libmpdclient libudev-devd meson pkgconf pulseaudio \
scdoc sndio spdlog
pkg install -y catch evdev-proto gtk-layer-shell gtkmm30 jsoncpp \
libdbusmenu libevdev libfmt libmpdclient libudev-devd meson \
pkgconf pulseaudio scdoc sndio spdlog
run: |
meson build -Dman-pages=enabled
ninja -C build
meson test -C build --no-rebuild --print-errorlogs --suite waybar
2 changes: 2 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ jobs:
run: meson -Dman-pages=enabled build
- name: build
run: ninja -C build
- name: test
run: meson test -C build --no-rebuild --print-errorlogs --suite waybar
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@ install: build
run: build
./build/waybar

debug-run: build-debug
./build/waybar --log-level debug

clean:
rm -rf build
15 changes: 4 additions & 11 deletions include/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
#include <fmt/format.h>
#include <gdk/gdk.h>
#include <gdk/gdkwayland.h>
#include <unistd.h>
#include <wayland-client.h>
#include <wordexp.h>

#include "bar.hpp"
#include "config.hpp"

struct zwlr_layer_shell_v1;
struct zwp_idle_inhibitor_v1;
Expand All @@ -29,18 +28,13 @@ class Client {
struct zxdg_output_manager_v1 * xdg_output_manager = nullptr;
struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager = nullptr;
std::vector<std::unique_ptr<Bar>> bars;
Config config;

private:
Client() = default;
std::tuple<const std::string, const std::string> getConfigs(const std::string &config,
const std::string &style) const;
void bindInterfaces();
const std::string getValidPath(const std::vector<std::string> &paths) const;
const std::string getStyle(const std::string &style);
void bindInterfaces();
void handleOutput(struct waybar_output &output);
bool isValidOutput(const Json::Value &config, struct waybar_output &output);
auto setupConfig(const std::string &config_file, int depth) -> void;
auto resolveConfigIncludes(Json::Value &config, int depth) -> void;
auto mergeConfig(Json::Value &a_config_, Json::Value &b_config_) -> void;
auto setupCss(const std::string &css_file) -> void;
struct waybar_output & getOutput(void *);
std::vector<Json::Value> getOutputConfigs(struct waybar_output &output);
Expand All @@ -55,7 +49,6 @@ class Client {
void handleMonitorRemoved(Glib::RefPtr<Gdk::Monitor> monitor);
void handleDeferredMonitorRemoval(Glib::RefPtr<Gdk::Monitor> monitor);

Json::Value config_;
Glib::RefPtr<Gtk::StyleContext> style_context_;
Glib::RefPtr<Gtk::CssProvider> css_provider_;
std::list<struct waybar_output> outputs_;
Expand Down
39 changes: 39 additions & 0 deletions include/config.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#pragma once

#include <json/json.h>

#include <optional>
#include <string>

#ifndef SYSCONFDIR
#define SYSCONFDIR "/etc"
#endif

namespace waybar {

class Config {
public:
static const std::vector<std::string> CONFIG_DIRS;

/* Try to find any of provided names in the supported set of config directories */
static std::optional<std::string> findConfigPath(
const std::vector<std::string> &names, const std::vector<std::string> &dirs = CONFIG_DIRS);

Config() = default;

void load(const std::string &config);

Json::Value &getConfig() { return config_; }

std::vector<Json::Value> getOutputConfigs(const std::string &name, const std::string &identifier);

private:
void setupConfig(Json::Value &dst, const std::string &config_file, int depth);
void resolveConfigIncludes(Json::Value &config, int depth);
void mergeConfig(Json::Value &a_config_, Json::Value &b_config_);

std::string config_file_;

Json::Value config_;
};
} // namespace waybar
1 change: 1 addition & 0 deletions include/modules/clock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Clock : public ALabel {
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;
bool setTimeZone(Json::Value zone_name);
};

} // namespace waybar::modules
10 changes: 5 additions & 5 deletions include/modules/cpu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ class Cpu : public ALabel {
auto update() -> void;

private:
double getCpuLoad();
std::tuple<uint16_t, std::string> getCpuUsage();
std::tuple<float, float, float> getCpuFrequency();
std::vector<std::tuple<size_t, size_t>> parseCpuinfo();
std::vector<float> parseCpuFrequencies();
double getCpuLoad();
std::tuple<std::vector<uint16_t>, std::string> getCpuUsage();
std::tuple<float, float, float> getCpuFrequency();
std::vector<std::tuple<size_t, size_t>> parseCpuinfo();
std::vector<float> parseCpuFrequencies();

std::vector<std::tuple<size_t, size_t>> prev_times_;

Expand Down
1 change: 1 addition & 0 deletions include/modules/network.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class Network : public ALabel {
bool carrier_;
std::string ifname_;
std::string ipaddr_;
std::string gwaddr_;
std::string netmask_;
int cidr_;
int32_t signal_strength_dbm_;
Expand Down
3 changes: 2 additions & 1 deletion man/waybar-clock.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ The *clock* module displays the current date and time.
*timezone*: ++
typeof: string ++
default: inferred local timezone ++
The timezone to display the time in, e.g. America/New_York.
The timezone to display the time in, e.g. America/New_York. ++
This field will be ignored if *timezones* field is set and have at least one value.

*timezones*: ++
typeof: list of strings ++
Expand Down
22 changes: 20 additions & 2 deletions man/waybar-cpu.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,23 @@ The *cpu* module displays the current cpu utilization.

*{load}*: Current cpu load.

*{usage}*: Current cpu usage.
*{usage}*: Current overall cpu usage.

*{usage*{n}*}*: Current cpu core n usage. Cores are numbered from zero, so first core will be {usage0} and 4th will be {usage3}.

*{avg_frequency}*: Current cpu average frequency (based on all cores) in GHz.

*{max_frequency}*: Current cpu max frequency (based on the core with the highest frequency) in GHz.

*{min_frequency}*: Current cpu min frequency (based on the core with the lowest frequency) in GHz.

# EXAMPLE
*{icon}*: Icon for overall cpu usage.

*{icon*{n}*}*: Icon for cpu core n usage. Use like {icon0}.

# EXAMPLES

Basic configuration:

```
"cpu": {
Expand All @@ -100,6 +108,16 @@ The *cpu* module displays the current cpu utilization.
}
```

Cpu usage per core rendered as icons:

```
"cpu": {
"interval": 1,
"format": "{icon0}{icon1}{icon2}{icon3} {usage:>2}% ",
"format-icons": ["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"],
},
```

# STYLE

- *#cpu*
2 changes: 2 additions & 0 deletions man/waybar-network.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ Addressed by *network*

*{ipaddr}*: The first IP of the interface.

*{gwaddr}*: The default gateway for the interface

*{netmask}*: The subnetmask corresponding to the IP.

*{cidr}*: The subnetmask corresponding to the IP in CIDR notation.
Expand Down
5 changes: 3 additions & 2 deletions man/waybar.5.scd.in
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ Also a minimal example configuration can be found on the at the bottom of this m

*include* ++
typeof: string|array ++
Paths to additional configuration files. In case of duplicate options, the including file's value takes precedence. Make sure to avoid circular imports.
For a multi-bar config, specify at least an empty object for each bar also in every file being included.
Paths to additional configuration files.
Each file can contain a single object with any of the bar configuration options. In case of duplicate options, the first defined value takes precedence, i.e. including file -> first included file -> etc. Nested includes are permitted, but make sure to avoid circular imports.
For a multi-bar config, the include directive affects only current bar configuration object.

# MODULE FORMAT

Expand Down
10 changes: 10 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ src_files = files(
'src/main.cpp',
'src/bar.cpp',
'src/client.cpp',
'src/config.cpp',
'src/util/ustring_clen.cpp'
)

Expand Down Expand Up @@ -360,6 +361,15 @@ if scdoc.found()
endforeach
endif

catch2 = dependency(
'catch2',
fallback: ['catch2', 'catch2_dep'],
required: get_option('tests'),
)
if catch2.found()
subdir('test')
endif

clangtidy = find_program('clang-tidy', required: false)

if clangtidy.found()
Expand Down
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ option('mpd', type: 'feature', value: 'auto', description: 'Enable support for t
option('gtk-layer-shell', type: 'feature', value: 'auto', description: 'Use gtk-layer-shell library for popups support')
option('rfkill', type: 'feature', value: 'auto', description: 'Enable support for RFKILL')
option('sndio', type: 'feature', value: 'auto', description: 'Enable support for sndio')
option('tests', type: 'feature', value: 'auto', description: 'Enable tests')
3 changes: 2 additions & 1 deletion resources/config
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@
"network": {
// "interface": "wlp2*", // (Optional) To force the use of this interface
"format-wifi": "{essid} ({signalStrength}%) ",
"format-ethernet": "{ifname}: {ipaddr}/{cidr} ",
"format-ethernet": "{ipaddr}/{cidr} ",
"tooltip-format": "{ifname} via {gwaddr} ",
"format-linked": "{ifname} (No IP) ",
"format-disconnected": "Disconnected ⚠",
"format-alt": "{ifname}: {ipaddr}/{cidr}"
Expand Down
2 changes: 1 addition & 1 deletion resources/custom_modules/mediaplayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def signal_handler(sig, frame):
def parse_arguments():
parser = argparse.ArgumentParser()

# Increase verbosity with every occurence of -v
# Increase verbosity with every occurrence of -v
parser.add_argument('-v', '--verbose', action='count', default=0)

# Define for which player we're listening
Expand Down
Loading

0 comments on commit 8549996

Please sign in to comment.