Compare commits

...

7 Commits
0.6.2 ... 0.6.3

Author SHA1 Message Date
d5a9eccb7b chore: v0.6.3 2019-05-12 20:02:53 +02:00
80e9ea746b fix(battery): use path for the / operator 2019-05-12 19:53:22 +02:00
84728f6fab Merge pull request #313 from apiote/master
remove empty and solo classes when they do not apply
2019-05-12 12:13:07 +02:00
10a17187a1 Merge pull request #309 from dlasky/btaudio
fix(btformat): fixes an issue where btformat was not detected
2019-05-12 12:12:16 +02:00
7cdde05568 remove empty and solo classes when they do not apply 2019-05-11 20:36:10 +02:00
Dan
e343cf4b00 fix(btformat): fixes an issue where btformat was not being correctly detected 2019-05-10 12:07:17 -04:00
e4756cf24e refactor: don't print an error when a watcher is already present 2019-05-10 14:56:28 +02:00
11 changed files with 35 additions and 26 deletions

View File

@ -7,11 +7,13 @@
#include "modules/sway/window.hpp" #include "modules/sway/window.hpp"
#include "modules/sway/workspaces.hpp" #include "modules/sway/workspaces.hpp"
#endif #endif
#ifndef NO_FILESYSTEM
#include "modules/battery.hpp" #include "modules/battery.hpp"
#endif
#include "modules/cpu.hpp" #include "modules/cpu.hpp"
#include "modules/idle_inhibitor.hpp" #include "modules/idle_inhibitor.hpp"
#include "modules/memory.hpp" #include "modules/memory.hpp"
#ifdef HAVE_DBUSMENU #if defined(HAVE_DBUSMENU) && !defined(NO_FILESYSTEM)
#include "modules/sni/tray.hpp" #include "modules/sni/tray.hpp"
#endif #endif
#ifdef HAVE_LIBNL #ifdef HAVE_LIBNL

View File

@ -33,6 +33,7 @@ class Pulseaudio : public ALabel {
bool muted_; bool muted_;
std::string port_name_; std::string port_name_;
std::string desc_; std::string desc_;
std::string monitor_;
bool scrolling_; bool scrolling_;
}; };

View File

