Rust · 1762 bytes Raw Blame History
1 //! IPC types for gardisplay daemon communication.
2
3 use serde::{Deserialize, Serialize};
4
5 /// Request from client to daemon.
6 #[derive(Debug, Clone, Serialize, Deserialize)]
7 pub enum Request {
8 /// Re-detect connected monitors.
9 Detect,
10 /// Apply a profile (uses default if None).
11 Apply { profile: Option<String> },
12 /// List available profile names.
13 ListProfiles,
14 /// Get current profile name.
15 GetProfile,
16 /// Switch to a named profile.
17 SetProfile { name: String },
18 /// Set brightness (0.0 - 1.0).
19 SetBrightness { value: f64 },
20 /// Set gamma (0.5 - 2.0).
21 SetGamma { value: f64 },
22 /// Control night mode.
23 NightMode { action: NightModeAction },
24 /// Get full current state.
25 GetState,
26 }
27
28 /// Night mode control action.
29 #[derive(Debug, Clone, Serialize, Deserialize)]
30 pub enum NightModeAction {
31 On,
32 Off,
33 Toggle,
34 }
35
36 /// Response from daemon to client.
37 #[derive(Debug, Clone, Serialize, Deserialize)]
38 pub enum Response {
39 Ok,
40 Error { message: String },
41 Profile { name: String },
42 Profiles { names: Vec<String> },
43 State(DisplayState),
44 }
45
46 /// Current display state.
47 #[derive(Debug, Clone, Serialize, Deserialize)]
48 pub struct DisplayState {
49 pub current_profile: String,
50 pub monitors: Vec<MonitorInfo>,
51 pub brightness: f64,
52 pub gamma: f64,
53 pub night_mode_active: bool,
54 }
55
56 /// Monitor information for IPC.
57 #[derive(Debug, Clone, Serialize, Deserialize)]
58 pub struct MonitorInfo {
59 pub name: String,
60 pub x: i32,
61 pub y: i32,
62 pub width: u32,
63 pub height: u32,
64 pub primary: bool,
65 }
66
67 /// Event sent to gar window manager.
68 #[derive(Debug, Clone, Serialize, Deserialize)]
69 pub enum Event {
70 LayoutChanged { monitors: Vec<MonitorInfo> },
71 }
72