-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
screenshot.clj
45 lines (40 loc) · 1.32 KB
/
screenshot.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
(ns ralphie.screenshot
(:require
[defthing.defcom :refer [defcom] :as defcom]
[ralphie.rofi :as rofi]
[ralphie.notify :refer [notify]]
[babashka.process :refer [$ check]]))
(defn select-region
"Depends on ~/.local/bin/screenshot-region"
;; TODO refactor to use shotgun + slop directly here
[]
(-> ($ screenshot-region)
check)
(notify "Selected region screenshot captured"))
;; TODO optionally disable transparency before shot
(defn full-screen
"Depends on ~/.local/bin/screenshot
TODO make sure this script reports an error when it fails
and consider moving the script logic into clj
"
;; TODO refactor to use shotgun + slop directly here
[]
(-> ($ screenshot)
check)
(notify "Fullscreen screenshot captured"))
(defcom take-screenshot
{:doctor/depends-on ["screenshot" "screenshot-region"]}
(fn [_cmd & args]
(let [arg (some-> args first)]
(prn "Taking screenshot with arg" arg)
(cond
(= arg "full")
(full-screen)
(= arg "region")
(select-region)
:else
(rofi/rofi {:msg "Full screen or select region?"}
[{:label "full screen"
:on-select (fn [_arg] (full-screen))}
{:label "select region"
:on-select (fn [_arg] (select-region))}])))))