atagen

monolith

public
Star0
Watch0

Commit 140b53f6ef84

tarball

atagen <boss@atagen.co>2026-10-19 07:51 UTC

2 files changed+17-0
ipc: add a power command for outputs

Output power could only be changed through wlr-output-power-management, which needs a client speaking Wayland. `power on|off [output]` reaches the same `Power` state from a shell or a keybind. It is an additive `Command` variant, so existing clients and configs parse as before.
Modified file: crates/ipc/src/lib.rs+16 additions
@@ -102,6 +102,12 @@ pub enum Command {
102102 Dismiss {
103103 name: Option<String>,
104104 },
105+ /// Switches outputs on or off, all of them without a name.
106+ Power {
107+ on: bool,
108+ #[serde(default)]
109+ output: Option<String>,
110+ },
105111 }
106112
107113 #[derive(Debug, Clone, PartialEq, Eq)]
@@ -208,6 +214,16 @@ impl Command {
208214 _ => return Err(err("takes at most one name")),
209215 },
210216 },
217+ "power" => {
218+ let (on, output) = match args {
219+ ["on"] => (true, None),
220+ ["off"] => (false, None),
221+ ["on", o] => (true, Some(o.to_string())),
222+ ["off", o] => (false, Some(o.to_string())),
223+ _ => return Err(err("takes on or off and optionally an output")),
224+ };
225+ Command::Power { on, output }
226+ }
211227 _ => return Err(ParseError(format!("unknown command {name}"))),
212228 })
213229 }
Modified file: crates/monolith/src/commands.rs+1 additions
@@ -156,6 +156,7 @@ impl State {
156156 self.wm.layout.summon(&name);
157157 }
158158 Command::Dismiss { name } => self.wm.layout.dismiss(name.as_deref()),
159+ Command::Power { on, output } => self.set_output_power(output.as_deref(), on)?,
159160 }
160161 self.apply_layout();
161162 Ok(())