@ -4,11 +4,6 @@
#include <fstream> #include <fstream>
#include "ALabel.hpp" #include "ALabel.hpp"
#include "util/sleeper_thread.hpp" #include "util/sleeper_thread.hpp"
#ifdef FILESYSTEM_EXPERIMENTAL
#include <experimental/filesystem>
#else
#include <filesystem>
#endif
namespace waybar::modules { namespace waybar::modules {

View File

@ -1,6 +1,6 @@
project( project(
'waybar', 'cpp', 'c', 'waybar', 'cpp', 'c',
version: '0.6.2', version: '0.6.3',
license: 'MIT', license: 'MIT',
default_options : [ default_options : [
'cpp_std=c++17', 'cpp_std=c++17',
@ -12,7 +12,7 @@ project(
cpp_args = [] cpp_args = []
cpp_link_args = [] cpp_link_args = []
if false # libc++ if get_option('libcxx')
cpp_args += ['-stdlib=libc++'] cpp_args += ['-stdlib=libc++']
cpp_link_args += ['-stdlib=libc++', '-lc++abi'] cpp_link_args += ['-stdlib=libc++', '-lc++abi']
@ -34,7 +34,12 @@ else
endif endif
if not compiler.has_header('filesystem') if not compiler.has_header('filesystem')
add_project_arguments('-DFILESYSTEM_EXPERIMENTAL', language: 'cpp') if compiler.has_header('experimental/filesystem')
add_project_arguments('-DFILESYSTEM_EXPERIMENTAL', language: 'cpp')
else
add_project_arguments('-DNO_FILESYSTEM', language: 'cpp')
warning('No filesystem header found, some modules may not work')
endif
endif endif
add_global_arguments(cpp_args, language : 'cpp') add_global_arguments(cpp_args, language : 'cpp')

View File

@ -1,3 +1,4 @@
option('libcxx', type : 'boolean', value : false, description : 'Build with Clang\'s libc++ instead of libstdc++ on Linux.')
option('libnl', type: 'feature', value: 'auto', description: 'Enable libnl support for network related features') option('libnl', type: 'feature', value: 'auto', description: 'Enable libnl support for network related features')
option('libudev', type: 'feature', value: 'auto', description: 'Enable libudev support for udev related features') option('libudev', type: 'feature', value: 'auto', description: 'Enable libudev support for udev related features')
option('pulseaudio', type: 'feature', value: 'auto', description: 'Enable support for pulseaudio') option('pulseaudio', type: 'feature', value: 'auto', description: 'Enable support for pulseaudio')

View File

@ -7,9 +7,11 @@ waybar::IModule* waybar::Factory::makeModule(const std::string& name) const {
auto hash_pos = name.find('#'); auto hash_pos = name.find('#');
auto ref = name.substr(0, hash_pos); auto ref = name.substr(0, hash_pos);
auto id = hash_pos != std::string::npos ? name.substr(hash_pos + 1) : ""; auto id = hash_pos != std::string::npos ? name.substr(hash_pos + 1) : "";
#ifndef NO_FILESYSTEM
if (ref == "battery") { if (ref == "battery") {
return new waybar::modules::Battery(id, config_[name]); return new waybar::modules::Battery(id, config_[name]);
} }
#endif
#ifdef HAVE_SWAY #ifdef HAVE_SWAY
if (ref == "sway/mode") { if (ref == "sway/mode") {
return new waybar::modules::sway::Mode(id, config_[name]); return new waybar::modules::sway::Mode(id, config_[name]);
@ -33,7 +35,7 @@ waybar::IModule* waybar::Factory::makeModule(const std::string& name) const {
if (ref == "clock") { if (ref == "clock") {
return new waybar::modules::Clock(id, config_[name]); return new waybar::modules::Clock(id, config_[name]);
} }
#ifdef HAVE_DBUSMENU #if defined(HAVE_DBUSMENU) && !defined(NO_FILESYSTEM)
if (ref == "tray") { if (ref == "tray") {
return new waybar::modules::SNI::Tray(id, bar_, config_[name]); return new waybar::modules::SNI::Tray(id, bar_, config_[name]);
} }

View File

@ -47,21 +47,21 @@ void waybar::modules::Battery::worker() {
void waybar::modules::Battery::getBatteries() { void waybar::modules::Battery::getBatteries() {
try { try {
for (auto const& node : fs::directory_iterator(data_dir_)) { for (auto& node : fs::directory_iterator(data_dir_)) {
if (!fs::is_directory(node)) { if (!fs::is_directory(node)) {
continue; continue;
} }
auto dir_name = node.path().filename(); auto dir_name = node.path().filename();
auto bat_defined = config_["bat"].isString(); auto bat_defined = config_["bat"].isString();
if (((bat_defined && dir_name == config_["bat"].asString()) || !bat_defined) && if (((bat_defined && dir_name == config_["bat"].asString()) || !bat_defined) &&
fs::exists(node / "capacity") && fs::exists(node / "uevent") && fs::exists(node.path() / "capacity") && fs::exists(node.path() / "uevent") &&
fs::exists(node / "status")) { fs::exists(node.path() / "status")) {
batteries_.push_back(node); batteries_.push_back(node.path());
} }
auto adap_defined = config_["adapter"].isString(); auto adap_defined = config_["adapter"].isString();
if (((adap_defined && dir_name == config_["adapter"].asString()) || !adap_defined) && if (((adap_defined && dir_name == config_["adapter"].asString()) || !adap_defined) &&
fs::exists(node / "online")) { fs::exists(node.path() / "online")) {
adapter_ = node; adapter_ = node.path();
} }
} }
} catch (fs::filesystem_error& e) { } catch (fs::filesystem_error& e) {

View File

@ -148,6 +148,7 @@ void waybar::modules::Pulseaudio::sinkInfoCb(pa_context * /*context*/, const pa_
pa->volume_ = std::round(volume * 100.0F); pa->volume_ = std::round(volume * 100.0F);
pa->muted_ = i->mute != 0; pa->muted_ = i->mute != 0;
pa->desc_ = i->description; pa->desc_ = i->description;
pa->monitor_ = i->monitor_source_name;
pa->port_name_ = i->active_port != nullptr ? i->active_port->name : "Unknown"; pa->port_name_ = i->active_port != nullptr ? i->active_port->name : "Unknown";
pa->dp.emit(); pa->dp.emit();
} }
@ -192,7 +193,7 @@ auto waybar::modules::Pulseaudio::update() -> void {
label_.get_style_context()->add_class("muted"); label_.get_style_context()->add_class("muted");
} else { } else {
label_.get_style_context()->remove_class("muted"); label_.get_style_context()->remove_class("muted");
if (port_name_.find("a2dp_sink") != std::string::npos) { if (monitor_.find("a2dp_sink") != std::string::npos) {
format = format =
config_["format-bluetooth"].isString() ? config_["format-bluetooth"].asString() : format; config_["format-bluetooth"].isString() ? config_["format-bluetooth"].asString() : format;
label_.get_style_context()->add_class("bluetooth"); label_.get_style_context()->add_class("bluetooth");

View File

@ -14,8 +14,8 @@ Watcher::Watcher()
watcher_(sn_watcher_skeleton_new()) {} watcher_(sn_watcher_skeleton_new()) {}
Watcher::~Watcher() { Watcher::~Watcher() {
if (bus_name_id_ > 0) { if (bus_name_id_ != 0) {
g_bus_unown_name(bus_name_id_); Gio::DBus::unown_name(bus_name_id_);
bus_name_id_ = 0; bus_name_id_ = 0;
} }
@ -36,7 +36,10 @@ void Watcher::busAcquired(const Glib::RefPtr<Gio::DBus::Connection>& conn, Glib:
g_dbus_interface_skeleton_export( g_dbus_interface_skeleton_export(
G_DBUS_INTERFACE_SKELETON(watcher_), conn->gobj(), "/StatusNotifierWatcher", &error); G_DBUS_INTERFACE_SKELETON(watcher_), conn->gobj(), "/StatusNotifierWatcher", &error);
if (error != nullptr) { if (error != nullptr) {
std::cerr << error->message << std::endl; // Don't print an error when a watcher is already present
if (error->code != 2) {
std::cerr << error->message << std::endl;
}
g_error_free(error); g_error_free(error);
return; return;
} }

View File

@ -31,8 +31,10 @@ void Window::onCmd(const struct Ipc::ipc_response& res) {
bar_.window.get_style_context()->remove_class(app_id_); bar_.window.get_style_context()->remove_class(app_id_);
} }
if (nb == 0) { if (nb == 0) {
bar_.window.get_style_context()->remove_class("solo");
bar_.window.get_style_context()->add_class("empty"); bar_.window.get_style_context()->add_class("empty");
} else if (nb == 1) { } else if (nb == 1) {
bar_.window.get_style_context()->remove_class("empty");
bar_.window.get_style_context()->add_class("solo"); bar_.window.get_style_context()->add_class("solo");
if (!app_id.empty()) { if (!app_id.empty()) {
bar_.window.get_style_context()->add_class(app_id); bar_.window.get_style_context()->add_class(app_id);
@ -99,4 +101,4 @@ void Window::getTree() {
} }
} }
} // namespace waybar::modules::sway } // namespace waybar::modules::sway

View File

@ -8,11 +8,8 @@ waybar::modules::Temperature::Temperature(const std::string& id, const Json::Val
auto zone = config_["thermal-zone"].isInt() ? config_["thermal-zone"].asInt() : 0; auto zone = config_["thermal-zone"].isInt() ? config_["thermal-zone"].asInt() : 0;
file_path_ = fmt::format("/sys/class/thermal/thermal_zone{}/temp", zone); file_path_ = fmt::format("/sys/class/thermal/thermal_zone{}/temp", zone);
} }
#ifdef FILESYSTEM_EXPERIMENTAL std::ifstream temp(file_path_);
if (!std::experimental::filesystem::exists(file_path_)) { if (!temp.is_open()) {
#else
if (!std::filesystem::exists(file_path_)) {
#endif
throw std::runtime_error("Can't open " + file_path_); throw std::runtime_error("Can't open " + file_path_);
} }
label_.set_name("temperature"); label_.set_name("temperature");