mirror of
				https://github.com/rad4day/Waybar.git
				synced 2025-11-04 01:32:42 +01:00 
			
		
		
		
	Merge pull request #1978 from kpanuragh/master
This commit is contained in:
		@@ -13,7 +13,10 @@ The *image* module displays an image from a path.
 | 
				
			|||||||
*path*: ++
 | 
					*path*: ++
 | 
				
			||||||
	typeof: string ++
 | 
						typeof: string ++
 | 
				
			||||||
	The path to the image.
 | 
						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*: ++
 | 
					*size*: ++
 | 
				
			||||||
	typeof: integer ++
 | 
						typeof: integer ++
 | 
				
			||||||
	The width/height to render the image.
 | 
						The width/height to render the image.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,7 +11,6 @@ waybar::modules::Image::Image(const std::string& id, const Json::Value& config)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  dp.emit();
 | 
					  dp.emit();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  path_ = config["path"].asString();
 | 
					 | 
				
			||||||
  size_ = config["size"].asInt();
 | 
					  size_ = config["size"].asInt();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  interval_ = config_["interval"].asInt();
 | 
					  interval_ = config_["interval"].asInt();
 | 
				
			||||||
@@ -42,8 +41,22 @@ void waybar::modules::Image::refresh(int sig) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
auto waybar::modules::Image::update() -> void {
 | 
					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());
 | 
				
			||||||
 | 
					    path_ =output_.out;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    path_="";
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
  if (Glib::file_test(path_, Glib::FILE_TEST_EXISTS))
 | 
					  if (Glib::file_test(path_, Glib::FILE_TEST_EXISTS))
 | 
				
			||||||
    pixbuf = Gdk::Pixbuf::create_from_file(path_, size_, size_);
 | 
					    pixbuf = Gdk::Pixbuf::create_from_file(path_, size_, size_);
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user