Skip to content

Instantly share code, notes, and snippets.

@eugene-eeo
Last active May 2, 2019 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eugene-eeo/0b8e6b2686205fb9e4d165a8bfae9908 to your computer and use it in GitHub Desktop.
Save eugene-eeo/0b8e6b2686205fb9e4d165a8bfae9908 to your computer and use it in GitHub Desktop.
Floating Layer support for HLWM

Herbsluftwm does not natively come with support for a 'proper' floating layer. We can remedy that problem using some scripting; the goal is to get a 'seamless' experience.

First you need to download and run the floatmon script somewhere in autostart. Using this is a good start. But if you use multiple monitors you will run into the issue where if you focus right, sometimes you can focus an empty floatmon monitor. So probably you want to disable the focus_crosses_monitor_boundaries option.

Alternative:

# autostart

bind_focus_ignore_floatmon() {
    # only focus floatmon if it has >= 1 client.
    hc keybind $Mod-$1 try and \
        . focus $2 \
        . compare monitors.focus.name = floatmon \
        . compare tags.focus.client_count = 0 \
        . focus $2 \
        # still in floatmon => back please
        . compare monitors.focus.name = floatmon \
        . focus $3
}

bind_focus_ignore_floatmon Left  left  right
bind_focus_ignore_floatmon Up    up    down
bind_focus_ignore_floatmon Down  down  up
bind_focus_ignore_floatmon Right right left

I like this binding too:

# close the window, but if we are in floatmon
# then switch back to the previous monitor
hc keybind $Mod-Shift-c or \
    , and \
        . compare monitors.focus.name = floatmon \
        . substitute M clients.focus.my_lastmon and \
            + close \
            + try focus_monitor M \
    , close

to avoid focusing the floatmon monitor when you cycle monitors, we can also do this:

hc keybind $Mod-BackSpace try and \
    . cycle_monitor \
    . compare monitors.focus.name = floatmon \
    . cycle_monitor

Finally we place all dialogs/popups in the floating layer:

hc rule windowtype~'_NET_WM_WINDOW_TYPE_(DIALOG|UTILITY|SPLASH)' pseudotile=on tag='fl'

for proper multi-monitor support you'll need something like this:

hc remove_monitor floatmon
hc detect_monitors
# panel things
~/.config/herbstluftwm/floatmon.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment