From 8da8b3ffb823b6f5f6dd529488a0585ea301a835 Mon Sep 17 00:00:00 2001 From: Russell Matney Date: Tue, 17 Nov 2020 11:54:02 -0500 Subject: [PATCH] Add rofi example [skip ci] (#651) Rofi is a linux modal menu for fuzzy filtering, with a similar UX to Alfred or Spotlight on OSX. Borrows quite directly from the fzf example. --- examples/README.md | 14 +++++++++++++- examples/rofi.clj | 12 ++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 examples/rofi.clj diff --git a/examples/README.md b/examples/README.md index 80a44b6b..9e247831 100644 --- a/examples/README.md +++ b/examples/README.md @@ -348,7 +348,7 @@ See [torrent-viewer.clj](torrent-viewer.clj). ### [cprop.clj](cprop.clj) -This script uses [tolitius/cprop](https://github.com/tolitius/cprop) library. +This script uses [tolitius/cprop](https://github.com/tolitius/cprop) library. See [cprop.clj](cprop.clj) @@ -369,3 +369,15 @@ Example usage: ``` shell $ cat src/babashka/main.clj | bb examples/fzf.clj ``` + +### [rofi](rofi.clj) + +Invoke [rofi](https://github.com/davatorium/rofi), a type-to-filter menu on linux, from babashka. + +See [rofi.clj](rofi.clj) + +Example usage: + +``` shell +$ cat src/babashka/main.clj | bb examples/rofi.clj +``` diff --git a/examples/rofi.clj b/examples/rofi.clj new file mode 100644 index 00000000..da7045e6 --- /dev/null +++ b/examples/rofi.clj @@ -0,0 +1,12 @@ +(require '[babashka.process :as p]) + +(defn rofi [s] + (let [proc (p/process + ["rofi" "-i" "-dmenu" "-mesg" "Select" "-sync" "-p" "*"] + {:in s :err :inherit + :out :string})] + (:out @proc))) + +(rofi (slurp *in*)) + +;; `echo "hi\nthere\nclj" | bb examples/rofi.clj`