# GlazeWM configuration from the IBM DO YOU? article:
# "Making Windows feel more like Linux with GlazeWM"
#
# Before using this file:
# - Check bind_to_monitor values against GlazeWM's monitor numbering.
# - Check process names against the applications installed on your machine.
# - Replace the machine-specific Bitwarden CLI paths near the end of this file.
# - Expect some lwin bindings to overlap shortcuts reserved by Windows or
#   organisational policy. Replace lwin with alt if Windows intercepts them.
#
# The settings are unchanged from the working configuration described in the
# article. These comments have been expanded to make the downloaded copy easier
# to adapt.

general:
  # Commands to run when the WM has started. This is useful for running a
  # script or launching another application.
  # Example: The below command launches Zebar.
  #startup_commands: ['shell-exec zebar']

  # Commands to run just before the WM is shutdown.
  # Example: The below command kills Zebar.
  #shutdown_commands: ['shell-exec taskkill /IM zebar.exe /F']

  # Commands to run after the WM config is reloaded.
  config_reload_commands: []

  # Whether to automatically focus windows underneath the cursor.
  focus_follows_cursor: false

  # Whether to switch back and forth between the previously focused
  # workspace when focusing the current workspace.
  toggle_workspace_on_refocus: false

  cursor_jump:
    # Whether to automatically move the cursor on the specified trigger.
    enabled: false

    # Trigger for cursor jump:
    # - 'monitor_focus': Jump when focus changes between monitors.
    # - 'window_focus': Jump when focus changes between windows.
    trigger: 'monitor_focus'

  # How windows should be hidden when switching workspaces.
  # - 'cloak': (Windows-only) Recommended option for Windows.
  # - 'hide': (Windows-only) Legacy option for Windows. Has stability issues with some apps.
  # - 'place_in_corner': Artificially hides the window by placing it in the corner of the
  #   monitor. On macOS, this is always used instead of cloak/hide.
  hide_method: 'cloak'

  # Affects which windows get shown in the native Windows taskbar. Has no
  # effect if `hide_method: 'hide'`.
  # - 'true': Show all windows (regardless of workspace).
  # - 'false': Only show windows from the currently shown workspaces.
  show_all_in_taskbar: true

gaps:
  # Whether to scale the gaps with the DPI of the monitor.
  scale_with_dpi: true

  # Gap between adjacent windows.
  inner_gap: '3px'

  # Gap between windows and the screen edge.
  outer_gap:
    top: '3px'
    right: '3px'
    bottom: '3px'
    left: '3px'

window_effects:
  # Visual effects to apply to the focused window.
  focused_window:
    # Highlight the window with a colored border.
    # ** Exclusive to Windows 11 due to API limitations.
    border:
      enabled: true
      color: '#8dbcff'

    # Remove the title bar from the window's frame. Note that this can
    # cause rendering issues for some applications.
    hide_title_bar:
      enabled: false

    # Change the corner style of the window's frame.
    # ** Exclusive to Windows 11 due to API limitations.
    corner_style:
      enabled: true
      # Allowed values: 'square', 'rounded', 'small_rounded'.
      style: 'small_rounded'

    # Change the transparency of the window.
    transparency:
      enabled: false
      # Can be something like '95%' or '0.95' for slightly transparent windows.
      # '0' or '0%' is fully transparent (and, by consequence, unfocusable).
      opacity: '95%'

  # Visual effects to apply to non-focused windows.
  other_windows:
    border:
      enabled: true
      color: '#a1a1a1'
    hide_title_bar:
      enabled: false
    corner_style:
      enabled: false
      style: 'square'
    transparency:
      enabled: false
      opacity: '0%'

window_behavior:
  # New windows are created in this state whenever possible.
  # Allowed values: 'tiling', 'floating'.
  initial_state: 'tiling'

  # Sets the default options for when a new window is created. This also
  # changes the defaults for when the state change commands, like
  # `set-floating`, are used without any flags.
  state_defaults:
    floating:
      # Whether to center floating windows by default.
      centered: true

      # Whether to show floating windows as always on top.
      shown_on_top: false

    fullscreen:
      # Maximize the window if possible. If the window doesn't have a
      # maximize button, then it'll be fullscreen'ed normally instead.
      maximized: false

      # Whether to show fullscreen windows as always on top.
      shown_on_top: false

workspaces:
  # Monitor numbers depend on the local display arrangement. In this setup,
  # monitor 0 is the main working display and monitor 1 holds Teams.
  - name: '1'
    display_name: "Shells"
    bind_to_monitor: 0
  - name: '2'
    display_name: "Mail"
    bind_to_monitor: 0
  - name: '3'
    display_name: "Browser"
    bind_to_monitor: 0
  - name: '4'
    display_name: "IDEs"
    bind_to_monitor: 0
  - name: '5'
    display_name: "Misc"
    bind_to_monitor: 0
  - name: '6'
    display_name: "SQL Clients"
    bind_to_monitor: 0
  - name: '7'
    display_name: "Office"
    bind_to_monitor: 0
  - name: '8'
    display_name: "Remote Desktops"
    bind_to_monitor: 0
  - name: '9'
    display_name: "Password Managers"
    bind_to_monitor: 0
  - name: '0'
    display_name: "Teams"
    bind_to_monitor: 1

