git.lucas.co / cce-system-interface
system settings
git clone https://git.lucas.co/cce-system-interface.git

commit08a66910fbc3332d8843bdf6a353c70394f54098
parent786eea78a7
authorLucas Galante <[email protected]>
date2026-05-23 20:58
feat: add play bell toggle sound setting to notifications page

 src/main.rs                |  8 ++++++++
 src/pages/notifications.rs | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/src/main.rs b/src/main.rs
index 885caa8..1bbf4b3 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -715,6 +715,9 @@ impl SystemInterface {
                     if self.app.notifications.enable_toggle.cursor_moved(self.cursor_x / s, self.cursor_y / s) {
                         changed = true;
                     }
+                    if self.app.notifications.bell_toggle.cursor_moved(self.cursor_x / s, self.cursor_y / s) {
+                        changed = true;
+                    }
                 }
                 if self.app.current_page == Page::Typeface {
                     let s = self.scale_factor as f32;
@@ -999,6 +1002,11 @@ impl SystemInterface {
                     if toggle.take_click() {
                         actions.push(AppAction::Notifications(pages::notifications::NotificationsMessage::ToggleEnable));
                     }
+                    let toggle = &mut self.app.notifications.bell_toggle;
+                    toggle.mouse_input(*button, *state, lx, ly);
+                    if toggle.take_click() {
+                        actions.push(AppAction::Notifications(pages::notifications::NotificationsMessage::ToggleBell));
+                    }
                 }
                 if *state == ElementState::Pressed && self.app.current_page == Page::Audio {
                     for (i, sb) in self.app.audio.sink_spinboxes.iter_mut().enumerate() {
diff --git a/src/pages/notifications.rs b/src/pages/notifications.rs
index b467580..441dd5b 100644
--- a/src/pages/notifications.rs
+++ b/src/pages/notifications.rs
@@ -12,6 +12,8 @@ const CLEARWM_SOCK: &str = "/tmp/clearwm.sock";
 pub struct NotificationsState {
     pub enable: bool,
     pub enable_toggle: Toggle,
+    pub bell: bool,
+    pub bell_toggle: Toggle,
 }
 
 impl Default for NotificationsState {
@@ -19,6 +21,8 @@ impl Default for NotificationsState {
         Self {
             enable: true,
             enable_toggle: Toggle::new().with_label("Enable Notifications"),
+            bell: false,
+            bell_toggle: Toggle::new().with_label("Play Bell Sound"),
         }
     }
 }
@@ -26,6 +30,7 @@ impl Default for NotificationsState {
 #[derive(Debug, Clone)]
 pub enum NotificationsMessage {
     ToggleEnable,
+    ToggleBell,
     SendTestNotification,
     Refreshed(NotificationsState),
 }
@@ -33,9 +38,12 @@ pub enum NotificationsMessage {
 pub fn read_notifications_config() -> NotificationsState {
     let content = fs::read_to_string(CONFIG_PATH).unwrap_or_default();
     let enable = parse_notifications_enable(&content);
+    let bell = parse_notifications_bell(&content);
     NotificationsState {
         enable,
         enable_toggle: Toggle::new().with_label("Enable Notifications"),
+        bell,
+        bell_toggle: Toggle::new().with_label("Play Bell Sound"),
     }
 }
 
@@ -59,6 +67,26 @@ fn parse_notifications_enable(content: &str) -> bool {
     true // default to true
 }
 
+fn parse_notifications_bell(content: &str) -> bool {
+    let mut in_section = false;
+    for line in content.lines() {
+        let trimmed = line.trim();
+        if trimmed == "[notifications]" {
+            in_section = true;
+            continue;
+        }
+        if trimmed.starts_with('[') && in_section {
+            break;
+        }
+        if in_section && trimmed.starts_with("bell") {
+            if let Some(val) = trimmed.split('=').nth(1) {
+                return val.trim() == "true";
+            }
+        }
+    }
+    false // default to false
+}
+
 fn send_ipc_command(cmd: &str) {
     if let Ok(mut stream) = std::os::unix::net::UnixStream::connect(CLEARWM_SOCK) {
         let _ = stream.write_all(format!("{}\n", cmd).as_bytes());
@@ -152,6 +180,12 @@ pub fn view(state: &mut NotificationsState, cx: f32, cy: f32, cw: f32, _ch: f32)
     state.enable_toggle.set_toggled(state.enable);
     state.enable_toggle.set_row_rect(sec.ax(8.0), cw - 16.0);
     render_widget(&mut pc, &mut state.enable_toggle, sec.ax(100.0), yt, toggle_w, toggle_h);
+    sec.content_y += toggle_h + 12.0;
+
+    let yt2 = sec.ay();
+    state.bell_toggle.set_toggled(state.bell);
+    state.bell_toggle.set_row_rect(sec.ax(8.0), cw - 16.0);
+    render_widget(&mut pc, &mut state.bell_toggle, sec.ax(100.0), yt2, toggle_w, toggle_h);
     sec.content_y += toggle_h + 24.0;
 
     let btn_w = 160.0;
@@ -182,6 +216,10 @@ pub fn update(state: &mut NotificationsState, msg: NotificationsMessage) {
             state.enable = !state.enable;
             write_enable_notifications(state.enable);
         }
+        NotificationsMessage::ToggleBell => {
+            state.bell = !state.bell;
+            write_config_value("bell", &state.bell.to_string());
+        }
         NotificationsMessage::SendTestNotification => {
             send_ipc_command("notify \"clearwm\" \"System notifications are working correctly!\"");
         }