perf(image): set image from path only once
This commit is contained in:
+11
-9
@@ -28,6 +28,13 @@ waybar::modules::Image::Image(const std::string& id, const Json::Value& config)
|
|||||||
size_ = 16;
|
size_ = 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config_["path"].isString()) {
|
||||||
|
auto result = Config::tryExpandPath(config_["path"].asString(), "");
|
||||||
|
path_ = result.empty() ? "" : result.front();
|
||||||
|
} else {
|
||||||
|
path_.clear();
|
||||||
|
}
|
||||||
|
|
||||||
if (interval_.count() == 0) {
|
if (interval_.count() == 0) {
|
||||||
interval_ = std::chrono::milliseconds::max();
|
interval_ = std::chrono::milliseconds::max();
|
||||||
}
|
}
|
||||||
@@ -49,19 +56,14 @@ void waybar::modules::Image::refresh(int sig) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto waybar::modules::Image::update() -> void {
|
auto waybar::modules::Image::update() -> void {
|
||||||
if (config_["path"].isString()) {
|
if (config_["exec"].isString()) {
|
||||||
path_ = config_["path"].asString();
|
|
||||||
} else if (config_["exec"].isString()) {
|
|
||||||
output_ = util::command::exec(config_["exec"].asString(), "");
|
output_ = util::command::exec(config_["exec"].asString(), "");
|
||||||
parseOutputRaw();
|
parseOutputRaw();
|
||||||
} else {
|
// expand path if "~" or "$HOME" is present in original path
|
||||||
path_ = "";
|
auto result = Config::tryExpandPath(path_, "");
|
||||||
|
path_ = result.empty() ? "" : result.front();
|
||||||
}
|
}
|
||||||
|
|
||||||
// expand path if "~" or "$HOME" is present in original path
|
|
||||||
auto result = Config::tryExpandPath(path_, "");
|
|
||||||
path_ = result.empty() ? "" : result.front();
|
|
||||||
|
|
||||||
if (Glib::file_test(path_, Glib::FILE_TEST_EXISTS)) {
|
if (Glib::file_test(path_, Glib::FILE_TEST_EXISTS)) {
|
||||||
Glib::RefPtr<Gdk::Pixbuf> pixbuf;
|
Glib::RefPtr<Gdk::Pixbuf> pixbuf;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user