for image module get path from executable file

This commit is contained in:
Anuragh K P 2023-01-25 22:28:07 +05:30
parent 47cdd6f988
commit 1495b957f1
2 changed files with 11 additions and 2 deletions

View File

@ -27,6 +27,7 @@ class Image : public AModule {
std::string path_;
int size_;
int interval_;
util::command::res output_;
util::SleeperThread thread_;
};

View File

@ -9,7 +9,7 @@ waybar::modules::Image::Image(const std::string& name, const std::string& id,
dp.emit();
path_ = config["path"].asString();
//path_ = config["path"].asString();
size_ = config["size"].asInt();
interval_ = config_["interval"].asInt();
@ -41,7 +41,15 @@ void waybar::modules::Image::refresh(int sig) {
auto waybar::modules::Image::update() -> void {
Glib::RefPtr<Gdk::Pixbuf> pixbuf;
if(config_["path"].isString())
{
path_ = config_["path"].asString();
}
else
{
output_ = util::command::exec(config_["exec"].asString());
path_ =output_.out;
}
if (Glib::file_test(path_, Glib::FILE_TEST_EXISTS))
pixbuf = Gdk::Pixbuf::create_from_file(path_, size_, size_);
else