fix: sync template sysroot, add script
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* settings.hpp
|
||||
* Montauk Toolkit helpers for loading desktop appearance settings
|
||||
* Copyright (c) 2026 Daniel Hammer
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <montauk/config.h>
|
||||
#include <montauk/syscall.h>
|
||||
#include "gui/gui.hpp"
|
||||
|
||||
namespace gui::mtk {
|
||||
|
||||
inline Color color_from_rgb_int(int64_t rgb, Color fallback = colors::ACCENT) {
|
||||
if (rgb < 0) return fallback;
|
||||
return Color::from_rgb((uint8_t)((rgb >> 16) & 0xFF),
|
||||
(uint8_t)((rgb >> 8) & 0xFF),
|
||||
(uint8_t)(rgb & 0xFF));
|
||||
}
|
||||
|
||||
inline Color load_system_accent(Color fallback = colors::ACCENT) {
|
||||
char user[64] = {};
|
||||
if (montauk::getuser(user, sizeof(user)) > 0 && user[0]) {
|
||||
auto doc = montauk::config::load_user(user, "desktop");
|
||||
int64_t accent = doc.get_int("appearance.accent_color", -1);
|
||||
if (accent >= 0) {
|
||||
Color color = color_from_rgb_int(accent, fallback);
|
||||
doc.destroy();
|
||||
return color;
|
||||
}
|
||||
doc.destroy();
|
||||
}
|
||||
|
||||
auto doc = montauk::config::load("desktop");
|
||||
int64_t accent = doc.get_int("appearance.accent_color", -1);
|
||||
Color color = color_from_rgb_int(accent, fallback);
|
||||
doc.destroy();
|
||||
return color;
|
||||
}
|
||||
|
||||
} // namespace gui::mtk
|
||||
Reference in New Issue
Block a user