|
5 | 5 | [babashka.process :as process] |
6 | 6 | )) |
7 | 7 |
|
| 8 | +(defn hc-raw! [msg] |
| 9 | + "fires hyprctl, returns the output" |
| 10 | + (let [cmd (str "hyprctl " msg)] |
| 11 | + (-> (process/process {:cmd cmd :out :string}) |
| 12 | + (process/check) |
| 13 | + :out))) |
| 14 | + |
| 15 | +(comment |
| 16 | + (hc-raw! "--help") |
| 17 | + ) |
| 18 | + |
8 | 19 | (defn hc! [msg] |
9 | 20 | "fires hyprctl, returns json" |
10 | | - (let [cmd (str "hyprctl -j " msg)] |
11 | | - (-> (process/process |
12 | | - {:cmd cmd :out :string}) |
13 | | - ;; throws when error occurs |
14 | | - (process/check) |
15 | | - :out |
16 | | - (json/parse-string |
17 | | - (fn [k] (keyword "hypr" k)))))) |
| 21 | + (-> (hc-raw! (str "-j " msg)) |
| 22 | + (json/parse-string |
| 23 | + (fn [k] (keyword "hypr" k))))) |
| 24 | + |
18 | 25 |
|
19 | 26 | (comment |
20 | 27 | (hc! "workspaces") |
21 | | - (hc! "--help") |
22 | | - ) |
| 28 | + (hc-raw! "-j workspaces") |
| 29 | + (hc-raw! "help")) |
| 30 | + |
| 31 | +(defn version [] |
| 32 | + "Prints the hyprland version, meaning flags, commit and branch of build." |
| 33 | + (hc! "version")) |
| 34 | + |
| 35 | +(defn get-active-window [] |
| 36 | + "Gets the active window name and its properties" |
| 37 | + (hc! "activewindow")) |
| 38 | + |
| 39 | +(defn get-active-workspace [] |
| 40 | + "Gets the active workspace and its properties" |
| 41 | + (hc! "activeworkspace")) |
| 42 | + |
| 43 | +(defn get-animations [] |
| 44 | + "Gets the current config'd info about animations and beziers" |
| 45 | + (hc! "animations")) |
| 46 | + |
| 47 | +(defn list-binds [] |
| 48 | + "Lists all registered binds" |
| 49 | + (hc! "binds")) |
| 50 | + |
| 51 | +(defn list-clients [] |
| 52 | + "Lists all windows with their properties" |
| 53 | + (hc! "clients")) |
| 54 | + |
| 55 | +(defn list-config-errors [] |
| 56 | + "Lists all current config parsing errors" |
| 57 | + (hc! "configerrors")) |
| 58 | + |
| 59 | +(defn get-cursor-pos [] |
| 60 | + "Gets the current cursor position in global layout coordinates" |
| 61 | + (hc! "cursorpos")) |
| 62 | + |
| 63 | +(defn list-decorations [window-regex] |
| 64 | + "<window_regex> - Lists all decorations and their info" |
| 65 | + (hc! (str "decorations " window-regex))) |
| 66 | + |
| 67 | +(defn list-devices [] |
| 68 | + "Lists all connected keyboards and mice" |
| 69 | + (hc! "devices")) |
| 70 | + |
| 71 | +(defn dismiss-notify [amount] |
| 72 | + "[amount] - Dismisses all or up to AMOUNT notifications" |
| 73 | + (hc! (str "dismissnotify " amount))) |
| 74 | + |
| 75 | +(defn issue-dispatch [dispatcher args] |
| 76 | + " <dispatcher> [args] → Issue a dispatch to call a keybind dispatcher with arguments" |
| 77 | + (hc! (str "dispatch " dispatcher " " args))) |
| 78 | + |
| 79 | +(defn get-option [opt] |
| 80 | + "<option> - Gets the config option status (values)" |
| 81 | + (hc! "getoption " opt)) |
| 82 | + |
| 83 | +(defn list-global-shortcuts [] |
| 84 | + "Lists all global shortcuts" |
| 85 | + (hc! "globalshortcuts")) |
| 86 | + |
| 87 | +(defn issue-hyprpaper [args] |
| 88 | + "... - Issue a hyprpaper request" |
| 89 | + (hc! (str "hyprpaper " args))) |
| 90 | + |
| 91 | +(defn issue-hyprsunset [args] |
| 92 | + "... - Issue a hyprsunset request" |
| 93 | + (hc! (str "hyprsunset " args))) |
23 | 94 |
|
24 | | -(defn monitors [] |
| 95 | +(defn list-instances [] |
| 96 | + "Lists all running instances of Hyprland with their info" |
| 97 | + (hc! "instances")) |
| 98 | + |
| 99 | +(defn issue-keyword [name value] |
| 100 | + " <name> <value> → Issue a keyword to call a config keyword dynamically" |
| 101 | + (hc! (str "keyword " name " " value))) |
| 102 | + |
| 103 | +(defn issue-kill-mode [] |
| 104 | + "Issue a kill to get into a kill mode, where you can kill an app by clicking on it. |
| 105 | +You can exit it with ESCAPE" |
| 106 | + (hc! "kill")) |
| 107 | + |
| 108 | +(defn list-layers [] |
| 109 | + "Lists all the surface layers" |
| 110 | + (hc! "layers")) |
| 111 | + |
| 112 | +(defn list-layouts [] |
| 113 | + "Lists all layouts available (including plugin'd ones)" |
| 114 | + (hc! "layouts")) |
| 115 | + |
| 116 | +(defn list-monitors [] |
| 117 | + "Lists active outputs with their properties" |
| 118 | + (hc! "monitors")) |
| 119 | + |
| 120 | +(defn list-monitors-all [] |
| 121 | + "List all outputs with their properties, both active and inactive" |
25 | 122 | (hc! "monitors all")) |
26 | 123 |
|
27 | | -(defn workspaces [] |
| 124 | +(defn notify [args] |
| 125 | + "... - Sends a notification using the built-in Hyprland notification system" |
| 126 | + (hc-raw! (str "notify 5 5000 0 " args))) |
| 127 | + |
| 128 | +(comment |
| 129 | + (notify "\n\nwhat up \n\n\nfrom deep in HYPRLAND!!!\n\n")) |
| 130 | + |
| 131 | +(defn output [args] |
| 132 | + "... - Allows you to add and remove fake outputs to your preferred backend" |
| 133 | + (hc! (str "output " args))) |
| 134 | + |
| 135 | +(defn issue-plugin [args] |
| 136 | + "... - Issue a plugin request" |
| 137 | + (hc! (str "plugin " args))) |
| 138 | + |
| 139 | +(defn reload |
| 140 | + " [config-only] → Issue a reload to force reload the config. Pass 'config-only' to disable monitor reload" |
| 141 | + ([] (reload false)) |
| 142 | + ([config-only] |
| 143 | + (hc-raw! (str "reload " (when config-only "config-only"))))) |
| 144 | + |
| 145 | +(comment |
| 146 | + (reload)) |
| 147 | + |
| 148 | +(defn rolling-log [] |
| 149 | + "Prints tail of the log. Also supports -f/--follow option" |
| 150 | + (-> (hc-raw! "rollinglog") |
| 151 | + (string/split #"\n"))) |
| 152 | + |
| 153 | +(defn set-cursor [theme size] |
| 154 | + "<theme> <size> - Sets the cursor theme and reloads the cursor manager" |
| 155 | + (hc! (str "setcursor " theme " " size))) |
| 156 | + |
| 157 | +(defn set-error [color message] |
| 158 | + "<color> <message...> - Sets the hyprctl error string. Color has the same format as in colors in config. Will reset when Hyprland's config is reloaded" |
| 159 | + (hc! (str "seterror " color " " message))) |
| 160 | + |
| 161 | +(defn set-prop [args] |
| 162 | + "... - Sets a window property" |
| 163 | + (hc! (str "setprop" args))) |
| 164 | + |
| 165 | +(defn get-splash [] |
| 166 | + "Get the current splash" |
| 167 | + (hc! "splash")) |
| 168 | + |
| 169 | +(defn switch-xkb-layout [idx] |
| 170 | + "Sets the xkb layout index for a keyboard" |
| 171 | + (hc! (str "switchxkblayout " idx))) |
| 172 | + |
| 173 | +(defn get-system-info [] |
| 174 | + "Get system info" |
| 175 | + (hc-raw! "systeminfo")) |
| 176 | + |
| 177 | +(defn list-workspaces [] |
| 178 | + "Lists all workspaces with their properties" |
28 | 179 | (hc! "workspaces")) |
29 | 180 |
|
30 | | -(defn layers [] |
31 | | - (hc! "layers")) |
| 181 | +(defn list-workspace-rules [] |
| 182 | + "Lists all workspace rules" |
| 183 | + (hc! "workspacerules")) |
0 commit comments