Last active
June 8, 2026 10:29
-
-
Save pepe/160ae0998bebd8d27694c59789f5ea1a to your computer and use it in GitHub Desktop.
jwno config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (import jwno/auto-layout) | |
| (import jwno/indicator) | |
| (import jwno/util) | |
| (import jwno/log) | |
| (import jwno/scratch-pad) | |
| (import jwno/ui-hint) | |
| (def dir-keys | |
| "Direction keys for all the other mappings" | |
| {:left "u" | |
| :down "j" | |
| :up "k" | |
| :right "i"}) | |
| (def {:key-manager key-man | |
| :command-manager command-man | |
| :window-manager window-man | |
| :ui-manager ui-man | |
| :hook-manager hook-man | |
| :repl-manager repl-man} | |
| "Define all the managers." | |
| jwno/context) | |
| (def repl-server | |
| "Define repl server" | |
| (or (:get-default-server repl-man) | |
| (:start-server repl-man))) | |
| (util/export-to-repl repl-server window-man) | |
| (defn move-window-after-split | |
| ``` | |
| Move the activated window into the new empty frame, | |
| and activate (move focus to) that frame. | |
| ``` | |
| [frame] | |
| (def all-sub-frames (in frame :children)) | |
| (def all-wins (in (first all-sub-frames) :children)) | |
| (def move-to-frame (in all-sub-frames 1)) | |
| (when (>= (length all-wins) 2) | |
| (:add-child move-to-frame (:get-current-window frame))) | |
| (:activate move-to-frame)) | |
| (defn match-exe-name | |
| "Matches the windows exe to `exe-name`." | |
| [exe-name] | |
| (fn [win] | |
| (def win-exe (:get-exe-path win)) | |
| (string/has-suffix? (string "\\" exe-name) win-exe))) | |
| (defmacro defkeymap | |
| ``` | |
| Convenience macro for defining multiple keys in keymap. | |
| If `transient` is true, `:pop-keymap` is added for enter and esc. | |
| ``` | |
| [key-man keypairs &opt transient] | |
| (with-syms [keymap key-seq cmd docs] | |
| ~(let [,keymap (:new-keymap ,key-man)] | |
| (loop [[,key-seq ,cmd ,docs] :in ,keypairs] | |
| (:define-key ,keymap ,key-seq ,cmd ,docs)) | |
| ,(when transient | |
| ~(do | |
| (:define-key ,keymap "enter" :pop-keymap "Cancel") | |
| (:define-key ,keymap "esc" :pop-keymap "Cancel"))) | |
| ,keymap))) | |
| (def resize-mode-keymap | |
| "A transient key map for resizing frames." | |
| (defkeymap key-man | |
| [[(in dir-keys :down) [:resize-frame 0 -100] "Make window lower"] | |
| [(in dir-keys :up) [:resize-frame 0 100] "Make window taller"] | |
| [(in dir-keys :left) [:resize-frame -100 0] "Make window narrower"] | |
| [(in dir-keys :right) [:resize-frame 100 0] "Make window wider"] | |
| ["=" :balance-frames "Balance windows"] | |
| [";" [:zoom-in 0.7] "Zoom in"] | |
| ["shift + ;" [:zoom-in 0.3]] "Zoom out"] | |
| true)) | |
| (def yank-mode-keymap | |
| "A transient key map for moving windows around." | |
| (defkeymap key-man | |
| (seq [[cmd key] :pairs dir-keys] | |
| [key [:move-window cmd] (string "Move window " cmd)]) | |
| true)) | |
| (def adjacent-move-arr | |
| "A keys for moving windows around and moving in frames." | |
| (let [res (array/new 8)] | |
| (loop [[cmd key] :pairs dir-keys] | |
| (array/push res | |
| [(string "win + ctrl + " key) [:adjacent-frame cmd] | |
| (string "Move to " cmd " frame")] | |
| [(string "win + shift + " key) [:move-window cmd] | |
| (string "Move window " cmd)])) | |
| res)) | |
| (def window-mode-keymap | |
| "Transient keymap for window manipulation" | |
| (defkeymap key-man | |
| [["d" :describe-window "Describe window"] | |
| ["m" :manage-window "Manage window"] | |
| ["i" :ignore-window "Ignore window"]] | |
| true)) | |
| (def scratch-pad | |
| "Use the scratch pad" | |
| (scratch-pad/scratch-pad jwno/context)) | |
| (put scratch-pad :rect {:left 400 :top 200 :right 2500 :bottom 1500}) | |
| (:enable scratch-pad) | |
| (def ui-hint (ui-hint/ui-hint jwno/context)) | |
| (:enable ui-hint) | |
| (def hint-key-list "fjdksleiwocmxz") | |
| (def apps | |
| "Apps configuration" | |
| {"t" ["wt.exe" "Window terminal"] | |
| "f" ["firefox.exe" "Mozilla Firefox"] | |
| "i" ["inkscape.exe" "Inkscape"] | |
| "s" ["Steam.exe" "Steam"] | |
| "e" ["explorer.exe" "Explorer"]}) | |
| (def webs | |
| "Web configuration" | |
| {"b" ["https://builds.sr.ht" "SRHT builds"] | |
| "c" ["https://chatgpt.com" "ChatGPT"] | |
| "g" ["https://github.com" "GitHub"] | |
| "j" ["https://janet-lang.org/api/index.html" | |
| "Janet Core API"] | |
| "m" ["https://www.facebook.com/messages" "Messenger"] | |
| "t" ["https://track.pospisil.work" "Track"]}) | |
| (def remotes | |
| "Remotes configuration" | |
| {"p" ["ppe" "pacts.pan.earth"] | |
| "t" ["tpw" "track.pospisil.work"]}) | |
| (def directories | |
| "Directories configuration" | |
| {"b" "bin" | |
| "c" "code" | |
| "j h" "code\\jhydro" | |
| "j j" "code\\janet" | |
| "j l" "code\\simple-janet-lsp" | |
| "j s" "code\\spork" | |
| "p e" "code\\pan.earth" | |
| "p w" "code\\bow" | |
| "p i" "code\\interstudy" | |
| "p g" "code\\gp" | |
| "p m" "code\\metabolon" | |
| "p p" "code\\pacts" | |
| "p n" "code\\not-only.work" | |
| "p s" "code\\mppm.studio"}) | |
| (def open-apps | |
| "Adds keybindings for apps" | |
| (seq [[k [e n]] :pairs apps] | |
| [(string "app " k) [:exec true e] (string "Run " n)])) | |
| (def open-webs-tab | |
| "Adds keybinding for webs in tabs" | |
| (seq [[k [w n]] :pairs webs] | |
| [(string "win + alt + enter " k) | |
| [:exec true "firefox.exe" "-new-tab" w] | |
| (string "Open web " n " in new tab")])) | |
| (def open-webs-win | |
| "Adds keybinding for webs in wins" | |
| (seq [[k [w n]] :pairs webs] | |
| [(string "win + alt + shift + enter " k) | |
| [:exec true "firefox.exe" "-new-window" w] | |
| (string "Open web " n)])) | |
| (defn wt | |
| "Construct tuple for executing wt.exe with commands." | |
| [profile dir & cmd] | |
| [:exec true "wt.exe" "-p" profile "-d" dir ;cmd]) | |
| (def home "Home dir" "\\Users\\josef\\") | |
| (def open-terminals | |
| "Adds keybinding for running the terminal" | |
| (seq [[k p] :pairs directories] | |
| [(string "win + shift + enter " k) | |
| (wt "PowerShell" (string home p)) | |
| (string "Open terminal in ~\\" p)])) | |
| (def open-helix | |
| "Adds keybinding for running the helix" | |
| (seq [[k p] :pairs directories] | |
| [(string "win + ctrl + enter " k) | |
| (wt "helix" (string home p) "hx") | |
| (string "Open helix in ~\\" p)])) | |
| (def open-remotes | |
| "Adds keybinding for running the terminal" | |
| (seq [[k [p n]] :pairs remotes] | |
| [(string "win + o " k) | |
| (wt p home) | |
| (string "Open remote " n)])) | |
| (:add-command | |
| (in jwno/context :command-manager) :enum-frame-and-zoom-in | |
| (fn [dir] | |
| (def last-fr (:get-current-frame (get-in jwno/context [:window-manager :root]))) | |
| (def rev-dir | |
| (case dir | |
| :next :prev | |
| :prev :next)) | |
| (:add-oneshot-hook (in jwno/context :hook-manager) :frame-activated | |
| (fn [frame] | |
| (when (= last-fr (:enumerate-node (:get-layout frame) frame rev-dir)) | |
| (:call-command (in jwno/context :command-manager) :zoom-in 0.7)))) | |
| (:call-command (in jwno/context :command-manager) :enum-frame dir))) | |
| (def root-keymap | |
| "Complete keymap with all the parts" | |
| (defkeymap key-man | |
| [["win + shift + /" :show-root-keymap "Show root keymap"] | |
| ["win + shift + q" :quit "Quit"] | |
| ["win + enter" (wt "PowerShell" home)] | |
| ;open-apps | |
| ;open-webs-tab | |
| ;open-webs-win | |
| ;open-terminals | |
| ;open-helix | |
| ;open-remotes | |
| ["win + shift + r" [:repl true "127.0.0.1" 9999] "Connect repl"] | |
| ["win + r" :retile "Retile"] | |
| ["win + shift + c" :close-window-or-frame "Close window or frame"] | |
| ["win + ctrl + f" :flatten-parent "Flatten parent"] | |
| ["win + ," [:split-frame :horizontal 2 [0.5] move-window-after-split] | |
| "Horizontal split"] | |
| ["win + ." [:split-frame :vertical 2 [0.5] move-window-after-split] | |
| "Vertical split"] | |
| ["win + =" :balance-frames "Balance frames"] | |
| ["win + ;" [:zoom-in 0.7] "Zoom in"] | |
| ["win + shift + ;" [:zoom-in 0.3] "Zoom out"] | |
| ["win + f" :fill-monitor "File monitor"] | |
| ["win + shift + p" :cascade-windows-in-frame "Cascade windows in frame"] | |
| [(string "win + alt + " (in dir-keys :down)) [:enum-frame-and-zoom-in :prev]] | |
| [(string "win + alt + " (in dir-keys :up)) [:enum-frame-and-zoom-in :next]] | |
| [(string "win + " (in dir-keys :down)) [:enum-frame :prev] "Previous frame"] | |
| [(string "win + " (in dir-keys :up)) [:enum-frame :next] "Next frame"] | |
| [(string "win + " (in dir-keys :left)) [:enum-window-in-frame :prev] "Previous window in frame"] | |
| [(string "win + " (in dir-keys :right)) [:enum-window-in-frame :next] "Next window in frame"] | |
| ;adjacent-move-arr | |
| ["win + w" [:push-keymap window-mode-keymap] "Window transient"] | |
| ["win + s" [:push-keymap resize-mode-keymap] "Resize transient"] | |
| ["win + y" [:push-keymap yank-mode-keymap] "Yank transient"] | |
| ["win + h" :toggle-scratch-pad "Toggle scratch pad"] | |
| ["win + shift + h" :add-to-scratch-pad "Add current window to scratch pad"] | |
| ["win + ctrl + shift + h" :remmove-from-scratch-pad "Add current window to scratch pad"] | |
| ["win + backspace" [:ui-hint hint-key-list (ui-hint/gradual-uia-hinter :show-highlights true)] "Show all interactable elements"] | |
| ["win + shift + backspace" [:ui-hint "fjdksleiwocmxz" (ui-hint/uia-hinter)]]])) | |
| (:set-keymap key-man root-keymap) | |
| (def auto-close-empty-frame | |
| "Check for empty frames and close them, when a window is removed." | |
| (auto-layout/close-empty-frame jwno/context)) | |
| (:enable auto-close-empty-frame) | |
| (def current-frame-area | |
| "Highlights an empty active frame by drawing a rectangle in it. " | |
| (indicator/current-frame-area jwno/context)) | |
| (put current-frame-area :margin 1) | |
| (:enable current-frame-area) | |
| (def current-frame-tooltip | |
| "Use the current-frame-tooltip object" | |
| (indicator/current-frame-tooltip jwno/context)) | |
| (:enable current-frame-tooltip) | |
| (:add-hook hook-man :window-created | |
| (fn [win uia-win _exe-path _desktop-info] | |
| (put (in win :tags) :anchor :center) | |
| (put (in win :tags) :margin 1) | |
| (def class-name (:get_CachedClassName uia-win)) | |
| (if (= "#32770" class-name) # Dialog window class | |
| (put (in win :tags) :no-expand true)))) | |
| (:add-hook hook-man :monitor-updated | |
| (fn [frame] | |
| (put (in frame :tags) :padding 1))) | |
| (:add-command command-man :fill-monitor | |
| (fn [] | |
| (def cur-win (:get-current-window (in window-man :root))) | |
| (when cur-win | |
| (def cur-frame (in cur-win :parent)) | |
| (def mon-frame (:get-top-frame cur-frame)) | |
| (def rect (:get-padded-rect mon-frame)) | |
| (:transform cur-win rect))) | |
| ``` | |
| (:fill-monitor) | |
| Resizes the focused window, so that it fills the whole work | |
| area of the current monitor. | |
| ```) | |
| (:add-command command-man :show-root-keymap | |
| (fn [] | |
| (:show-tooltip | |
| ui-man | |
| :show-root-keymap | |
| (:format root-keymap) | |
| nil | |
| nil | |
| 10000 | |
| :center)) | |
| ``` | |
| (:show-root-keymap) | |
| Shows the root keymap defined in the config file. | |
| ```) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment