Home

Awesome

This repo is now Archived

All the scripts from this repo are now available at SWABAI, including other window-manager commands and Yabai support.

At the time of writing, the workflow described here works exactly the same in SWABAI. As SWABAI is now my daily driver, I'll continue development there.

Sway-Talisman: Sway – Terminal Application Launcher in Scratchpad, Minimalist And Native

<p align="center"> <img src="https://github.com/sebastiancarlos/sway-talisman/assets/88276600/7847675e-3758-43b5-bc86-e39f18fb7af1" /> </p>

Welcome to sway-talisman, the ultra-minimalist approach to launching applications within the Sway/i3 tiling window managers.

This project leverages the power of terminals and Sway's scratchpad to function as an app launcher with no dependencies.

This is not a TUI launcher; It just makes your terminal even more of a launcher.

Introduction

GUI application launchers like rofi are cool, but if you're a Sway user, you might be interested in taking your minimalism to the next level.

It turns out we've had application launchers since the 1960's: Terminals and shells! Indeed, shells are the only programming languages in which launching a new process is a first-class citizen.

So, why not embrace a minimalist tiling-window-manager workflow in which your terminal is your application launcher?

If you go that route, sway-talisman might be for you.

Let's look at it from first principles. Application launchers are:

  1. Floating windows
  2. They open in response to a keybinding.
  3. They display and autocomplete a list of applications.
  4. They close after opening an application.

sway provides features 1 through 3 if your workflow consists of having a single terminal in your scratchpad.

sway-talisman is here to help you with feature 4, providing the missing UX piece of closing the scratchpad after launching the app.

Another issue with GUI application launchers is that they can be overwhelming: They usually show every single GUI application in your system, even those that came with packages you never intend to open.

sway-talisman provides instead an additive approach: You are responsible for defining every app you want to launch. And nothing stops you from adding extra automation and configuration before and after opening your app.

Features

Installation

  1. Clone the repo and run:
make
make install # This will install seven bash scripts in your path.
             # They can be removed with `make uninstall`
  1. In your Sway config, replace your bindings to move a window to the scratchpad and to toggle it.

Note: This is needed to add a mark to the scratchpad terminal, so it can be found by sway-talisman.

...
# Move the currently focused window to the scratchpad
# bindsym $mod+Shift+minus move scratchpad
bindsym $mod+Shift+minus exec sway-move-to-scratchpad
...
# Show the next scratchpad window or hide the focused scratchpad window.
# If there are multiple scratchpad windows, this command cycles through them.
# bindsym $mod+minus scratchpad show
bindsym $mod+minus exec sway-scratchpad-toggle
...
  1. Open a new terminal and move it to your scratchpad. (If you have one already, you'll need to close it and open a new one for the changes to apply.)

  2. Create aliases or scripts which call sway-launch, and call them from your regular terminals, from keybindings, or your brand-new terminal-scratchpad launcher!

Example:

# in .bashrc
alias firefox='sway-launch --workspace=next-empty -- firefox'

Then run:

<mod>- # open scratchpad
firefox<ret> # launch firefox, scratchpad is then hidden.

For a full list of options and customizations, see the individual script documentation below.

Usage

Usage: sway-launch [OPTIONS] [--]  <command> [arguments...]
       sway-launch [OPTIONS] [--] '<command> [arguments...]'

- Launch a command. Meant to be called from a wrapper script or alias, which in turn
  is called from a terminal running in the Sway/i3 scratchpad.

- After running it, the scratchpad is hidden. This is meant to simulate the UX of an
  application launcher like rofi, but from a terminal running in the scratchpad.

Options:
  -w, --workspace=<value>   Launch the command in the given workspace.
                            - VALUE can be "current" (default), "next", "prev",
                              "next-empty", or a number.
  -n, --no-hide-scratchpad  Do not hide the scratchpad after launching the command.
  -e, --window-name <value> Used to check for the new window's existence (by app_id
                            or instance). When the window exists, sway-launch exits.
                            With no value (default), exit as soon as a new window
                            is created.
  -t, --no-wait             Do not wait for a window to open. Exit immediately.
  -q, --quiet               Do not print any output. (Useful for wrapping scripts
                            with their own outputs.)
  -d, --debug               Print debug output.
  -h, --help                Show this help message.

Example:
  # in .bashrc
  alias firefox='sway-launch --workspace=next-empty -- firefox'

 <mod>- # open scratchpad
 firefox<ret> # launch firefox, scratchpad is then hidden.

Usage of utility scripts

These other bash scripts are used by sway-launch, the main entry point. But they are also yours to use elsewhere.

sway-get-workspace

Usage: sway-get-workspace
  - Print name of current workspace

sway-get-next-empty-workspace

Usage: sway-get-next-empty-workspace
  - Print number of the first empty workspace to the right of the
    current one (or the current workspace if it is empty).

sway-workspace

Usage: sway-workspace [OPTIONS] [VALUE]

- Go to provided workspace.
- If no value is provided, print the current workspace.

VALUE can be:
- "next", "prev", "next-empty", or a number.

OPTIONS:
  -q, --quiet               Do not print any output. (Useful for wrapping scripts
                            with their own outputs.)
  -h, --help                Show this help message.

sway-is-scratchpad-focused

Usage: sway-is-scratchpad-focused
  - If focused, returns 0 and print "true"
  - If not, returns 1 and print "false"

sway-move-to-scratchpad

Usage: sway-move-to-scratchpad
  - Move the focused window to the scratchpad
  - Also add a border and a mark called "scratchpad"

sway-scratchpad-toggle

Usage: sway-scratchpad-toggle [-h|--help] [-q|--quiet]
 - "advanced" version of "swaymsg scratchpad show" with one advantage:
   It toggles the scratchpad even if it's not currently focused, but only visible
   in the current workspace.
 - Relies on the scratchpad having the mark "scratchpad".

As featured in

You might also like

License

MIT

Contributing

We welcome contributions of all kinds. If you have a suggestion or fix, please feel free to open an issue or pull request.

Enjoy a lightweight, efficient, and terminal-centric launching experience with sway-talisman!

See also