-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
init: create basic sources with readme
- codes imported from rinx/dotfiles https://github.com/rinx/dotfiles/tree/60709726b7c2986de228e04f20e0c596ef4e1d8b/macos/sketchybar/rc Signed-off-by: Rintaro Okamura <rintaro.okamura@gmail.com>
- Loading branch information
0 parents
commit 3da21a0
Showing
8 changed files
with
212 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Run tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
paths: | ||
- ".github/workflows/test.yaml" | ||
- "src/**" | ||
- "test/**" | ||
- "bb.edn" | ||
- "deps.edn" | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Java | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: "temurin" | ||
java-version: "21" | ||
- name: Setup Clojure | ||
uses: DeLaGuardo/setup-clojure@12.5 | ||
with: | ||
cli: "latest" | ||
bb: "latest" | ||
- name: Run JVM tests | ||
run: | | ||
bb test:clj | ||
- name: Run bb tests | ||
run: | | ||
bb test:bb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/.clj-kondo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# sbar-bb | ||
|
||
Write your [SketchyBar](https://github.com/FelixKratz/SketchyBar) config in Babashka script. | ||
|
||
## Usage | ||
|
||
TBW | ||
|
||
## API | ||
|
||
TBW | ||
|
||
## Example | ||
|
||
TBW | ||
|
||
[rinx/dotfiles: macos/sketchybar](https://github.com/rinx/dotfiles/tree/60709726b7c2986de228e04f20e0c596ef4e1d8b/macos/sketchybar) will be re-written by using this module. | ||
|
||
## Similar Projects | ||
|
||
- [FelixKratz/SbarLua](https://github.com/FelixKratz/SbarLua) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
This is free and unencumbered software released into the public domain. | ||
|
||
Anyone is free to copy, modify, publish, use, compile, sell, or | ||
distribute this software, either in source code form or as a compiled | ||
binary, for any purpose, commercial or non-commercial, and by any | ||
means. | ||
|
||
In jurisdictions that recognize copyright laws, the author or authors | ||
of this software dedicate any and all copyright interest in the | ||
software to the public domain. We make this dedication for the benefit | ||
of the public at large and to the detriment of our heirs and | ||
successors. We intend this dedication to be an overt act of | ||
relinquishment in perpetuity of all present and future rights to this | ||
software under copyright law. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
For more information, please refer to <http://unlicense.org> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{:paths ["src"] | ||
|
||
:deps {io.github.rinx/sbar-bb {:local/root "."}} | ||
:tasks {test:clj (shell "clojure -X:test") | ||
test:bb {:extra-paths ["test"] | ||
:extra-deps {io.github.cognitect-labs/test-runner | ||
{:git/tag "v0.5.1" :git/sha "dfb30dd"}} | ||
:task (exec 'cognitect.test-runner.api/test)} | ||
dev (clojure "-M:dev -m nrepl.cmdline --middleware [cider.nrepl/cider-middleware]")}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{:deps {babashka/process {:mvn/version "0.5.22"} | ||
camel-snake-kebab/camel-snake-kebab {:mvn/version "0.4.3"} | ||
cheshire/cheshire {:mvn/version "5.13.0"}} | ||
:aliases {:test {:extra-paths ["test"] | ||
:extra-deps {io.github.cognitect-labs/test-runner | ||
{:git/tag "v0.5.1" :git/sha "dfb30dd"}} | ||
:main-opts ["-m" "cognitect.test-runner"] | ||
:exec-fn cognitect.test-runner.api/test} | ||
:dev {:extra-deps {nrepl/nrepl {:mvn/version "1.0.0"} | ||
cider/cider-nrepl {:mvn/version "0.45.0"}}}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
(ns sketchybar.core | ||
(:require | ||
[babashka.process :refer [shell]] | ||
[camel-snake-kebab.core :as csk] | ||
[cheshire.core :as json]) | ||
(:refer-clojure :exclude [set update])) | ||
|
||
(defn map->kvs [m] | ||
(->> m | ||
(map (fn [[k v]] | ||
(let [v (if (keyword? v) | ||
(name v) | ||
v)] | ||
(str (name k) "=" v)))))) | ||
|
||
(defn bar [m] | ||
(flatten [["--bar"] (map->kvs m)])) | ||
|
||
(defn default [m] | ||
(flatten [["--default"] (map->kvs m)])) | ||
|
||
(defn set [item m] | ||
(flatten [["--set" (name item)] (map->kvs m)])) | ||
|
||
(defn add-item [item position] | ||
["--add" "item" (name item) (name position)]) | ||
|
||
(defn add-graph [graph position width] | ||
["--add" "graph" (name graph) (name position) (str width)]) | ||
|
||
(defn add-space [space position] | ||
["--add" "space" (name space) (name position)]) | ||
|
||
(defn add-bracket [bracket & members] | ||
(flatten [["--add" "bracket" (name bracket) (map name members)]])) | ||
|
||
(defn add-alias [app position] | ||
["--add" "alias" app (name position)]) | ||
|
||
(defn add-slider [slider position width] | ||
["--add" "slider" (name slider) (name position) (str width)]) | ||
|
||
(defn add-event | ||
([event] | ||
["--add" "event" (name event)]) | ||
([event notification] | ||
["--add" "event" (name event) (name notification)])) | ||
|
||
(defn push-datapoint [graph & data] | ||
(flatten [["--push" (name graph)] (map str data)])) | ||
|
||
(defn subscribe [item & events] | ||
(flatten [["--subscribe" (name item)] (map name events)])) | ||
|
||
(defn exec [& args] | ||
(->> (flatten args) | ||
(filter some?) | ||
(apply shell "sketchybar"))) | ||
|
||
(defn update [] | ||
(exec "--update")) | ||
|
||
(defn query [& args] | ||
(-> (apply shell {:out :string} "sketchybar" "--query" args) | ||
:out | ||
(json/parse-string csk/->kebab-case-keyword))) | ||
|
||
(comment | ||
(map->kvs {:update_freq 5 | ||
:label.color "0x0000000" | ||
:background.height 15 | ||
:script "bb test"}) | ||
(bar {}) | ||
(set :battery {:script "bb battery.jar" | ||
:update_freq 5 | ||
:background.color "0x000000" | ||
:label.color "0x000000" | ||
:background.height 15}) | ||
(add-item :battery :right) | ||
(add-graph :temperature :right 100) | ||
(add-space :space1 :left) | ||
(add-bracket :bracket1 :space.1 :space.2) | ||
(add-alias "Control Center,WiFi" :center) | ||
(add-slider :volume :left 100) | ||
(push-datapoint :temperature 20 21 22 23) | ||
(subscribe :battery :system_woke) | ||
|
||
(exec) | ||
(update) | ||
|
||
(query "battery")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
(ns sketchybar.core-test | ||
(:require | ||
[sketchybar.core :as core] | ||
[clojure.test :as t])) | ||
|
||
(t/deftest impl-helper | ||
(t/testing "map-kvs" | ||
(t/is (= (core/map->kvs {:update_freq 5 | ||
:label.color "0x0000000" | ||
:background.height 15 | ||
:script "bb test"}) | ||
'("update_freq=5" | ||
"label.color=0x0000000" | ||
"background.height=15" | ||
"script=bb test"))))) | ||
|
||
(t/deftest sbar-helper | ||
(t/testing "bar" | ||
(t/is (= (core/bar {:update_freq 5}) | ||
'("--bar" | ||
"update_freq=5"))))) |