"Better" tab and stack navigation for Sway WM.

Overview

sway_bfocus

"Better" tab and stack navigation for Sway WM. Proof of concept.

This program lets you create one set of keybinds exclusively for cycling through tabs/stacks, and another set exclusively for navigating between splits. The result is that switching focus generally can be performed in one action rather than some sequence of focus parent and focus [direction] actions.

Installation

Clone the repository, run cargo build --release, and copy the executable to a location in your$PATH (~/.local/bin/ is probably a good choice).

Commands can then be added to the config, e.g. bindsym $mod+k exec sway_bfocus splitv backward nocycle.

Usage

sway_bfocus (splith|splitv|tabbed|stacked) (forward|backward) (cycle|nocycle)

The command takes a layout target, a direction, and a cycle setting. It works similarly to the regular focus commands, but will only focus neighbors in the first parent container that matches the layout target.

Example

See below for a simple configuration. This setup doesn't handle stacks, but should be enough for most other use cases. Consider using a different keybind for focusing the previous tab, as the suggestion is dangerously close to $mod+Shift+q.

Focus Keybind Command
up $mod+k sway_bfocus splitv backward nocycle
down $mod+j sway_bfocus splitv forward nocycle
left $mod+h sway_bfocus splith backward nocycle
right $mod+l sway_bfocus splith forward nocycle
prev tab $mod+Shift+Tab sway_bfocus tabbed backward cycle
next tab $mod+Tab sway_bfocus tabbed forward cycle

TODO

  • Showcase video
  • Float support
  • Ignoring singletons
  • Multiple layout targets
  • Directional focus between outputs
  • Workspace wraparound
  • Moving containers?
