Add a config flag to disable an output
Browse files at this commitd155f5cd6c1a8c6a6e2b7259a8b0cee3187941acParent: 74ff4f13 changed files +12 -0
- resources/default-config.kdl +3 -0
- src/backend/tty.rs +5 -0
- src/config.rs +4 -0
resources/default-config.kdlmodified+3 -0
| @@ -43,6 +43,9 @@ input { | ||
| 43 | 43 | // The built-in laptop monitor is usually called "eDP-1". |
| 44 | 44 | // Remember to uncommend the node by removing "/-"! |
| 45 | 45 | /-output "eDP-1" { |
| 46 | + // Uncomment this line to disable this output. | |
| 47 | + // off | |
| 48 | + | |
| 46 | 49 | // Scale is a floating-point number, but at the moment only integer values work. |
| 47 | 50 | scale 2.0 |
| 48 | 51 |
src/backend/tty.rsmodified+5 -0
| @@ -431,6 +431,11 @@ impl Tty { | ||
| 431 | 431 | .cloned() |
| 432 | 432 | .unwrap_or_default(); |
| 433 | 433 | |
| 434 | + if config.off { | |
| 435 | + debug!("output is disabled in the config"); | |
| 436 | + return Ok(()); | |
| 437 | + } | |
| 438 | + | |
| 434 | 439 | let device = self |
| 435 | 440 | .output_device |
| 436 | 441 | .as_mut() |
src/config.rsmodified+4 -0
| @@ -120,6 +120,8 @@ pub struct Tablet { | ||
| 120 | 120 | |
| 121 | 121 | #[derive(knuffel::Decode, Debug, Clone, PartialEq)] |
| 122 | 122 | pub struct Output { |
| 123 | + #[knuffel(child)] | |
| 124 | + pub off: bool, | |
| 123 | 125 | #[knuffel(argument)] |
| 124 | 126 | pub name: String, |
| 125 | 127 | #[knuffel(child, unwrap(argument), default = 1.)] |
| @@ -133,6 +135,7 @@ pub struct Output { | ||
| 133 | 135 | impl Default for Output { |
| 134 | 136 | fn default() -> Self { |
| 135 | 137 | Self { |
| 138 | + off: false, | |
| 136 | 139 | name: String::new(), |
| 137 | 140 | scale: 1., |
| 138 | 141 | position: None, |
| @@ -624,6 +627,7 @@ mod tests { | ||
| 624 | 627 | }, |
| 625 | 628 | }, |
| 626 | 629 | outputs: vec![Output { |
| 630 | + off: false, | |
| 627 | 631 | name: "eDP-1".to_owned(), |
| 628 | 632 | scale: 2., |
| 629 | 633 | position: Some(Position { x: 10, y: 20 }), |