This commit is contained in:
2026-09-09 11:30:58 +02:00
parent 78631065e2
commit 1367b03b97
8 changed files with 315 additions and 35 deletions
+15 -1
View File
@@ -82,7 +82,7 @@ fn run() -> Result<ExitCode, Box<dyn Error>> {
let displays = sway::displays(&mut sway)?;
let display = sway::focused(&displays).ok_or("sway reports no active display")?;
let opts = args.resolve(&config, display);
let mut targets = sway::windows(&mut sway)?;
let mut targets = sway::windows(&mut sway, opts.order)?;
if opts.outputs {
// Displays go last, after the windows, so window positions are
// stable as windows come and go.
@@ -198,6 +198,20 @@ fn run() -> Result<ExitCode, Box<dyn Error>> {
let Some(target) = app.picked() else {
return Ok(ExitCode::FAILURE); // cancelled: nothing on stdout
};
if opts.focus {
if let Ok(mut sway) = sway::connect() {
match target.kind {
target::Kind::Window => {
if let Some(con_id) = target.con_id {
let _ = sway.run_command(format!("[con_id={con_id}] focus"));
}
}
target::Kind::Output => {
let _ = sway.run_command(format!("focus output {}", target.id));
}
}
}
}
match target.render(opts.format) {
Some(line) => println!("{line}"),
// Only the portal format can fail to name something: it identifies a