Comments
  • doc: add mention of AUR package to README.md

    doc: add mention of AUR package to README.md

    Hey,

    I have created an Arch User Repository (AUR) package for this repository under the name sway-overfocus. Software from the AUR is very convenient to install for users of the pacman package manager (which is the default for Arch Linux and Manjaro) over an installation from source. The package currently tracks the 0.2.3 version, as given by the tag. Feel free to add a mention to this package to the README if you would like.

    Note: While creating the package, I noticed that the package versions for sway-overfocus differ in the Cargo.toml (0.2.3) and Cargo.lock (0.2.2) files. I currently circumvent this issue in the build process by using sed to adjust the version in the lockfile. Please let me know if this intended or if you plan to fix this discrepancy.


    In case you never heard of the AUR, let me quote from the Arch Linux wiki:

    The Arch User Repository (AUR) is a community-driven repository for Arch users. It contains package descriptions that allow you to compile a package from source with makepkg and then install it via pacman. The AUR was created to organize and share new packages from the community and to help expedite popular packages' inclusion into the community repository.


    In case you have any questions or concerns, or would like me to take the package down, please let me know. Thank you for providing this great piece of software!

    opened by leon-richardt 4
  • Make order of operations significant

    Make order of operations significant

    Hiya! Found this via that sway ticket & loving it, great work.

    This request is probably going to seem esoteric but would it be possible to make the order in which the movement arguments were specified semantically significant?

    My use case is essentially this (paraphrased):

    bindsym [hjkl] exec sway-overfocus group-[ldur]w split-[ldur]w
    bindsym Shift+[hjkl] exec sway-overfocus split-[ldur]w group-[ldur]w
    

    So, because I have a layout that frequently ends up as alternations of tab > split > tab > sometimes split, what I'm after is for my basic hjkl movements to move group-wise if the focus is within a tabbed/stacked container, and split-wise if it's not (so, how it works currently). However, I would like, when I shift the keys, for the behaviour to be the exact opposite, where it will move split-wise when the focus is in a tabbed/stacked container, and tab-wise when it's in a split, which for me essentially has the effect of moving containers at the parent level instead of the focus level.

    However, at the moment, unless I've set something up incorrectly, it would appear that both of those commands do the same thing, which I'd assume would mean the order of arguments is not taken into account.

    opened by Myrdden 4
  • Directional movement between outputs, floats

    Directional movement between outputs, floats

    My setup is: External monitor with pos: 0,0 Laptop monitor with pos: 3840,0 My external monitor is physically positioned to the left of my laptop.

    The original focus command in sway allows me to

    1. Have focus in a window/container on my laptop-screen
    2. Press mod+Left
    3. Get focus on a window on my external monitor (positioned to the left of my laptop both virtually and physically)

    sway_bfocus does not transcend desktop boundaries.

    If the aim is to replace the focus command, all "active desktops", i.e. those that are currently displayed, should be taken into account when switching focus.

    enhancement 
    opened by madsobitsoe 3
  • Build requires feature `strip`, not stabilized in Cargo 1.58.0/rustc 1.58.1

    Build requires feature `strip`, not stabilized in Cargo 1.58.0/rustc 1.58.1

    The README states that Cargo 1.58 or newer is required to build, but the project doesn't build with Cargo 1.58. See the output below.

    > cargo build --release
    error: failed to parse manifest at `/home/mads/dev/sway-overfocus/Cargo.toml`
    
    Caused by:
      feature `strip` is required
    
      The package requires the Cargo feature called `strip`, but that feature is not stabilized in this version of Cargo (1.58.0 (f01b232bc 2022-01-19)).
      Consider trying a newer version of Cargo (this may require the nightly release).
      See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#profile-strip-option for more information about the status of this feature.
    
    opened by madsobitsoe 2
  • Attempting to focus a window with no title fails

    Attempting to focus a window with no title fails

    If the target window has no title, sway-overfocus fails.

    $ sway-overfocus split-lw float-lw
    error: no valid focus command
    

    The window that should be the target (notice name is null):

    {
      "id": 63,
      "type": "con",
      "orientation": "none",
      "percent": 0.3319633259563705,
      "urgent": false,
      "marks": [],
      "focused": true,
      "layout": "none",
      "border": "pixel",
      "current_border_width": 4,
      "rect": {
        "x": 2154,
        "y": 18,
        "width": 1050,
        "height": 1668
      },
      "deco_rect": {
        "x": 0,
        "y": 0,
        "width": 0,
        "height": 0
      },
      "window_rect": {
        "x": 4,
        "y": 4,
        "width": 1042,
        "height": 1660
      },
      "geometry": {
        "x": 0,
        "y": 0,
        "width": 500,
        "height": 500
      },
      "name": null,
      "window": 6291457,
      "nodes": [],
      "floating_nodes": [],
      "focus": [],
      "fullscreen_mode": 0,
      "sticky": false,
      "pid": 3670786,
      "app_id": null,
      "visible": true,
      "max_render_time": 0,
      "shell": "xwayland",
      "inhibit_idle": false,
      "idle_inhibitors": {
        "user": "none",
        "application": "none"
      },
      "window_properties": {
        "transient_for": null
      }
    }
    

    If I forcefully set a name with xprop, sway-overfocus works as expected:

    $ xprop -id 6291457 -set WM_NAME test
    $ sway-overfocus split-lw float-lw
    [
      {
        "success": true
      }
    ]
    
    bug 
    opened by b0o 2
  • Floating containers

    Floating containers

    Currently, floating containers are simply ignored, so trying to change focus from one does nothing.

    Since they are only present in workspace containers, we should be able to get basic support by reforming the top nodes of the tree. It might be challenging to support proper directional movement.

    enhancement 
    opened by korreman 2
  • Target several layouts at once

    Target several layouts at once

    Currently I cycle through tabs with bindsym $mod+Tab exec sway_bfocus tabbed forward cycle

    However, I sometimes stack my windows instead of tabbing them.

    Is it possible to make the cycling tab/stack agnostic?

    enhancement 
    opened by madsobitsoe 2
  • Bump regex from 1.5.4 to 1.5.6

    Bump regex from 1.5.4 to 1.5.6

    Bumps regex from 1.5.4 to 1.5.6.

    Changelog

    Sourced from regex's changelog.

    1.5.6 (2022-05-20)

    This release includes a few bug fixes, including a bug that produced incorrect matches when a non-greedy ? operator was used.

    1.5.5 (2022-03-08)

    This releases fixes a security bug in the regex compiler. This bug permits a vector for a denial-of-service attack in cases where the regex being compiled is untrusted. There are no known problems where the regex is itself trusted, including in cases of untrusted haystacks.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • Change command syntax in README

    Change command syntax in README

    The following doesn't work in my config

    set $i3_scripts ~/.config/i3/scripts
    bindsym $mod+w exec '$i3_scripts/sway-overfocus split-li group-lw'
    bindsym $mod+e exec '$i3_scripts/sway-overfocus split-ri group-ri'
    

    whereas this works:

    set $i3_scripts ~/.config/i3/scripts
    bindsym $mod+w exec $i3_scripts/sway-overfocus split-li group-lw   # Remove single quotes
    bindsym $mod+e exec $i3_scripts/sway-overfocus split-ri group-ri   # Remove single quotes
    

    Maybe change README to address this?

    documentation 
    opened by RayZ0rr 1
  • Direct IPC

    Direct IPC

    The program runs for sway in 5-15ms on my system, which is acceptable. It takes 30-50ms in i3 however.

    The vast majority of time is spent running the swaymsg/i3-msg commands, while parsing and searching takes less than 1ms. Maybe doing IPC directly would be significantly faster?

    enhancement 
    opened by korreman 0
  • Fullscreen

    Fullscreen

    When a container is fullscreened, the containing workspace should be treated as simply holding that container alone. Currently, containers are always focused as though nothing is full-screen.

    bug 
    opened by korreman 0
  • Moving containers around

    Moving containers around

    It'd be nice to support moving containers using the same logic they are focused with.

    My initial idea is that sway_bfocus move <targets> should find the container that would be focused, then place the currently focused container right before or after it. This wouldn't be as powerful as the builtin directional movement, but it would be more consistent. The lacking functionality could then be achieved with an additional move to parent command.

    enhancement 
    opened by korreman 6
