Skip to content
Fenner Macrae edited this page Sep 14, 2022 · 5 revisions

The Flashfocus Wiki

This wiki provides explanations of some of flashfocus' more niche features, see the README for basic usage.

Flashing the Current Window

Flashfocus contains two options for flashing the currently active window.

  • flash_window is implemented in python with no extra dependencies. Its fairly fast and should work fine for most people.

  • nc_flash_window is ~4X faster than flash_window, but requires the OpenBSD flavor of netcat to be installed (openbsd-netcat on Arch).

Defining Window-Specific Flash Rules in Config File

X-based Window Managers

Flash rules are defined by matching the WM_CLASS property of a window. To get the WM_CLASS property of a window use xprop WM_CLASS and click on a window. The property is a tuple of the form (window-id, window-class). The window-class is usually the name of the application, but not always.

Say I'd like to set all termite windows to 80% opacity but leave other windows at full opacity:

rules:
  - window-class: Termite
    default-opacity: 0.8

I also would prefer that firefox windows are not flashed on focus:

rules:
  - window-class: firefox
    flash-on-focus: False
  - window-class: Termite
    default-opacity: 0.8

For more complicated rules, you can use (python-style) regexes:

rules:
  - window-id: ^(?!termite)$
    default-opacity: 0.8

Sway

Native wayland apps can be matched using the app_id and window name. These can be found using swaymsg -t get_tree. XWayland apps are matched with using WM_CLASS as above (this can also be found with swaymsg)

Given that termite is wayland native and firefox is not, the rules above could instead be written:

rules:
  - window-class: firefox
    flash-on-focus: False
  - app-id: termite
    default-opacity: 0.8
rules:
  - window-name: ^(?!termite)$
    default-opacity: 0.8

Systemd config

Instructions for setting up flashfocus to run as a systemd service.

First make sure that /usr/lib/systemd/user/flashfocus.service exists. If not you'll need to manually create the file. See https://github.com/fennerm/flashfocus/blob/master/flashfocus.service

Sway

  1. Place the following systemd unit file in ~/.config/systemd/user/sway-session.target:
[Unit]
Description=sway compositor session
Documentation=man:systemd.special(7)
BindsTo=graphical-session.target
Wants=graphical-session-pre.target
After=graphical-session-pre.target
  1. Add exec "systemctl --user import-environment; systemctl --user start sway-session.target" to the bottom of your sway config file.

  2. systemctl --systemctl --user enable --now flashfocus

  3. Flashfocus should start up automatically next time you log in.

For more detailed instructions see https://github.com/swaywm/sway/wiki/Systemd-integration

X-based window managers

  1. Place the following systemd unit file in ~/.config/systemd/user/xsession.target:
[Unit]
Description=X session
Documentation=man:systemd.special(7)
BindsTo=graphical-session.target
Wants=graphical-session-pre.target
After=graphical-session-pre.target
  1. Add systemctl --user import-environment; systemctl --user start xsession.target to ~/.xinitrc. Might need to tweak this step depending on your setup and it might not be necessary at all if you use a login manager.

  2. systemctl --systemctl --user enable --now flashfocus

  3. Flashfocus should start up automatically next time you log in.

For more detailed instructions see https://goral.net.pl/post/systemd-x-sessions/

Alternatives to flashfocus

  • glimmer - Similar idea to flashfocus but using window borders rather than opacity.

  • If you use sway and you want something simple, this script replicates the core functionality of flashfocus.

#!/bin/bash

for OP in 0.905 0.82 0.745 0.68 0.625 0.58 0.545 0.52 0.505 0.5 0.505 0.52 0.545 0.58 0.625 0.68 0.745 0.82 0.905 1
do
        swaymsg opacity $OP
        sleep .005
done

Then you'd need to add something like this to your sway config:

bindsym $mod+$left exec swaymsg focus left && path-to-script
bindsym $mod+$right exec swaymsg focus right && path-to-script
bindsym $mod+$down exec swaymsg focus down && path-to-script
bindsym $mod+$up exec swaymsg focus up && path-to-script