mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
refactor(temperature): check if file exist on init
This commit is contained in:
parent
24684ca71b
commit
5870421f84
@ -4,6 +4,11 @@
|
||||
#include <fstream>
|
||||
#include "util/sleeper_thread.hpp"
|
||||
#include "ALabel.hpp"
|
||||
#ifdef FILESYSTEM_EXPERIMENTAL
|
||||
#include <experimental/filesystem>
|
||||
#else
|
||||
#include <filesystem>
|
||||
#endif
|
||||
|
||||
namespace waybar::modules {
|
||||
|
||||
|
@ -10,7 +10,13 @@ waybar::modules::Temperature::Temperature(const std::string& id, const Json::Val
|
||||
config_["thermal-zone"].isInt() ? config_["thermal-zone"].asInt() : 0;
|
||||
file_path_ = fmt::format("/sys/class/thermal/thermal_zone{}/temp", zone);
|
||||
}
|
||||
|
||||
#ifdef FILESYSTEM_EXPERIMENTAL
|
||||
if (!std::experimental::filesystem::exists(file_path_)) {
|
||||
#else
|
||||
if (!std::filesystem::exists(file_path_)) {
|
||||
#endif
|
||||
throw std::runtime_error("Can't open " + file_path_);
|
||||
}
|
||||
label_.set_name("temperature");
|
||||
if (!id.empty()) {
|
||||
label_.get_style_context()->add_class(id);
|
||||
|
Loading…
Reference in New Issue
Block a user