claude_code_toolkit/utils/
mod.rs1pub mod systemd;
2
3#[cfg(feature = "notifications")]
4pub mod notifications {
5 use crate::error::*;
6 use notify_rust::Notification;
7 use tracing::warn;
8
9 pub fn send_session_warning(minutes_remaining: u64) -> Result<()> {
10 let title = "Claude Code Session Warning";
11 let body = format!("Your Claude session expires in {} minutes", minutes_remaining);
12
13 match
14 Notification::new()
15 .summary(title)
16 .body(&body)
17 .icon("dialog-warning")
18 .timeout(5000) .show()
20 {
21 Ok(_) => Ok(()),
22 Err(e) => {
23 warn!("Failed to send notification: {}", e);
24 Err(ClaudeCodeError::Notification(e.to_string()))
25 }
26 }
27 }
28
29 pub fn send_sync_failure(target: &str, error: &str) -> Result<()> {
30 let title = "Claude Code Sync Failed";
31 let body = format!("Failed to sync to {}: {}", target, error);
32
33 match
34 Notification::new()
35 .summary(title)
36 .body(&body)
37 .icon("dialog-error")
38 .timeout(10000) .show()
40 {
41 Ok(_) => Ok(()),
42 Err(e) => {
43 warn!("Failed to send notification: {}", e);
44 Err(ClaudeCodeError::Notification(e.to_string()))
45 }
46 }
47 }
48
49 pub fn send_sync_success(count: usize) -> Result<()> {
50 let title = "Claude Code Sync Success";
51 let body = format!("Successfully synced credentials to {} targets", count);
52
53 match
54 Notification::new()
55 .summary(title)
56 .body(&body)
57 .icon("dialog-information")
58 .timeout(3000) .show()
60 {
61 Ok(_) => Ok(()),
62 Err(e) => {
63 warn!("Failed to send notification: {}", e);
64 Err(ClaudeCodeError::Notification(e.to_string()))
65 }
66 }
67 }
68}
69
70#[cfg(not(feature = "notifications"))]
71pub mod notifications {
72 use crate::error::*;
73
74 pub fn send_session_warning(_minutes_remaining: u64) -> Result<()> {
75 Ok(())
76 }
77
78 pub fn send_sync_failure(_target: &str, _error: &str) -> Result<()> {
79 Ok(())
80 }
81
82 pub fn send_sync_success(_count: usize) -> Result<()> {
83 Ok(())
84 }
85}