j3blocks

codeberg.org · 2026-08-02 · by Long Nguyen ·generic
j3blocks

j3blocks

Code Issues Pull requests Projects Releases Packages Wiki Activity

No description

102 commits 1 branch 1 tag 185 KiB

  • Janet 100%
  • master

    Find a file

    HTTPS

    Download ZIP Download TAR.GZ Download BUNDLE Open with VS Code Open with VSCodium Open with Intellij IDEA

    | Repository files (latest commit first) | Filename | Latest commit message | Latest commit date | | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- | ------------------ | | amano.kenji 26e279ec18 Replace stdin file with spork/stream/make-stdin | 2026-02-19 11:18:22 +00:00 | | | | examples | Fix examples | 2024-02-25 11:18:01 +00:00 | | | j3blocks | j3blocks/format: Replace camel case with hyphens | 2024-02-25 22:55:57 +00:00 | | | screenshots | Add screenshots to README.md | 2024-02-20 11:15:44 +00:00 | | | j3blocks.janet | Replace stdin file with spork/stream/make-stdin | 2026-02-19 11:18:22 +00:00 | | | LICENSE | First working version | 2024-01-19 01:39:31 +00:00 | | | project.janet | Add development status to README | 2025-03-15 13:52:55 +00:00 | | | README.md | Add development status to README | 2025-03-15 13:52:55 +00:00 | |

    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

    bandwidth

    cpu

    cpu

    memory usage

    mem

    swap usage

    swap

    time

    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/pango` module will be useful.
  • If your j3blocks module needs to parse `/proc/meminfo`, `j3blocks/procmeminfo` module will be useful.
  • If your j3blocks module needs to parse `/proc/net/dev`, `j3blocks/procnetdev` module will be useful.
  • `spork/sh` is useful for launching programs in response to click events.

Contribution

This library tries not to exceed 120 characters per line.

codeberg.org · 10 images · 75 links

Comments (0)

No comments yet