1
0
Fork 0
forked from wry/wry

config: add Seat::show_workspace_on

This commit is contained in:
Julian Orth 2025-10-07 05:02:07 +02:00
parent d2ce140f54
commit d320d2f3c1
12 changed files with 131 additions and 13 deletions

View file

@ -141,6 +141,7 @@ pub enum Action {
},
ShowWorkspace {
name: String,
output: Option<OutputMatch>,
},
SimpleCommand {
cmd: SimpleCommand,

View file

@ -88,6 +88,8 @@ pub enum ActionParserError {
JumpToMark(#[source] MarkIdParserError),
#[error("Could not parse a copy-mark action")]
CopyMark(#[source] MarkIdParserError),
#[error("Could not parse a show-workspace action")]
ShowWorkspace(#[source] OutputMatchParserError),
}
pub struct ActionParser<'a>(pub &'a Context<'a>);
@ -184,8 +186,15 @@ impl ActionParser<'_> {
}
fn parse_show_workspace(&mut self, ext: &mut Extractor<'_>) -> ParseResult<Self> {
let name = ext.extract(str("name"))?.value.to_string();
Ok(Action::ShowWorkspace { name })
let (name, output) = ext.extract((str("name"), opt(val("output"))))?;
let name = name.value.to_string();
let output = output
.map(|o| {
o.parse_map(&mut OutputMatchParser(self.0))
.map_spanned_err(ActionParserError::ShowWorkspace)
})
.transpose()?;
Ok(Action::ShowWorkspace { name, output })
}
fn parse_move_to_workspace(&mut self, ext: &mut Extractor<'_>) -> ParseResult<Self> {

View file

@ -235,9 +235,26 @@ impl Action {
}
Action::Exec { exec } => b.new(move || create_command(&exec).spawn()),
Action::SwitchToVt { num } => b.new(move || switch_to_vt(num)),
Action::ShowWorkspace { name } => {
Action::ShowWorkspace { name, output } => {
let workspace = get_workspace(&name);
b.new(move || s.show_workspace(workspace))
let state = state.clone();
b.new(move || {
let output = 'get_output: {
let Some(output) = &output else {
break 'get_output None;
};
for connector in connectors() {
if connector.connected() && output.matches(connector, &state) {
break 'get_output Some(connector);
}
}
None
};
match output {
Some(o) => s.show_workspace_on(workspace, o),
_ => s.show_workspace(workspace),
}
})
}
Action::MoveToWorkspace { name } => {
let workspace = get_workspace(&name);