|
5 | 5 | [babashka.process :as process] |
6 | 6 | )) |
7 | 7 |
|
8 | | -(defn hc-raw! [msg] |
| 8 | +(defn hc-raw! |
9 | 9 | "fires hyprctl, returns the output" |
| 10 | + [msg] |
10 | 11 | (let [cmd (str "hyprctl " msg)] |
11 | 12 | (println cmd) |
12 | 13 | (-> (process/process |
|
25 | 26 | (hc-raw! "--help") |
26 | 27 | ) |
27 | 28 |
|
28 | | -(defn hc! [msg] |
| 29 | +(defn hc! |
29 | 30 | "fires hyprctl, returns edn" |
| 31 | + [msg] |
30 | 32 | (-> (hc-raw! (str "-j " msg)) |
31 | 33 | (json/parse-string |
32 | 34 | (fn [k] (keyword "hypr" k))))) |
|
37 | 39 | (hc-raw! "-j workspaces") |
38 | 40 | (hc-raw! "help")) |
39 | 41 |
|
40 | | -(defn version [] |
| 42 | +(defn version |
41 | 43 | "Prints the hyprland version, meaning flags, commit and branch of build." |
| 44 | + [] |
42 | 45 | (hc! "version")) |
43 | 46 |
|
44 | | -(defn get-active-window [] |
| 47 | +(defn get-active-window |
45 | 48 | "Gets the active window name and its properties" |
| 49 | + [] |
46 | 50 | (hc! "activewindow")) |
47 | 51 |
|
48 | | -(defn get-active-workspace [] |
| 52 | +(defn get-active-workspace |
49 | 53 | "Gets the active workspace and its properties" |
| 54 | + [] |
50 | 55 | (hc! "activeworkspace")) |
51 | 56 |
|
52 | | -(defn get-animations [] |
| 57 | +(defn get-animations |
53 | 58 | "Gets the current config'd info about animations and beziers" |
| 59 | + [] |
54 | 60 | (hc! "animations")) |
55 | 61 |
|
56 | | -(defn list-binds [] |
| 62 | +(defn list-binds |
57 | 63 | "Lists all registered binds" |
| 64 | + [] |
58 | 65 | (hc! "binds")) |
59 | 66 |
|
60 | | -(defn list-clients [] |
| 67 | +(defn list-clients |
61 | 68 | "Lists all windows with their properties" |
| 69 | + [] |
62 | 70 | (hc! "clients")) |
63 | 71 |
|
64 | | -(defn list-config-errors [] |
| 72 | +(defn list-config-errors |
65 | 73 | "Lists all current config parsing errors" |
| 74 | + [] |
66 | 75 | (hc! "configerrors")) |
67 | 76 |
|
68 | | -(defn get-cursor-pos [] |
| 77 | +(defn get-cursor-pos |
69 | 78 | "Gets the current cursor position in global layout coordinates" |
| 79 | + [] |
70 | 80 | (hc! "cursorpos")) |
71 | 81 |
|
72 | | -(defn list-decorations [window-regex] |
| 82 | +(defn list-decorations |
73 | 83 | "<window_regex> - Lists all decorations and their info" |
| 84 | + [window-regex] |
74 | 85 | (hc! (str "decorations " window-regex))) |
75 | 86 |
|
76 | | -(defn list-devices [] |
| 87 | +(defn list-devices |
77 | 88 | "Lists all connected keyboards and mice" |
| 89 | + [] |
78 | 90 | (hc! "devices")) |
79 | 91 |
|
80 | | -(defn dismiss-notify [amount] |
| 92 | +(defn dismiss-notify |
81 | 93 | "[amount] - Dismisses all or up to AMOUNT notifications" |
| 94 | + [amount] |
82 | 95 | (hc! (str "dismissnotify " amount))) |
83 | 96 |
|
84 | | -(defn issue-dispatch [dispatcher args] |
| 97 | +(defn issue-dispatch |
85 | 98 | " <dispatcher> [args] → Issue a dispatch to call a keybind dispatcher with arguments" |
| 99 | + [dispatcher args] |
86 | 100 | (hc-raw! (str "dispatch " dispatcher " " args))) |
87 | 101 |
|
88 | | -(defn get-option [opt] |
| 102 | +(defn get-option |
89 | 103 | "<option> - Gets the config option status (values)" |
90 | | - (hc! "getoption " opt)) |
| 104 | + [opt] |
| 105 | + (hc! (str "getoption " opt))) |
91 | 106 |
|
92 | | -(defn list-global-shortcuts [] |
| 107 | +(defn list-global-shortcuts |
93 | 108 | "Lists all global shortcuts" |
| 109 | + [] |
94 | 110 | (hc! "globalshortcuts")) |
95 | 111 |
|
96 | | -(defn issue-hyprpaper [args] |
| 112 | +(defn issue-hyprpaper |
97 | 113 | "... - Issue a hyprpaper request" |
| 114 | + [args] |
98 | 115 | (hc! (str "hyprpaper " args))) |
99 | 116 |
|
100 | | -(defn issue-hyprsunset [args] |
| 117 | +(defn issue-hyprsunset |
101 | 118 | "... - Issue a hyprsunset request" |
| 119 | + [args] |
102 | 120 | (hc! (str "hyprsunset " args))) |
103 | 121 |
|
104 | 122 | (defn list-instances [] |
@@ -154,8 +172,9 @@ You can exit it with ESCAPE" |
154 | 172 | (comment |
155 | 173 | (reload)) |
156 | 174 |
|
157 | | -(defn rolling-log [] |
| 175 | +(defn rolling-log |
158 | 176 | "Prints tail of the log. Also supports -f/--follow option" |
| 177 | + [] |
159 | 178 | (-> (hc-raw! "rollinglog") |
160 | 179 | (string/split #"\n"))) |
161 | 180 |
|
@@ -222,7 +241,6 @@ You can exit it with ESCAPE" |
222 | 241 | first)) |
223 | 242 |
|
224 | 243 | (comment |
225 | | - (string/strip-right "special:" "special:web") |
226 | 244 | (->> |
227 | 245 | (list-workspaces) |
228 | 246 | (map :hypr/name)) |
@@ -263,8 +281,17 @@ You can exit it with ESCAPE" |
263 | 281 | ;; floating |
264 | 282 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
265 | 283 |
|
266 | | -(defn set-floating [] |
267 | | - (issue-dispatch "setfloating" nil)) |
| 284 | +(defn set-floating |
| 285 | + ([] (issue-dispatch "setfloating" nil)) |
| 286 | + ([float?] |
| 287 | + (if float? |
| 288 | + (issue-dispatch "setfloating" nil) |
| 289 | + (do |
| 290 | + (issue-dispatch "setfloating" nil) |
| 291 | + (issue-dispatch "togglefloating" nil))))) |
| 292 | + |
| 293 | +(defn toggle-floating |
| 294 | + [] (issue-dispatch "togglefloating" nil)) |
268 | 295 |
|
269 | 296 | (defn center-client [] |
270 | 297 | (issue-dispatch "centerwindow" "1")) |
|
0 commit comments