window_rules:
  # Leave overlays, application dialogs, and remote desktop windows under
  # native Windows control instead of attempting to tile them.
  - commands: ['ignore']
    match:
      # Ignores any Zebar windows.
      - window_process: { equals: 'zebar' }

      # Ignores picture-in-picture windows for browsers.
      - window_title: { regex: '[Pp]icture.in.[Pp]icture' }
        window_class: { regex: 'Chrome_WidgetWin_1|MozillaDialogClass' }

      # Ignore rules for various 3rd-party apps.
      - window_process: { equals: 'PowerToys' }
        window_class: { regex: 'HwndWrapper\[PowerToys\.PowerAccent.*?\]' }
      - window_title: { equals: 'Command Palette' }
        window_class: { equals: 'WinUIDesktopWin32WindowClass' }
      - window_process: { equals: 'PowerToys' }
        window_title: { regex: '.*? - Peek' }
      - window_process: { equals: 'Lively' }
        window_class: { regex: 'HwndWrapper' }
      - window_process: { equals: 'EXCEL' }
        window_class: { not_regex: 'XLMAIN' }
      - window_process: { equals: 'WINWORD' }
        window_class: { not_regex: 'OpusApp' }
      - window_process: { equals: 'POWERPNT' }
        window_class: { not_regex: 'PPTFrameClass' }
      - window_process: { equals: 'msrdc' }
      - window_process: { equals: 'bomgar-acc' }

  # Route application windows to predictable workspaces when they open.
  # Update these process names if an application changes its executable name.
  - commands: ['set-tiling', 'move --workspace 1']
    match:
      - window_process: { equals: 'WindowsTerminal' }

  - commands: ['set-tiling', 'move --workspace 2']
    match:
      - window_process: { equals: 'olk' }

  - commands: ['set-tiling', 'move --workspace 3']
    match:
      - window_process: { equals: 'firefox' }

  - commands: ['set-tiling', 'move --workspace 4']
    match:
      - window_process: { equals: 'Code' }

  - commands: ['set-tiling', 'move --workspace 6']
    match:
      - window_process: { equals: 'dbeaver' }

  - commands: ['set-tiling', 'move --workspace 7']
    match:
      - window_process: { equals: 'WINWORD' }
      - window_process: { equals: 'EXCEL' }

  - commands: ['set-tiling', 'move --workspace 9']
    match:
      - window_process: { equals: 'Bitwarden' }
      - window_process: { equals: 'Keeper' }

  - commands: ['set-tiling', 'move --workspace 0']
    match:
      - window_process: { equals: 'ms-teams' }

binding_modes:
  # This resize mode is defined but is not currently activated by a main
  # keybinding. Add `wm-enable-binding-mode --name resize` under `keybindings`
  # and uncomment the exit binding below if you want to use it.
  - name: 'resize'
    keybindings:
      - commands: ['resize --width -2%']
        bindings: ['h', 'left']
      - commands: ['resize --width +2%']
        bindings: ['l', 'right']
      - commands: ['resize --height +2%']
        bindings: ['k', 'up']
      - commands: ['resize --height -2%']
        bindings: ['j', 'down']
      # Press enter/escape to return to default keybindings.
      # - commands: ['wm-disable-binding-mode --name resize']
      #   bindings: ['escape', 'enter']

