alt-tab
This commit is contained in:
+15
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user