From 1495b957f18cb9b01e0915e901fcf98e59ca4a29 Mon Sep 17 00:00:00 2001 From: Anuragh K P Date: Wed, 25 Jan 2023 22:28:07 +0530 Subject: [PATCH 1/6] for image module get path from executable file --- include/modules/image.hpp | 1 + src/modules/image.cpp | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/modules/image.hpp b/include/modules/image.hpp index 06b61eef4..391922c21 100644 --- a/include/modules/image.hpp +++ b/include/modules/image.hpp @@ -27,6 +27,7 @@ class Image : public AModule { std::string path_; int size_; int interval_; + util::command::res output_; util::SleeperThread thread_; }; diff --git a/src/modules/image.cpp b/src/modules/image.cpp index eed19aea3..01f1375bd 100644 --- a/src/modules/image.cpp +++ b/src/modules/image.cpp @@ -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 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 From 9068b7548fad9d78085ceffb3c641879326fc04c Mon Sep 17 00:00:00 2001 From: Anuragh K P Date: Wed, 25 Jan 2023 22:29:33 +0530 Subject: [PATCH 2/6] for image module get path from executable file --- src/modules/image.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/modules/image.cpp b/src/modules/image.cpp index 01f1375bd..2388d6088 100644 --- a/src/modules/image.cpp +++ b/src/modules/image.cpp @@ -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(); From 012baadaca2a6dea6d4e9f2b23ff99920735a4d5 Mon Sep 17 00:00:00 2001 From: Anuragh K P Date: Sun, 29 Jan 2023 10:41:24 +0530 Subject: [PATCH 3/6] added exec condition check on image module --- src/modules/image.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules/image.cpp b/src/modules/image.cpp index 2388d6088..069f723fb 100644 --- a/src/modules/image.cpp +++ b/src/modules/image.cpp @@ -44,11 +44,15 @@ auto waybar::modules::Image::update() -> void { { path_ = config_["path"].asString(); } - else + else if(config_['exec'].isString()) { output_ = util::command::exec(config_["exec"].asString()); path_ =output_.out; } + else + { + path_=""; + } if (Glib::file_test(path_, Glib::FILE_TEST_EXISTS)) pixbuf = Gdk::Pixbuf::create_from_file(path_, size_, size_); else From 7554d7f07135fc0005124cc5cb78ae588d3d7bb5 Mon Sep 17 00:00:00 2001 From: Anuragh K P Date: Sun, 29 Jan 2023 19:13:01 +0530 Subject: [PATCH 4/6] Fixing build issue in image module --- src/modules/image.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/image.cpp b/src/modules/image.cpp index 069f723fb..d2eb77987 100644 --- a/src/modules/image.cpp +++ b/src/modules/image.cpp @@ -44,7 +44,7 @@ auto waybar::modules::Image::update() -> void { { path_ = config_["path"].asString(); } - else if(config_['exec'].isString()) + else if(config_["exec"].isString()) { output_ = util::command::exec(config_["exec"].asString()); path_ =output_.out; From 7b3a6fbaa70f44963cb09008716b46deef7cf57d Mon Sep 17 00:00:00 2001 From: Anuragh K P Date: Mon, 30 Jan 2023 18:35:06 +0530 Subject: [PATCH 5/6] created local variable for _output --- include/modules/image.hpp | 1 - src/modules/image.cpp | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/modules/image.hpp b/include/modules/image.hpp index 391922c21..06b61eef4 100644 --- a/include/modules/image.hpp +++ b/include/modules/image.hpp @@ -27,7 +27,6 @@ class Image : public AModule { std::string path_; int size_; int interval_; - util::command::res output_; util::SleeperThread thread_; }; diff --git a/src/modules/image.cpp b/src/modules/image.cpp index d2eb77987..b153523ff 100644 --- a/src/modules/image.cpp +++ b/src/modules/image.cpp @@ -39,6 +39,8 @@ void waybar::modules::Image::refresh(int sig) { } auto waybar::modules::Image::update() -> void { + util::command::res output_; + Glib::RefPtr pixbuf; if(config_["path"].isString()) { From 74a8464c09cf84375954213b49d32875b907bb12 Mon Sep 17 00:00:00 2001 From: Anuragh K P Date: Wed, 1 Feb 2023 21:22:10 +0530 Subject: [PATCH 6/6] updating man page --- man/waybar-image.5.scd | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/man/waybar-image.5.scd b/man/waybar-image.5.scd index df7086f05..ff0e34c34 100644 --- a/man/waybar-image.5.scd +++ b/man/waybar-image.5.scd @@ -15,7 +15,10 @@ Addressed by *custom/* *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.