Skip to content

Instantly share code, notes, and snippets.

@GaussianWonder
Created September 28, 2024 08:22
Show Gist options
  • Save GaussianWonder/be7d080039f501378a82f7494286d92c to your computer and use it in GitHub Desktop.
Save GaussianWonder/be7d080039f501378a82f7494286d92c to your computer and use it in GitHub Desktop.

Revisions

  1. GaussianWonder created this gist Sep 28, 2024.
    97 changes: 97 additions & 0 deletions komorebi.ahk
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,97 @@
    #Requires AutoHotkey v2.0.2
    #SingleInstance Force

    Komorebic(cmd) {
    RunWait(format("komorebic.exe {}", cmd), , "Hide")
    }

    ; Start komorebi if not started already
    if !ProcessExist("komorebi.exe")
    Komorebic("start")

    #q:: Komorebic("close")

    ; Focus windows
    #Left:: Komorebic("focus left")
    #Down:: Komorebic("focus down")
    #Up:: Komorebic("focus up")
    #Right:: Komorebic("focus right")

    #[:: Komorebic("cycle-focus previous")
    #]:: Komorebic("cycle-focus next")

    #^[:: Komorebic("cycle-stack previous")
    #^]:: Komorebic("cycle-stack next")

    ; Move windows
    #+Left:: Komorebic("move left")
    #+Down:: Komorebic("move down")
    #+Up:: Komorebic("move up")
    #+Right:: Komorebic("move right")

    ; Stack windows
    #+^Left:: Komorebic("stack left")
    #+^Down:: Komorebic("stack down")
    #+^Up:: Komorebic("stack up")
    #+^Right:: Komorebic("stack right")
    #^Enter:: Komorebic("unstack")
    #^Left:: Komorebic("cycle-stack previous")
    #^Right:: Komorebic("cycle-stack next")

    ; Resize
    #=:: Komorebic("resize-axis horizontal increase")
    #-:: Komorebic("resize-axis horizontal decrease")
    #+=:: Komorebic("resize-axis vertical increase")
    #+_:: Komorebic("resize-axis vertical decrease")

    ; Manipulate windows
    #f:: Komorebic("toggle-float")
    #m:: Komorebic("toggle-monocle")

    ; Window manager options
    #+r:: Komorebic("retile")
    #p:: Komorebic("toggle-pause")

    ; Layouts
    #x:: Komorebic("flip-layout horizontal")
    #y:: Komorebic("flip-layout vertical")

    #+Enter:: Komorebic("promote")

    ; Workspaces
    #1:: Komorebic("focus-workspace 0")
    #2:: Komorebic("focus-workspace 1")
    #3:: Komorebic("focus-workspace 2")
    #4:: Komorebic("focus-workspace 3")
    #5:: Komorebic("focus-workspace 4")
    #6:: Komorebic("focus-workspace 5")
    #7:: Komorebic("focus-workspace 6")

    ; Move windows across workspaces
    #+1:: Komorebic("move-to-workspace 0")
    #+2:: Komorebic("move-to-workspace 1")
    #+3:: Komorebic("move-to-workspace 2")
    #+4:: Komorebic("move-to-workspace 3")
    #+5:: Komorebic("move-to-workspace 4")
    #+6:: Komorebic("move-to-workspace 5")
    #+7:: Komorebic("move-to-workspace 6")

    ; Page up and down aliases
    ^!Up::PgUp
    ^!Down::PgDn

    ; Applicaton shortcuts

    #Enter:: Run("wt")

    CloseKomorebi(Reason, Code) {
    if Reason != "Logoff" and Reason != "Shutdown" {
    pid := ProcessExist("komorebi.exe")
    if pid {
    ProcessClose(pid)
    }
    }
    return 0
    }

    OnExit(CloseKomorebi)