Skip to content

Commit ac27b7d

Browse files
committed
hypr: set and toggle floating
this got ugly, but there's no documented way to set-floating false. Maybe need to get into the source code.
1 parent 94528e9 commit ac27b7d

File tree

1 file changed

+50
-23
lines changed

1 file changed

+50
-23
lines changed

src/ralphie/hyprland.clj

Lines changed: 50 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
[babashka.process :as process]
66
))
77

8-
(defn hc-raw! [msg]
8+
(defn hc-raw!
99
"fires hyprctl, returns the output"
10+
[msg]
1011
(let [cmd (str "hyprctl " msg)]
1112
(println cmd)
1213
(-> (process/process
@@ -25,8 +26,9 @@
2526
(hc-raw! "--help")
2627
)
2728

28-
(defn hc! [msg]
29+
(defn hc!
2930
"fires hyprctl, returns edn"
31+
[msg]
3032
(-> (hc-raw! (str "-j " msg))
3133
(json/parse-string
3234
(fn [k] (keyword "hypr" k)))))
@@ -37,68 +39,84 @@
3739
(hc-raw! "-j workspaces")
3840
(hc-raw! "help"))
3941

40-
(defn version []
42+
(defn version
4143
"Prints the hyprland version, meaning flags, commit and branch of build."
44+
[]
4245
(hc! "version"))
4346

44-
(defn get-active-window []
47+
(defn get-active-window
4548
"Gets the active window name and its properties"
49+
[]
4650
(hc! "activewindow"))
4751

48-
(defn get-active-workspace []
52+
(defn get-active-workspace
4953
"Gets the active workspace and its properties"
54+
[]
5055
(hc! "activeworkspace"))
5156

52-
(defn get-animations []
57+
(defn get-animations
5358
"Gets the current config'd info about animations and beziers"
59+
[]
5460
(hc! "animations"))
5561

56-
(defn list-binds []
62+
(defn list-binds
5763
"Lists all registered binds"
64+
[]
5865
(hc! "binds"))
5966

60-
(defn list-clients []
67+
(defn list-clients
6168
"Lists all windows with their properties"
69+
[]
6270
(hc! "clients"))
6371

64-
(defn list-config-errors []
72+
(defn list-config-errors
6573
"Lists all current config parsing errors"
74+
[]
6675
(hc! "configerrors"))
6776

68-
(defn get-cursor-pos []
77+
(defn get-cursor-pos
6978
"Gets the current cursor position in global layout coordinates"
79+
[]
7080
(hc! "cursorpos"))
7181

72-
(defn list-decorations [window-regex]
82+
(defn list-decorations
7383
"<window_regex> - Lists all decorations and their info"
84+
[window-regex]
7485
(hc! (str "decorations " window-regex)))
7586

76-
(defn list-devices []
87+
(defn list-devices
7788
"Lists all connected keyboards and mice"
89+
[]
7890
(hc! "devices"))
7991

80-
(defn dismiss-notify [amount]
92+
(defn dismiss-notify
8193
"[amount] - Dismisses all or up to AMOUNT notifications"
94+
[amount]
8295
(hc! (str "dismissnotify " amount)))
8396

84-
(defn issue-dispatch [dispatcher args]
97+
(defn issue-dispatch
8598
" <dispatcher> [args] → Issue a dispatch to call a keybind dispatcher with arguments"
99+
[dispatcher args]
86100
(hc-raw! (str "dispatch " dispatcher " " args)))
87101

88-
(defn get-option [opt]
102+
(defn get-option
89103
"<option> - Gets the config option status (values)"
90-
(hc! "getoption " opt))
104+
[opt]
105+
(hc! (str "getoption " opt)))
91106

92-
(defn list-global-shortcuts []
107+
(defn list-global-shortcuts
93108
"Lists all global shortcuts"
109+
[]
94110
(hc! "globalshortcuts"))
95111

96-
(defn issue-hyprpaper [args]
112+
(defn issue-hyprpaper
97113
"... - Issue a hyprpaper request"
114+
[args]
98115
(hc! (str "hyprpaper " args)))
99116

100-
(defn issue-hyprsunset [args]
117+
(defn issue-hyprsunset
101118
"... - Issue a hyprsunset request"
119+
[args]
102120
(hc! (str "hyprsunset " args)))
103121

104122
(defn list-instances []
@@ -154,8 +172,9 @@ You can exit it with ESCAPE"
154172
(comment
155173
(reload))
156174

157-
(defn rolling-log []
175+
(defn rolling-log
158176
"Prints tail of the log. Also supports -f/--follow option"
177+
[]
159178
(-> (hc-raw! "rollinglog")
160179
(string/split #"\n")))
161180

@@ -222,7 +241,6 @@ You can exit it with ESCAPE"
222241
first))
223242

224243
(comment
225-
(string/strip-right "special:" "special:web")
226244
(->>
227245
(list-workspaces)
228246
(map :hypr/name))
@@ -263,8 +281,17 @@ You can exit it with ESCAPE"
263281
;; floating
264282
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
265283

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))
268295

269296
(defn center-client []
270297
(issue-dispatch "centerwindow" "1"))

0 commit comments

Comments
 (0)