Skip to content

Sway Integration

set $super Mod4
bindsym $super+Space exec raffi

Inside sway, Raffi starts the app you pick with swaymsg exec, so sway is its parent and the app gets sway’s environment and working directory. Command lines that sway would split or expand (with ;, ,, $, quotes, backslashes or line breaks) are started by Raffi itself. To always start apps from Raffi, set launch: direct in general (see General Settings).

Raffi’s window has the app ID com.chmouel.raffi. To float it in the middle of the screen without a border:

for_window [app_id="com.chmouel.raffi"] floating enable, border none, resize set width 45 ppt height 78 ppt, move position center

Put this in the config file. Sent through swaymsg, the commands after the first comma run on their own and fail.

If you start a second style with raffi --app-name com.chmouel.raffi.fb, give it its own for_window line with that app ID.

Pass an addon keyword as the initial query to open Raffi straight into it:

bindsym $super+w exec raffi -i "win "
bindsym $super+v exec raffi -i "clip "
bindsym $super+t exec raffi -i "tabs "

win lists the open windows, scratchpad included. Enter focuses one, Ctrl+Enter moves it to the current workspace, Ctrl+D closes it, and Ctrl+Tab shows the workspaces instead. The list follows sway’s window and workspace events while it is open. See Window Switcher.

With raise_running: true in general, Enter on a launcher whose app already has a window focuses that window, and Ctrl+Enter starts a new one. Raffi matches the app ID, or the class of an Xwayland window. See General Settings.

ifcompositor shows a launcher only under the given compositors:

launchers.yaml
sway-reload:
binary: swaymsg
args: ["reload"]
description: "Reload sway"
ifcompositor: sway

Raffi is translucent by default (opacity: 0.95 in general). Plain Sway has no blur. SwayFX can blur behind it:

for_window [app_id="com.chmouel.raffi"] blur enable

See Transparency and Blur.

raffi -p prints the selected command instead of running it. You can hand it to swaymsg yourself:

set $menu raffi -p
bindsym $super+Space exec cmd=$($menu) && [ -n "$cmd" ] && swaymsg exec -- "$cmd"

[ -n "$cmd" ] skips swaymsg when nothing was picked, and the quotes pass the command as one argument, which keeps arguments with spaces and multi-line script entries intact.

  • Check that Raffi is in sway’s PATH. Sway’s exec runs commands through sh -c, which does not read ~/.bashrc or ~/.zshrc, so a binary in ~/.cargo/bin can work in a terminal but not from a binding. Use an absolute path, or export the directory with systemctl --user import-environment PATH.
  • Check sway’s logs: journalctl --user -u sway.

An app starts with the wrong environment or directory

Section titled “An app starts with the wrong environment or directory”

Apps started through sway inherit sway’s environment, not your shell’s. Set launch: direct to have Raffi start them, or export the variables to sway.

Invalid exec command (expected at least 1 argument, got 0)

Section titled “Invalid exec command (expected at least 1 argument, got 0)”

This comes from swaymsg in the print-only recipe: Raffi printed nothing because you closed it or picked an addon result, which acts inside Raffi. Keep the [ -n "$cmd" ] guard.

Write a debug log from the binding:

bindsym $super+Space exec raffi --debug-file /tmp/raffi.log