git.lucas.co / cce-display-manager
login greeter
git clone https://git.lucas.co/cce-display-manager.git

commit3d53e1227ad7871b1e0d41d1942b7b56d4153a83
parentc844e43095
authorLucas Galante <[email protected]>
date2026-05-28 20:35
feat: read system-wide settings from /etc/clear.toml and support scale override

 Cargo.toml  |  1 +
 clear.toml  |  2 ++
 src/main.rs | 22 +++++++++++++++++++++-
 3 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/Cargo.toml b/Cargo.toml
index 7d25ed2..be59b00 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -8,6 +8,7 @@ clear-ui = { path = "../clear-ui" }
 pam = "0.7.0"
 libc = "0.2"
 users = "0.8.1"
+toml = "0.8"
 smithay-client-toolkit = { version = "0.19.2", features = ["calloop"] }
 calloop = "0.13.0"
 calloop-wayland-source = "0.3.0"
diff --git a/clear.toml b/clear.toml
new file mode 100644
index 0000000..c73f1ba
--- /dev/null
+++ b/clear.toml
@@ -0,0 +1,2 @@
+# System-wide configuration for Clear programs
+scale = 2.0
diff --git a/src/main.rs b/src/main.rs
index 625da76..0cdc906 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1079,6 +1079,23 @@ delegate_keyboard!(AppState);
 delegate_registry!(AppState);
 delegate_output!(AppState);
 
+#[derive(serde::Deserialize, Debug, Default)]
+struct SystemConfig {
+    scale: Option<f64>,
+}
+
+fn load_system_config() -> SystemConfig {
+    let path = "/etc/clear.toml";
+    if std::path::Path::new(path).exists() {
+        if let Ok(content) = std::fs::read_to_string(path) {
+            if let Ok(config) = toml::from_str(&content) {
+                return config;
+            }
+        }
+    }
+    SystemConfig::default()
+}
+
 fn run_greeter() {
     let conn = Connection::connect_to_env().expect("Wayland connection");
     let (globals, mut event_queue) = registry_queue_init(&conn).expect("registry init");
@@ -1115,7 +1132,10 @@ fn run_greeter() {
 
     event_queue.roundtrip(&mut app).unwrap();
 
-    let scale = clear_ui::wayland::detect_scale_factor(&app.output_state);
+    let sys_config = load_system_config();
+    let scale = sys_config.scale.unwrap_or_else(|| {
+        clear_ui::wayland::detect_scale_factor(&app.output_state)
+    });
     let surface = app.compositor_state.create_surface(&qh);
     surface.set_buffer_scale(scale as i32);