gardesk/gar / 72af8c4

Browse files

add configurable picom backend (glx/xrender) to avoid Xid 79 GPU crashes

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
72af8c406dbd6cb900cc9179cc7178ee440554ed
Parents
592b9e2
Tree
d1c2abb

2 changed files

StatusFile+-
M gar/src/config/lua.rs 13 0
M gar/src/config/mod.rs 19 2
gar/src/config/lua.rsmodified
@@ -406,6 +406,19 @@ impl LuaConfig {
406406
                         }
407407
                     }
408408
                 }
409
+                // Picom backend: "glx" or "xrender"
410
+                "compositor_backend" | "picom_backend" => {
411
+                    if let Value::String(s) = value {
412
+                        if let Ok(str_val) = s.to_str() {
413
+                            let backend = str_val.to_lowercase();
414
+                            if backend == "glx" || backend == "xrender" {
415
+                                state.config.picom_backend = backend;
416
+                            } else {
417
+                                tracing::warn!("Unknown compositor backend '{}', using 'glx'", str_val);
418
+                            }
419
+                        }
420
+                    }
421
+                }
409422
                 // Compositor visual settings (picom)
410423
                 "corner_radius" => {
411424
                     if let Value::Integer(v) = value {
gar/src/config/mod.rsmodified
@@ -46,6 +46,8 @@ pub struct Config {
4646
     pub screen_timeout_seconds: u32,
4747
     // Compositor selection: "picom" (default), "garchomp", or "none"
4848
     pub compositor: String,
49
+    // Picom backend: "glx" (GPU) or "xrender" (CPU, safer on NVIDIA)
50
+    pub picom_backend: String,
4951
     // Compositor visual settings (picom)
5052
     // These are stored for reference and potential dynamic picom config generation
5153
     pub corner_radius: u32,
@@ -82,6 +84,18 @@ impl Config {
8284
     /// Generate picom.conf content from current config settings.
8385
     pub fn generate_picom_config(&self) -> String {
8486
         let blur_section = if self.blur_enabled {
87
+            // dual_kawase requires GLX backend; fall back to kernel blur on xrender
88
+            let (blur_method, blur_strength) = if self.picom_backend == "xrender"
89
+                && self.blur_method == "dual_kawase"
90
+            {
91
+                tracing::info!(
92
+                    "Switching blur from dual_kawase to kernel (xrender backend doesn't support dual_kawase)"
93
+                );
94
+                ("kernel".to_string(), self.blur_strength)
95
+            } else {
96
+                (self.blur_method.clone(), self.blur_strength)
97
+            };
98
+
8599
             format!(
86100
                 r#"# Blur
87101
 blur-method = "{}";
@@ -98,7 +112,7 @@ blur-background-exclude = [
98112
     "window_type = 'popup_menu'",
99113
     "_NET_WM_BYPASS_COMPOSITOR = 1"
100114
 ];"#,
101
-                self.blur_method, self.blur_strength
115
+                blur_method, blur_strength
102116
             )
103117
         } else {
104118
             "# Blur disabled".to_string()
@@ -259,7 +273,7 @@ animations = ({{
259273
 # Edit ~/.config/gar/init.lua instead and reload with Mod+Shift+R
260274
 
261275
 # Backend Configuration
262
-backend = "glx";
276
+backend = "{}";
263277
 vsync = true;
264278
 use-ewmh-active-win = true;
265279
 
@@ -317,6 +331,7 @@ wintypes:
317331
     }};
318332
 }};
319333
 "#,
334
+            self.picom_backend,
320335
             self.corner_radius,
321336
             blur_section,
322337
             shadow_section,
@@ -545,6 +560,8 @@ impl Default for Config {
545560
             screen_timeout_seconds: 600,
546561
             // Compositor selection: "picom" (default), "garchomp", or "none"
547562
             compositor: "picom".to_string(),
563
+            // Picom backend: "glx" (GPU) or "xrender" (CPU, safer on NVIDIA)
564
+            picom_backend: "glx".to_string(),
548565
             // Compositor settings (picom) - matching picom.conf defaults
549566
             corner_radius: 12,
550567
             blur_enabled: true,