keybindings:
  # lwin acts as a Linux-style Super key in this setup. Windows reserves some
  # Win-key combinations, including Win+L, so use alt if a binding is intercepted.

  # Apps
  - commands: ['shell-exec wt']
    bindings: ['lwin+enter']

  - commands: ['shell-exec olk']
    bindings: ['lwin+shift+e']

  - commands: ['wm-redraw']
    bindings: ['lwin+alt+r']

  - commands: ['shell-exec rundll32.exe user32.dll,LockWorkStation']
    bindings: ['lwin+o']

  - commands: ['shell-exec firefox']
    bindings: ['lwin+b']

  - commands: ['shell-exec code']
    bindings: ['lwin+e']

  - commands: ['shell-exec dbeaver']
    bindings: ['lwin+d']

  - commands: ['shell-exec remmina']
    bindings: ['lwin+r']

  - commands: ['shell-exec explorer.exe']
    bindings: ['lwin+shift+f']

  # GlazeWM control
  - commands: ['wm-reload-config']
    bindings: ['lwin+escape']

  - commands: ['wm-exit']
    bindings: ['lwin+alt+q']

  # Close window
  - commands: ['close']
    bindings: ['lwin+w', 'lwin+shift+w']

  # Focus windows
  - commands: ['focus --direction left']
    bindings: ['lwin+alt+h']

  - commands: ['focus --direction down']
    bindings: ['lwin+alt+j']

  - commands: ['focus --direction up']
    bindings: ['lwin+alt+k']

  - commands: ['focus --direction right']
    bindings: ['lwin+alt+l']

  - commands: ['focus --next-active-workspace']
    bindings: ['lwin+c']

  - commands: ['focus --prev-active-workspace']
    bindings: ['lwin+shift+c']

  # Generate a 25-character password with the Bitwarden CLI and copy it to the
  # clipboard. These commands contain a machine-specific WinGet package path.
  # Replace the path below, or put bw.exe on PATH and call `bw` directly.
  - commands: ['shell-exec cmd.exe /c start "" /min cmd.exe /c ""C:/Users/ChrisBrown/AppData/Local/Microsoft/WinGet/Packages/Bitwarden.CLI_Microsoft.Winget.Source_8wekyb3d8bbwe/bw.exe" generate --length 25 --uppercase --lowercase --number --special | clip""']
    bindings: ["lwin+ctrl+shift+9"]

  - commands: ['shell-exec cmd.exe /c start "" /min cmd.exe /c ""C:/Users/ChrisBrown/AppData/Local/Microsoft/WinGet/Packages/Bitwarden.CLI_Microsoft.Winget.Source_8wekyb3d8bbwe/bw.exe" generate --length 25 --uppercase --lowercase --number | clip""']
    bindings: ["lwin+ctrl+shift+8"]

  # Move windows
  - commands: ['move --direction left']
    bindings: ['lwin+shift+h']

  - commands: ['move --direction down']
    bindings: ['lwin+shift+j']

  - commands: ['move --direction up']
    bindings: ['lwin+shift+k']

  - commands: ['move --direction right']
    bindings: ['lwin+shift+l']

  # Layout / state
  - commands: ['toggle-tiling']
    bindings: ['lwin+t']

  - commands: ['toggle-floating --centered']
    bindings: ['lwin+s']

  - commands: ['toggle-fullscreen']
    bindings: ['lwin+f', 'lwin+shift+t']

  - commands: ['toggle-tiling-direction']
    bindings: ['lwin+m']

  - commands: ['toggle-minimized']
    bindings: ['lwin+x']

  # Resize windows. Ctrl distinguishes these from the Alt-based focus bindings.
  - commands: ['resize --width -2%']
    bindings: ['lwin+ctrl+h']

  - commands: ['resize --height +2%']
    bindings: ['lwin+ctrl+j']

  - commands: ['resize --height -2%']
    bindings: ['lwin+ctrl+k']

  - commands: ['resize --width +2%']
    bindings: ['lwin+ctrl+l']

  # Workspaces
  - commands: ['focus --workspace 1']
    bindings: ['lwin+1']
  - commands: ['focus --workspace 2']
    bindings: ['lwin+2']
  - commands: ['focus --workspace 3']
    bindings: ['lwin+3']
  - commands: ['focus --workspace 4']
    bindings: ['lwin+4']
  - commands: ['focus --workspace 5']
    bindings: ['lwin+5']
  - commands: ['focus --workspace 6']
    bindings: ['lwin+6']
  - commands: ['focus --workspace 7']
    bindings: ['lwin+7']
  - commands: ['focus --workspace 8']
    bindings: ['lwin+8']
  - commands: ['focus --workspace 9']
    bindings: ['lwin+9']
  - commands: ['focus --workspace 0']
    bindings: ['lwin+0']

  - commands: ['move --workspace 1', 'focus --workspace 1']
    bindings: ['lwin+shift+1']
  - commands: ['move --workspace 2', 'focus --workspace 2']
    bindings: ['lwin+shift+2']
  - commands: ['move --workspace 3', 'focus --workspace 3']
    bindings: ['lwin+shift+3']
  - commands: ['move --workspace 4', 'focus --workspace 4']
    bindings: ['lwin+shift+4']
  - commands: ['move --workspace 5', 'focus --workspace 5']
    bindings: ['lwin+shift+5']
  - commands: ['move --workspace 6', 'focus --workspace 6']
    bindings: ['lwin+shift+6']
  - commands: ['move --workspace 7', 'focus --workspace 7']
    bindings: ['lwin+shift+7']
  - commands: ['move --workspace 8', 'focus --workspace 8']
    bindings: ['lwin+shift+8']
  - commands: ['move --workspace 9', 'focus --workspace 9']
    bindings: ['lwin+shift+9']
  - commands: ['move --workspace 0', 'focus --workspace 0']
    bindings: ['lwin+shift+0']
