MCPcopy Create free account
hub / github.com/Alexays/Waybar / getStyle

Method getStyle

src/client.cpp:152–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150}
151
152const std::string waybar::Client::getStyle(const std::string& style,
153 std::optional<Appearance> appearance = std::nullopt) {
154 auto gtk_settings = Gtk::Settings::get_default();
155 std::optional<std::string> css_file;
156
157 if (style.empty()) {
158 std::vector<std::string> search_files;
159 switch (appearance.value_or(portal->getAppearance())) {
160 case waybar::Appearance::LIGHT:
161 search_files.emplace_back("style-light.css");
162 gtk_settings->property_gtk_application_prefer_dark_theme() = false;
163 break;
164 case waybar::Appearance::DARK:
165 search_files.emplace_back("style-dark.css");
166 gtk_settings->property_gtk_application_prefer_dark_theme() = true;
167 break;
168 case waybar::Appearance::UNKNOWN:
169 break;
170 }
171 search_files.emplace_back("style.css");
172 css_file = Config::findConfigPath(search_files);
173 } else {
174 css_file = style;
175 }
176
177 if (!css_file) {
178 throw std::runtime_error("Missing required resource files");
179 }
180
181 spdlog::info("Using CSS file {}", css_file.value());
182 return css_file.value();
183};
184
185auto waybar::Client::setupCss(const std::string& css_file) -> void {
186 auto screen = Gdk::Screen::get_default();

Callers

nothing calls this directly

Calls 3

emptyMethod · 0.80
getAppearanceMethod · 0.80
valueMethod · 0.80

Tested by

no test coverage detected