Skip to content

Commit 1435f73

Browse files
committed
ralphie: misc git, hypr clean up
1 parent ac27b7d commit 1435f73

File tree

3 files changed

+73
-31
lines changed

3 files changed

+73
-31
lines changed

src/ralphie/emacs.clj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@
106106
(or (some wsp [:emacs.open/workspace
107107
:workspace/title :org/name :clawe.defs/name])
108108
"ralphie-fallback")
109-
initial-file (some wsp [:emacs.open/file :emacs.open/directory])
109+
initial-file (some wsp [:emacs.open/file :emacs.open/directory
110+
:workspace/initial-file])
110111
initial-file (determine-initial-file initial-file)
111112
elisp-hook (:emacs.open/elisp-hook wsp)
112113
eval-str (str
@@ -116,6 +117,7 @@
116117
(when wsp-name
117118
(str " (russ/open-workspace \"" wsp-name "\") "))
118119
(when initial-file
120+
;; TODO consider a 'daily file' pattern here, even searching to find one
119121
(str " (find-file \"" initial-file "\") " " "))
120122
(when elisp-hook elisp-hook)
121123
" )")]

src/ralphie/git.clj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
(mapcat (fn [home-dir]
4545
(-> (str "~/" home-dir "/*/.git")
4646
zsh/expand
47+
;; BUG this breaks if there are spaces in dir names
4748
(string/split #" "))))
4849
;; remove failed expansions
4950
(remove (fn [path] (string/includes? path "/*/")))))
@@ -321,8 +322,10 @@
321322
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
322323

323324
(defn last-fetch-timestamp [repo-path]
324-
(fs/last-modified-time
325-
(str (zsh/expand repo-path) "/.git/FETCH_HEAD")))
325+
(let [fetch-head-path
326+
(str (zsh/expand repo-path) "/.git/FETCH_HEAD")]
327+
(when (fs/exists? fetch-head-path)
328+
(fs/last-modified-time fetch-head-path))))
326329

327330
(comment
328331
(last-fetch-timestamp "~/russmatney/clawe")

src/ralphie/hyprland.clj

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

8+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9+
;; raw helpers
10+
811
(defn hc-raw!
912
"fires hyprctl, returns the output"
1013
[msg]
@@ -33,26 +36,71 @@
3336
(json/parse-string
3437
(fn [k] (keyword "hypr" k)))))
3538

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

3756
(comment
3857
(hc! "workspaces")
3958
(hc-raw! "-j workspaces")
4059
(hc-raw! "help"))
4160

61+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
62+
;; public api
63+
4264
(defn version
4365
"Prints the hyprland version, meaning flags, commit and branch of build."
4466
[]
4567
(hc! "version"))
4668

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+
4780
(defn get-active-window
4881
"Gets the active window name and its properties"
4982
[]
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
5195

5296
(defn get-active-workspace
5397
"Gets the active workspace and its properties"
5498
[]
55-
(hc! "activeworkspace"))
99+
(->workspace
100+
(hc! "activeworkspace")))
101+
102+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
103+
;; other stuff
56104

57105
(defn get-animations
58106
"Gets the current config'd info about animations and beziers"
@@ -64,11 +112,6 @@
64112
[]
65113
(hc! "binds"))
66114

67-
(defn list-clients
68-
"Lists all windows with their properties"
69-
[]
70-
(hc! "clients"))
71-
72115
(defn list-config-errors
73116
"Lists all current config parsing errors"
74117
[]
@@ -94,11 +137,6 @@
94137
[amount]
95138
(hc! (str "dismissnotify " amount)))
96139

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-
102140
(defn get-option
103141
"<option> - Gets the config option status (values)"
104142
[opt]
@@ -119,39 +157,42 @@
119157
[args]
120158
(hc! (str "hyprsunset " args)))
121159

122-
(defn list-instances []
160+
(defn list-instances
123161
"Lists all running instances of Hyprland with their info"
162+
[]
124163
(hc! "instances"))
125164

126-
(defn issue-keyword [name value]
165+
(defn issue-keyword
127166
" <name> <value> → Issue a keyword to call a config keyword dynamically"
167+
[name value]
128168
(hc! (str "keyword " name " " value)))
129169

130-
(defn issue-kill-mode []
170+
(defn issue-kill-mode
131171
"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+
[]
133174
(hc! "kill"))
134175

135-
(defn list-layers []
176+
(defn list-layers
136177
"Lists all the surface layers"
178+
[]
137179
(hc! "layers"))
138180

139-
(defn list-layouts []
181+
(defn list-layouts
140182
"Lists all layouts available (including plugin'd ones)"
183+
[]
141184
(hc! "layouts"))
142185

143-
(defn list-monitors []
186+
(defn list-monitors
144187
"Lists active outputs with their properties"
188+
[]
145189
(hc! "monitors"))
146190

147-
(defn list-monitors-all []
191+
(defn list-monitors-all
148192
"List all outputs with their properties, both active and inactive"
193+
[]
149194
(hc! "monitors all"))
150195

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-
155196
(comment
156197
(notify "\n\nwhat up \n\n\nfrom deep in HYPRLAND!!!\n\n"))
157198

@@ -202,10 +243,6 @@ You can exit it with ESCAPE"
202243
"Get system info"
203244
(hc-raw! "systeminfo"))
204245

205-
(defn ->workspace [wsp]
206-
(assoc wsp
207-
:hypr/is-special (string/includes? (:hypr/name wsp) "special:")))
208-
209246
(defn list-workspaces []
210247
"Lists all workspaces with their properties"
211248
(->> (hc! "workspaces") (map ->workspace)))

0 commit comments

Comments
 (0)