Any Rustaceans out there? #475
Replies: 2 comments 2 replies
-
I also have a plugin for |
Beta Was this translation helpful? Give feedback.
-
I have played with direct both-way communication here as well: https://github.com/FelixKratz/SbarLua By utilizing this functionality we are able to circumvent the fork-exec overhead of spawing a new process. This is especially noticeable when switching spaces with disabled space change animations or other "reactive" operations, where the response latency drops by orders of magnitude and is faster than the screen refresh time and thus quasi-instantaneous. |
Beta Was this translation helpful? Give feedback.
-
Hello fellow SketchyBar enthusiasts! For a while now I've been playing around with the idea of writing Rust plugins for SketchyBar. This is almost entirely an excuse to practice and write more Rust code. I haven't ever noticed a plugin that was consuming a high number of resources or was particularly slow.
Initially I was playing around with the idea of integrating SketchyBar directly into a custom crate. For example I created a weather CLI tool for the purposes of integrating with SketchyBar. The initial integration still used a Bash script that called the CLI tool, parsed the results and updated SketchyBar. Then I played around with making a Rust library that wrapped the SketchyBarHelper. Well first, I tried reproducing SketchyBarHelper in pure Rust, but I totally flopped on that effort!
Ultimately I was able to integrate my helper library into the
conditions
binary so that my Rust code was directly updating SketchyBar. This worked and cut out the need to parse output from the CLI command, however a couple of things were still bothering me.Enter
cargo-script
. This is a tool that allows you to write Rust scripts that can be run directly from the command line. It also allows you to specify dependencies in the script itself. This is perfect for SketchyBar! I can write a Rust script that calls my library and have it update SketchyBar directly. This script is automatically compiled into a binary after each change to the script and that binary is cached (~/.cargo/target/
).Here's an example, using the before mentioned
conditions
crate:NOTE: The font-matter in the script should be denoted with fence blocks (```) but I couldn't get it to render correctly in the post so I used hyphens (---).
For completeness, here is my weather specific SketchyBar configuration
which results in this:
Hopefully there are other Rustaceans out there who will find this useful or roast me on my implementation! 😂
Beta Was this translation helpful? Give feedback.
All reactions