| 150 | } |
| 151 | |
| 152 | const 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 | |
| 185 | auto waybar::Client::setupCss(const std::string& css_file) -> void { |
| 186 | auto screen = Gdk::Screen::get_default(); |
nothing calls this directly
no test coverage detected