Releases(v0.2.3-fix)
Owner
null
Nushell "extern" definitions for tab completion generated from Fish's

Nushell completions pack This is a system for generating extern defs (tab-completion) in nu. Background The fish shell project has a long, complicated

Scott Boggs 7 Feb 28, 2023
A user-friendly TUI for secure file transfers, with arrow-key and VIM-style navigation

gsftp SFTP with an interactive text-based user interface (TUI). Transfer files through an encrypted connection with a visual interface, so you can see

Ben Jiron 3 Jul 7, 2022
Modern file system navigation tool on Unix

monat -- Modern file system Navigator 简体中文 Introduction monat is a Unix shell auxiliary command focusing on the navigation of the file system, especia

Pavinberg 8 May 10, 2022
Galileo OSNMA (Open Service Navigation Message Authentication)

galileo-osnma galileo-osnma is a Rust implementation of the Galileo OSNMA (Open Service Navigation Message Authentication) protocol. This protocol is

Daniel Estévez 26 Nov 25, 2022
Adds back-and-forth jumping between current and previous focused windows to Sway.

sway-focus-back-and-forth Implements back-and-forth movement between the current and the previous focused windows. It also can be seen as a fix to thi

Vinícius Müller 4 Aug 11, 2022
A native screenshot tool for wlroots based compositors such as sway and river written in Rust

A native screenshot tool for wlroots based compositors such as sway and river written in Rust. X11 support coming soon.

Waycrate 66 Dec 28, 2022
Faster and better alternative to Vtop written in Rust.

Rtop Faster and better alternative to Vtop written in Rust. Work in Progress Features Lightweight < 1MB Responsive UI Sort Process by Memory, CPU Usag

Squitch 7 Nov 18, 2022
A system clipboard command line tools which inspired by pbcopy & pbpaste but better to use.

rclip A command line tool which supports copy a file contents to the system clipboard or copy the contents of the system clipboard to a file. Install

yahaa 3 May 30, 2022
A better customization password dictionary generator implementation by Rust.

abcdict A better customization password dictionary generator implementation by Rust. Features Cli Faster Customize Rules Build & Installation $> cargo

b23r0 6 Jun 2, 2022
nothing::[Probably] is a better [Option].

nothing::[Probably] is a better [Option].

Btwiuse Arch 0 Sep 22, 2022
A better rust version of pokeget.

pokeget-rs A better rust version of pokeget. Usage pokeget <pokemon> for more info, run pokeget --help Also, if you're using pokeget in your bashrc, t

Tal 11 Aug 14, 2023
A localized open-source AI server that is better than ChatGPT.

??AI00 RWKV Server English | 中文 | 日本語 AI00 RWKV Server is an inference API server based on the RWKV model. It supports VULKAN inference acceleration a

顾真牛 142 Aug 23, 2023
`cal` (but better!) in rust

cal-rs cal-rs is a simple command-line calendar application written in Rust. It allows you to display a calendar for a specific month and year, with o

Robert Jackson 3 Apr 8, 2024
Another approach to thread stack spoofing.

Description This Twitter thread inspired the creation of this tool. Unwinder is a PoC of how to parse PE's UNWIND_INFO structs in order to achieve "pr

Kurosh Dabbagh Escalante 132 Jan 6, 2023
Dragonfly, POC full-stack web app DSL

Dragonfly Dragonfly is a toy DSL that explores ways to describe the structure of full-stack web applications. You should not use it in production. For

Bas Dirks 9 Mar 15, 2023
🦀🔨 DevBcn Workshop - Full Stack Rust - Actix - Postgres - Shuttle - Dioxus

Building a Movie Collection Manager - Full Stack Workshop with Rust, Actix, SQLx, Dioxus, and Shuttle Welcome to the this workshop! In this hands-on w

BcnRust 57 Jul 12, 2023
A Nix template for full-stack web apps in Rust using Leptos

leptos-fullstack A Nix template for full-stack web apps in Rust using Leptos. Tech used: Leptos full-stack framework server functions ssr + hydration

Sridhar Ratnakumar 6 Aug 4, 2023
SquidVM is a VM made in Rust implementing a Stack-based machine.

What is SquidVM? _____ _ ___ ____ __ / ____| (_) | \ \ / / \/ | | (___ __ _ _ _ _ __| |\ \ / /| \ /

Fragmenta 4 Dec 17, 2023
Easy recursion in Rust, without stack overflows.

Recursive With recursive you can easily make (indirectly) recursive functions without worrying about stack overflows by marking them as #[recursive]:

Orson Peters 28 Jul 5, 2024