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 all 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
5 changes: 4 additions & 1 deletion man/waybar-image.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ Addressed by *custom/<name>*
*path*: ++
typeof: string ++
The path to the image.

*exec*: ++
typeof: string ++
The path to the script, which should return image path file
it will only execute if the path is not set
*size*: ++
typeof: integer ++
The width/height to render the image.
Expand Down
17 changes: 15 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 @@ -40,8 +39,22 @@ void waybar::modules::Image::refresh(int sig) {
}

auto waybar::modules::Image::update() -> void {
Glib::RefPtr<Gdk::Pixbuf> pixbuf;
util::command::res output_;

Glib::RefPtr<Gdk::Pixbuf> pixbuf;
if(config_["path"].isString())
{
path_ = config_["path"].asString();
}
else if(config_["exec"].isString())
{
output_ = util::command::exec(config_["exec"].asString());
kpanuragh marked this conversation as resolved.
Show resolved Hide resolved
path_ =output_.out;
}
else
{
path_="";
}
if (Glib::file_test(path_, Glib::FILE_TEST_EXISTS))
pixbuf = Gdk::Pixbuf::create_from_file(path_, size_, size_);
else
Expand Down