Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set Image path from executable file (Image Module) #1978

Merged
merged 6 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/modules/image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Image : public AModule {
std::string path_;
int size_;
int interval_;
util::command::res output_;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove that variable


util::SleeperThread thread_;
};
Expand Down
11 changes: 9 additions & 2 deletions src/modules/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ waybar::modules::Image::Image(const std::string& name, const std::string& id,

dp.emit();

path_ = config["path"].asString();
size_ = config["size"].asInt();

interval_ = config_["interval"].asInt();
Expand Down Expand Up @@ -41,7 +40,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
kpanuragh marked this conversation as resolved.
Show resolved Hide resolved
{
output_ = util::command::exec(config_["exec"].asString());
kpanuragh marked this conversation as resolved.
Show resolved Hide resolved
path_ =output_.out;
}
if (Glib::file_test(path_, Glib::FILE_TEST_EXISTS))
pixbuf = Gdk::Pixbuf::create_from_file(path_, size_, size_);
else
Expand Down