|
5 | 5 | [babashka.process :as process] |
6 | 6 | )) |
7 | 7 |
|
| 8 | +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 9 | +;; raw helpers |
| 10 | + |
8 | 11 | (defn hc-raw! |
9 | 12 | "fires hyprctl, returns the output" |
10 | 13 | [msg] |
|
33 | 36 | (json/parse-string |
34 | 37 | (fn [k] (keyword "hypr" k))))) |
35 | 38 |
|
| 39 | +(defn issue-dispatch |
| 40 | + " <dispatcher> [args] → Issue a dispatch to call a keybind dispatcher with arguments" |
| 41 | + [dispatcher args] |
| 42 | + (hc-raw! (str "dispatch " dispatcher " " args))) |
| 43 | + |
| 44 | +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 45 | +;; models |
| 46 | + |
| 47 | +(defn ->workspace [wsp] |
| 48 | + (assoc wsp |
| 49 | + :special? (string/includes? (:hypr/name wsp) "special:"))) |
| 50 | + |
| 51 | +(defn ->client [cli] |
| 52 | + (assoc cli |
| 53 | + :workspace-name (-> cli :hypr/workspace :hypr/name) |
| 54 | + :workspace-id (-> cli :hypr/workspace :hypr/id))) |
36 | 55 |
|
37 | 56 | (comment |
38 | 57 | (hc! "workspaces") |
39 | 58 | (hc-raw! "-j workspaces") |
40 | 59 | (hc-raw! "help")) |
41 | 60 |
|
| 61 | +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 62 | +;; public api |
| 63 | + |
42 | 64 | (defn version |
43 | 65 | "Prints the hyprland version, meaning flags, commit and branch of build." |
44 | 66 | [] |
45 | 67 | (hc! "version")) |
46 | 68 |
|
| 69 | +(defn notify |
| 70 | + "... - Sends a notification using the built-in Hyprland notification system" |
| 71 | + [args] |
| 72 | + (hc-raw! (str "notify 5 5000 0 " args))) |
| 73 | + |
| 74 | +(comment |
| 75 | + (notify "hi")) |
| 76 | + |
| 77 | +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 78 | +;; clients/windows |
| 79 | + |
47 | 80 | (defn get-active-window |
48 | 81 | "Gets the active window name and its properties" |
49 | 82 | [] |
50 | | - (hc! "activewindow")) |
| 83 | + (->client |
| 84 | + (hc! "activewindow"))) |
| 85 | + |
| 86 | +(defn list-clients |
| 87 | + "Lists all windows with their properties" |
| 88 | + [] |
| 89 | + (->> |
| 90 | + (hc! "clients") |
| 91 | + (map ->client))) |
| 92 | + |
| 93 | +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 94 | +;; workspaces |
51 | 95 |
|
52 | 96 | (defn get-active-workspace |
53 | 97 | "Gets the active workspace and its properties" |
54 | 98 | [] |
55 | | - (hc! "activeworkspace")) |
| 99 | + (->workspace |
| 100 | + (hc! "activeworkspace"))) |
| 101 | + |
| 102 | +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 103 | +;; other stuff |
56 | 104 |
|
57 | 105 | (defn get-animations |
58 | 106 | "Gets the current config'd info about animations and beziers" |
|
64 | 112 | [] |
65 | 113 | (hc! "binds")) |
66 | 114 |
|
67 | | -(defn list-clients |
68 | | - "Lists all windows with their properties" |
69 | | - [] |
70 | | - (hc! "clients")) |
71 | | - |
72 | 115 | (defn list-config-errors |
73 | 116 | "Lists all current config parsing errors" |
74 | 117 | [] |
|
94 | 137 | [amount] |
95 | 138 | (hc! (str "dismissnotify " amount))) |
96 | 139 |
|
97 | | -(defn issue-dispatch |
98 | | - " <dispatcher> [args] → Issue a dispatch to call a keybind dispatcher with arguments" |
99 | | - [dispatcher args] |
100 | | - (hc-raw! (str "dispatch " dispatcher " " args))) |
101 | | - |
102 | 140 | (defn get-option |
103 | 141 | "<option> - Gets the config option status (values)" |
104 | 142 | [opt] |
|
119 | 157 | [args] |
120 | 158 | (hc! (str "hyprsunset " args))) |
121 | 159 |
|
122 | | -(defn list-instances [] |
| 160 | +(defn list-instances |
123 | 161 | "Lists all running instances of Hyprland with their info" |
| 162 | + [] |
124 | 163 | (hc! "instances")) |
125 | 164 |
|
126 | | -(defn issue-keyword [name value] |
| 165 | +(defn issue-keyword |
127 | 166 | " <name> <value> → Issue a keyword to call a config keyword dynamically" |
| 167 | + [name value] |
128 | 168 | (hc! (str "keyword " name " " value))) |
129 | 169 |
|
130 | | -(defn issue-kill-mode [] |
| 170 | +(defn issue-kill-mode |
131 | 171 | "Issue a kill to get into a kill mode, where you can kill an app by clicking on it. |
132 | | -You can exit it with ESCAPE" |
| 172 | + You can exit it with ESCAPE" |
| 173 | + [] |
133 | 174 | (hc! "kill")) |
134 | 175 |
|
135 | | -(defn list-layers [] |
| 176 | +(defn list-layers |
136 | 177 | "Lists all the surface layers" |
| 178 | + [] |
137 | 179 | (hc! "layers")) |
138 | 180 |
|
139 | | -(defn list-layouts [] |
| 181 | +(defn list-layouts |
140 | 182 | "Lists all layouts available (including plugin'd ones)" |
| 183 | + [] |
141 | 184 | (hc! "layouts")) |
142 | 185 |
|
143 | | -(defn list-monitors [] |
| 186 | +(defn list-monitors |
144 | 187 | "Lists active outputs with their properties" |
| 188 | + [] |
145 | 189 | (hc! "monitors")) |
146 | 190 |
|
147 | | -(defn list-monitors-all [] |
| 191 | +(defn list-monitors-all |
148 | 192 | "List all outputs with their properties, both active and inactive" |
| 193 | + [] |
149 | 194 | (hc! "monitors all")) |
150 | 195 |
|
151 | | -(defn notify [args] |
152 | | - "... - Sends a notification using the built-in Hyprland notification system" |
153 | | - (hc-raw! (str "notify 5 5000 0 " args))) |
154 | | - |
155 | 196 | (comment |
156 | 197 | (notify "\n\nwhat up \n\n\nfrom deep in HYPRLAND!!!\n\n")) |
157 | 198 |
|
@@ -202,10 +243,6 @@ You can exit it with ESCAPE" |
202 | 243 | "Get system info" |
203 | 244 | (hc-raw! "systeminfo")) |
204 | 245 |
|
205 | | -(defn ->workspace [wsp] |
206 | | - (assoc wsp |
207 | | - :hypr/is-special (string/includes? (:hypr/name wsp) "special:"))) |
208 | | - |
209 | 246 | (defn list-workspaces [] |
210 | 247 | "Lists all workspaces with their properties" |
211 | 248 | (->> (hc! "workspaces") (map ->workspace))) |
|
0 commit comments