| examples | ||
| j3blocks | ||
| screenshots | ||
| j3blocks.janet | ||
| LICENSE | ||
| project.janet | ||
| README.md | ||
j3blocks
It is a janet scripting system for i3bar and swaybar. It is distributed as a jpm library. You have to write a janet script to use this library.
Janet is a system scripting language.
Development Status
It doesn't get updates often because this software is finished. I have used it for more than a year without a major issue.
Built-in j3blocks module screenshots
bandwidth
cpu
memory usage
swap usage
time
Extra j3blocks modules
j3blocks tries not to have a lot of built-in modules.
Extra community modules can be found on j3blocks-extra.
You can contribute j3blocks modules to j3blocks-extra.
Basic usage
Built-in j3blocks modules are available in j3blocks/modules.
For example, if you want to use the built-in cpu module, run this janet script as the status command of i3bar or swaybar.
(import j3blocks)
(import j3blocks/modules/cpu)
(import j3blocks/loglevel)
(j3blocks/run
:unix-socket-name "test"
:loglevel loglevel/info
:blocks
[{:id "cpu"
:module (cpu/usage)
:click-event
(fn
[input output log]
(forever
(case (get (ev/take input) "button")
# left click
1
(ev/give output "update")
# right click
3
(ev/spawn (os/execute ["do" "something"] :p)))))
:modify-block
(fn
[input output log]
(forever
(def block (ev/take input))
(put block "separator" false)
(put block "markup" "pango")
(ev/give output block)))}])
The above example disables separator and sets markup to pango in cpu module. Log level is set to info. It also
processes click events.
It creates a unix domain socket at $XDG_RUNTIME_DIR/j3blocks/test or /tmp/j3blocks/$UID/test. The unix domain
socket messages become block events.
For details, read (doc j3blocks/run).
Unix domain socket
If you want to pass messages to j3blocks unix domain socket, then you should use j3blocks/msg as below.
(import j3blocks/msg)
(msg/send "test" ["static-block1" "instance1"] {"message" "ok"})
In the above example, msg/send sends {"message" "ok"} to a block identified by ["static-block1" "instance1"].
The block is running on a j3blocks instance listening on the unix domain socket, test. Any message sent to a j3blocks
block must be valid JSON which can be a string, a number, an object, and so on.
Refer to (doc msg/send) for details.
Every j3blocks block can receive click events and unix domain socket events.
Useful janet modules for j3blocks
- If you want to produce pango markup text,
j3blocks/pangomodule will be useful. - If your j3blocks module needs to parse
/proc/meminfo,j3blocks/procmeminfomodule will be useful. - If your j3blocks module needs to parse
/proc/net/dev,j3blocks/procnetdevmodule will be useful. spork/shis useful for launching programs in response to click events.
Contribution
This library tries not to exceed 120 characters per line.




