diff --git a/README.md b/README.md index e271cd2..a65b6ed 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ My personal blazingly fast and efficient status bar + widgets, in case anyone fi - gtk-layer-shell - PulseAudio server (PipeWire works too!) - pamixer +- libsass - meson, gcc/clang, ninja ## Building and installation (Manually) diff --git a/meson.build b/meson.build index 11dd2f2..77c846c 100644 --- a/meson.build +++ b/meson.build @@ -28,6 +28,9 @@ gtk_layer_shell = dependency('gtk-layer-shell-0') pulse = dependency('libpulse') +sass = dependency('libsass') + + headers = [ 'src/Common.h', 'src/Log.h', @@ -58,7 +61,7 @@ sources = [ 'src/SNI.cpp', ] -dependencies = [gtk, gtk_layer_shell, pulse, wayland_client ] +dependencies = [gtk, gtk_layer_shell, pulse, wayland_client, sass] if get_option('WithHyprland') add_global_arguments('-DWITH_HYPRLAND', language: 'cpp') diff --git a/src/CSS.cpp b/src/CSS.cpp index b723cc1..9a51a56 100644 --- a/src/CSS.cpp +++ b/src/CSS.cpp @@ -5,6 +5,8 @@ #include #include +#include + namespace CSS { static GtkCssProvider* sProvider; @@ -58,21 +60,49 @@ namespace CSS GError* err = nullptr; for (auto& dir : locations) { - std::string file = dir + "/style.css"; + std::string file = dir + "/style.scss"; + bool scss_suceeded = false; - if (!std::ifstream(file).is_open()) + if (std::ifstream(file).is_open()) { - LOG("Info: No CSS found in " << dir); - continue; + Sass_File_Context* ctx = sass_make_file_context(file.c_str()); + Sass_Context* ctxout = sass_file_context_get_context(ctx); + sass_compile_file_context(ctx); + if(sass_context_get_error_status(ctxout)) + { + LOG("Error Compiling SCSS: " << sass_context_get_error_message(ctxout)); + } + else + { + std::string data = sass_context_get_output_string(ctxout); + gtk_css_provider_load_from_data(sProvider, data.c_str(), data.length(), &err); + scss_suceeded = true; + } + sass_delete_file_context(ctx); } - gtk_css_provider_load_from_path(sProvider, file.c_str(), &err); + if (!scss_suceeded) + { + LOG("Info: couldn't load SCSS from " << dir); + file = dir + "/style.css"; + + if (!std::ifstream(file).is_open()) + { + LOG("Info: No CSS found in " << dir); + continue; + } + + gtk_css_provider_load_from_path(sProvider, file.c_str(), &err); + + } + if (!err) { LOG("CSS found and loaded successfully!"); return; } + LOG("Warning: Failed loading config for " << dir << ", trying next one!"); // Log any errors LOG(err->message);