Skip to content

yz778/hyprfloat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hyprfloat

hyprfloat is a Lua script that provides enhanced window management features for Hyprland, including a GNOME-style overview, floating window snapping, and more.

Demonstration.mp4

Getting Started

Prerequisites

Installation

  1. Install the required dependencies. Example using yay in Arch Linux:

    yay -S lua lua-posix lua-lgi lua-cjson grim-hyprland
  2. Run the install script

    curl -fsSL https://raw.githubusercontent.com/yz778/hyprfloat/main/install.sh | sh
  3. (Optional) Install and customize the default configuration file.

    hyprfloat install-config

    The configuration will be placed at ~/.config/hypr/hyprfloat.config.lua.

  4. Add bindings and rules to your ~/.config/hypr/hyprland.conf

Features

  • ALT-Tab Window Switching: A window switcher with MRU (Most-Recently-Used) focus, search / preview, and an option to switch between windows of the same class. To search through previews, keep holding the ALT key down as you type.
ALT-Tab.Window.Switching.mp4
  • Workspace Overview: Arranges all windows into a grid, similar to GNOME's overview.

  • Float Mode: Toggles all windows between tiling and floating, with customizable Hyprland settings for each mode.

  • Window Snapping: Snaps the active window to fractional portions of the screen.

  • Window Centering: Centers the active window, with an option to scale it.

  • Multi-monitor Support: Move windows between monitors while maintaining relative size and position.

  • Workspace Groups: Group workspaces together and cycle through them. This is useful for multi-monitor setups.

Commands

alttab <next|prev> [sameclass]

Switches focus to the next or previous window in the focus history.

Arguments:

  • <next|prev> Required. Specifies whether to switch to the next or the previous window.
  • [sameclass] Optional. If provided, the window selection is restricted to windows of the same class as the currently active window.

center <scale>

Centers the active window in the middle of the screen and applies a scaling factor.

Arguments:

  • <scale> Required. A number to scale the window size (e.g., 1.0 for original size, 1.2 to enlarge, 0.8 to shrink).

hyprfloat dynamicbind <binding>

Runs a command as defined in `dynamic_bind` configuration, choosing the appropriate one for the current window mode (floating or tiling).

Arguments:

  • <binding> (required): The binding name as defined in your dynamic_bind configuration.

events

Connects to the Hyprland event socket and prints all incoming events to the console. Useful for debugging.

install-config

Copies the default configuration file to the user's config directory, allowing for user-specific customizations.

movefocus <direction>

Move floating window focus by proximity in a given direction with wrapping support.

The algorithm treats floating windows as positioned in a 2D matrix and finds the nearest window in the specified direction. If no window exists in that direction, it wraps around to the opposite side.

Arguments:

  • <direction> Required. Direction to move focus:
    • u - Focus nearest window above (wraps to bottom)
    • d - Focus nearest window below (wraps to top)
    • l - Focus nearest window to the left (wraps to right)
    • r - Focus nearest window to the right (wraps to left)

Behavior:

  • Only considers floating windows on the current workspace
  • Uses window center points for distance calculations
  • Prioritizes windows in the target direction, then falls back to wrapping
  • Secondary sorting by distance for tie-breaking

movemon <direction>

Moves the active window to a different monitor while maintaining its relative position and size.

Arguments:

  • <direction> Required. A number indicating which monitor to move to (+1 for next, -1 for previous).

overview

Toggles a GNOME-style workspace overview, arranging all windows in a grid. Running the command again will exit overview mode.

snap <x0> <x1> <y0> <y1>

Snaps the active window to a fractional portion of the screen.

Arguments:

  • <x0> Required. Left position as a fraction of screen width (e.g., 0.0).
  • <x1> Required. Right position as a fraction of screen width (e.g., 0.5 for half width).
  • <y0> Required. Top position as a fraction of screen height (e.g., 0.0).
  • <y1> Required. Bottom position as a fraction of screen height (e.g., 1.0 for full height).

status

Prints workspaces and current mode, typically for use with Waybar.

togglefloat [on|off]

Switches all windows in the current workspace between floating and tiling layouts.

Arguments:

  • [on|off] Optional. Explicitly set all windows to floating ('on') or tiling ('off'). If omitted, it toggles the current state.

version

Prints the current version of hyprfloat.

workspacegroup <next|prev|status|group|move>

Manages groups of workspaces, useful for multi-monitor setups.

Arguments:

  • <next|prev> Switches to the next or previous workspace group.
  • <status> DEPRECATED: Use hyprctl status instead.
  • <group> Switches to a specific workspace group by number.
  • <move> Presents a UI to move the active window to a different workspace group.

Bindings

Add bindings and rules to your hyprland.conf. Here is an example hyprfloat.conf configuration that you can add:

source = ~/.config/hypr/hyprfloat.conf

Tips and Tricks

Here is a sample configuration that shows how I synchronize workspace changes across my three monitors.

~/.config/hypr/hyprland.conf

monitor=DP-1,1280x1024@75,0x0,1
monitor=DP-3,2560x1440@143,1280x0,1
monitor=HDMI-A-1,1280x1024@75,3840x0,1

# group 1
workspace=1, monitor:DP-1,     persistent:true
workspace=2, monitor:DP-3,     persistent:true
workspace=3, monitor:HDMI-A-1, persistent:true

# group 2
workspace=4, monitor:DP-1,     persistent:true
workspace=5, monitor:DP-3,     persistent:true
workspace=6, monitor:HDMI-A-1, persistent:true

# group 3
workspace=7, monitor:DP-1,     persistent:true
workspace=8, monitor:DP-3,     persistent:true
workspace=9, monitor:HDMI-A-1, persistent:true

~/.config/waybar/config.jsonc

"custom/workspacegroup": {
  "exec": "hyprfloat workspacegroup status",
  "interval": "once",
  "format": "{text}",
  "on-click": "hyprfloat workspacegroup next",
  "tooltip": false,
  "signal": 8
}

~/.config/hypr/hyprfloat.config.lua

workspacegroup = {
    icons = {
        active = "",
        default = "",
    },
    groups = {
        { 1, 2, 3 }, -- monitor 1
        { 4, 5, 6 }, -- monitor 2
        { 7, 8, 9 }, -- monitor 3
    },
    commands = {
        "pkill -RTMIN+8 waybar"
    }
}

About

Hyprland floating window manager and workspace overview utility.

Resources

License

Stars

Watchers

Forks

Packages

No packages published