niri
Clone
https://git.tahinli.com/Tahinli/niri.git
0 watching·0 forks·Rust·GPL-3.0·12.1 MiB·9d8f4f8·Ivan Molodetskikh·1 month ago·2997 commits
| 1 | use crate::appearance::{Color, WorkspaceShadow, WorkspaceShadowPart, DEFAULT_BACKDROP_COLOR}; |
| 2 | use crate::utils::{Flag, MergeWith}; |
| 3 | use crate::FloatOrInt; |
| 4 | |
| 5 | #[derive(knuffel::Decode, Debug, Clone, PartialEq, Eq)] |
| 6 | pub struct SpawnAtStartup { |
| 7 | #[knuffel(arguments)] |
| 8 | pub command: Vec<String>, |
| 9 | } |
| 10 | |
| 11 | #[derive(knuffel::Decode, Debug, Clone, PartialEq, Eq)] |
| 12 | pub struct SpawnShAtStartup { |
| 13 | #[knuffel(argument)] |
| 14 | pub command: String, |
| 15 | } |
| 16 | |
| 17 | #[derive(Debug, PartialEq)] |
| 18 | pub struct Cursor { |
| 19 | pub xcursor_theme: String, |
| 20 | pub xcursor_size: u8, |
| 21 | pub hide_when_typing: bool, |
| 22 | pub hide_after_inactive_ms: Option<u32>, |
| 23 | } |
| 24 | |
| 25 | impl Default for Cursor { |
| 26 | fn default() -> Self { |
| 27 | Self { |
| 28 | xcursor_theme: String::from("default"), |
| 29 | xcursor_size: 24, |
| 30 | hide_when_typing: false, |
| 31 | hide_after_inactive_ms: None, |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | #[derive(knuffel::Decode, Debug, PartialEq)] |
| 37 | pub struct CursorPart { |
| 38 | #[knuffel(child, unwrap(argument))] |
| 39 | pub xcursor_theme: Option<String>, |
| 40 | #[knuffel(child, unwrap(argument))] |
| 41 | pub xcursor_size: Option<u8>, |
| 42 | #[knuffel(child)] |
| 43 | pub hide_when_typing: Option<Flag>, |
| 44 | #[knuffel(child, unwrap(argument))] |
| 45 | pub hide_after_inactive_ms: Option<u32>, |
| 46 | } |
| 47 | |
| 48 | impl MergeWith<CursorPart> for Cursor { |
| 49 | fn merge_with(&mut self, part: &CursorPart) { |
| 50 | merge_clone!((self, part), xcursor_theme, xcursor_size); |
| 51 | merge!((self, part), hide_when_typing); |
| 52 | merge_clone_opt!((self, part), hide_after_inactive_ms); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | #[derive(knuffel::Decode, Debug, Clone, PartialEq)] |
| 57 | pub struct ScreenshotPath(#[knuffel(argument)] pub Option<String>); |
| 58 | |
| 59 | impl Default for ScreenshotPath { |
| 60 | fn default() -> Self { |
| 61 | Self(Some(String::from( |
| 62 | "~/Pictures/Screenshots/Screenshot from %Y-%m-%d %H-%M-%S.png", |
| 63 | ))) |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | #[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] |
| 68 | pub struct HotkeyOverlay { |
| 69 | pub skip_at_startup: bool, |
| 70 | pub hide_not_bound: bool, |
| 71 | } |
| 72 | |
| 73 | #[derive(knuffel::Decode, Debug, Default, Clone, Copy, PartialEq, Eq)] |
| 74 | pub struct HotkeyOverlayPart { |
| 75 | #[knuffel(child)] |
| 76 | pub skip_at_startup: Option<Flag>, |
| 77 | #[knuffel(child)] |
| 78 | pub hide_not_bound: Option<Flag>, |
| 79 | } |
| 80 | |
| 81 | impl MergeWith<HotkeyOverlayPart> for HotkeyOverlay { |
| 82 | fn merge_with(&mut self, part: &HotkeyOverlayPart) { |
| 83 | merge!((self, part), skip_at_startup, hide_not_bound); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | #[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] |
| 88 | pub struct ConfigNotification { |
| 89 | pub disable_failed: bool, |
| 90 | } |
| 91 | |
| 92 | #[derive(knuffel::Decode, Debug, Default, Clone, Copy, PartialEq, Eq)] |
| 93 | pub struct ConfigNotificationPart { |
| 94 | #[knuffel(child)] |
| 95 | pub disable_failed: Option<Flag>, |
| 96 | } |
| 97 | |
| 98 | impl MergeWith<ConfigNotificationPart> for ConfigNotification { |
| 99 | fn merge_with(&mut self, part: &ConfigNotificationPart) { |
| 100 | merge!((self, part), disable_failed); |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | #[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] |
| 105 | pub struct Clipboard { |
| 106 | pub disable_primary: bool, |
| 107 | } |
| 108 | |
| 109 | #[derive(knuffel::Decode, Debug, Default, Clone, Copy, PartialEq, Eq)] |
| 110 | pub struct ClipboardPart { |
| 111 | #[knuffel(child)] |
| 112 | pub disable_primary: Option<Flag>, |
| 113 | } |
| 114 | |
| 115 | impl MergeWith<ClipboardPart> for Clipboard { |
| 116 | fn merge_with(&mut self, part: &ClipboardPart) { |
| 117 | merge!((self, part), disable_primary); |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | #[derive(Debug, Clone, Copy, PartialEq)] |
| 122 | pub struct Overview { |
| 123 | pub zoom: f64, |
| 124 | pub backdrop_color: Color, |
| 125 | pub workspace_shadow: WorkspaceShadow, |
| 126 | } |
| 127 | |
| 128 | impl Default for Overview { |
| 129 | fn default() -> Self { |
| 130 | Self { |
| 131 | zoom: 0.5, |
| 132 | backdrop_color: DEFAULT_BACKDROP_COLOR, |
| 133 | workspace_shadow: WorkspaceShadow::default(), |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | #[derive(knuffel::Decode, Debug, Clone, Copy, PartialEq)] |
| 139 | pub struct OverviewPart { |
| 140 | #[knuffel(child, unwrap(argument))] |
| 141 | pub zoom: Option<FloatOrInt<0, 1>>, |
| 142 | #[knuffel(child)] |
| 143 | pub backdrop_color: Option<Color>, |
| 144 | #[knuffel(child)] |
| 145 | pub workspace_shadow: Option<WorkspaceShadowPart>, |
| 146 | } |
| 147 | |
| 148 | impl MergeWith<OverviewPart> for Overview { |
| 149 | fn merge_with(&mut self, part: &OverviewPart) { |
| 150 | merge!((self, part), zoom, workspace_shadow); |
| 151 | merge_clone!((self, part), backdrop_color); |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | #[derive(knuffel::Decode, Debug, Default, Clone, PartialEq, Eq)] |
| 156 | pub struct Environment(#[knuffel(children)] pub Vec<EnvironmentVariable>); |
| 157 | |
| 158 | #[derive(knuffel::Decode, Debug, Clone, PartialEq, Eq)] |
| 159 | pub struct EnvironmentVariable { |
| 160 | #[knuffel(node_name)] |
| 161 | pub name: String, |
| 162 | #[knuffel(argument)] |
| 163 | pub value: Option<String>, |
| 164 | } |
| 165 | |
| 166 | #[derive(Debug, Clone, PartialEq, Eq)] |
| 167 | pub struct XwaylandSatellite { |
| 168 | pub off: bool, |
| 169 | pub path: String, |
| 170 | } |
| 171 | |
| 172 | impl Default for XwaylandSatellite { |
| 173 | fn default() -> Self { |
| 174 | Self { |
| 175 | off: false, |
| 176 | path: String::from("xwayland-satellite"), |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | #[derive(knuffel::Decode, Debug, Clone, PartialEq, Eq)] |
| 182 | pub struct XwaylandSatellitePart { |
| 183 | #[knuffel(child)] |
| 184 | pub off: bool, |
| 185 | #[knuffel(child)] |
| 186 | pub on: bool, |
| 187 | #[knuffel(child, unwrap(argument))] |
| 188 | pub path: Option<String>, |
| 189 | } |
| 190 | |
| 191 | impl MergeWith<XwaylandSatellitePart> for XwaylandSatellite { |
| 192 | fn merge_with(&mut self, part: &XwaylandSatellitePart) { |
| 193 | self.off |= part.off; |
| 194 | if part.on { |
| 195 | self.off = false; |
| 196 | } |
| 197 | |
| 198 | merge_clone!((self, part), path); |
| 199 | } |
| 200 | } |