frewsxcv / rust-sysbar Goto Github PK
View Code? Open in Web Editor NEWRust library for interacting with the system's taskbar / tray / statusbar
License: Apache License 2.0
Rust library for interacting with the system's taskbar / tray / statusbar
License: Apache License 2.0
Lines 109 to 184 in d505b36
this was inherited from rs-barfly and i'm not entirely sure what's going on here
On including this package as a dependency in our project, we get this warning from clippy (which is configured to run as a pre-commit hook):
error[E0433]: failed to resolve: use of undeclared type or module `SysbarImpl`
--> /home/amit_project/Code/amitu_heroku/.cargo/registry/src/github.com-1ecc6299db9ec823/sysbar-0.2.0/src/lib.rs:12:16
|
12 | Sysbar(SysbarImpl::new(name))
| ^^^^^^^^^^ use of undeclared type or module `SysbarImpl`
error[E0412]: cannot find type `SysbarImpl` in this scope
--> /home/amit_project/Code/amitu_heroku/.cargo/registry/src/github.com-1ecc6299db9ec823/sysbar-0.2.0/src/lib.rs:8:19
|
8 | pub struct Sysbar(SysbarImpl);
| ^^^^^^^^^^ not found in this scope
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0412, E0433.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `sysbar`.
Hey,
is there currently a way to have dynamic content? Like the time or something?
Thanks for the help.
Hi, would be nice if this crate supports a progress indicator in the taskbar item, I'm unsure if macOS support it but Windows and Linux do
Some systems only show the icon of the application, what is currently not possible to set.
The creator of connectr wrote me a message on reddit a while ago, thought I'd paste it here in case others find the information valuable:
If you're interested, I'd be happy to team up with you on making a nice sysbar library. Though I think it's more important to reach out to ones working on systray-rs and see if everyone can agree on one API that works for all three major OSs.
Feel free to take anything useful out of Connectr. As I said, it was my first Rust project and it was driven from an application need, so it didn't end up very clean. The current interface is here: https://github.com/mrmekon/connectr/blob/master/src/lib.rs#L82
The main thing I care about is that I've proven that it runs for 2+ weeks, clearing and rebuilding its menu every 30 seconds, without crashing or leaking memory.
The big things I learned from it:
I don't like depending on tons of libraries, so I want to drop the 'cocoa' lib and use only the 'objc' libs. The cocoa lib is nice, but mixing the two ends up being a pain, and cocoa is missing a lot of functionality. It's less work to just implement it with 'objc' than to try to get upstream changes into 'cocoa'.
Mixing 'cocoa' and 'objc' and 'objcid' leads to some things having Drop traits and some things not, and it gets confusing. My preference now is to use _only 'objc' and do all memory management manually.
I assumed a flat menu design, which was dumb. I'm currently working on changing it to support recursive menus. Items should be added to menu objects, instead of to a global 'sysbar' instance.
Every UI library, and some other libraries (like HTTP libs) assume they will get a run_forever() on the main thread. This makes it impossible to mix them. I went through great pains to make my mine support run_once(), and split that out into a separate library (fruitbasket: see the next item). I think this is important if it will ever be used seriously in bigger applications.
Mac apps can run as standalone binaries or in app bundles, and behave differently. All of my handling for that, and the non-blocking application loop, was split out into fruitbasket. I'm plugging my own thing here, but i think this is the way to go for managing Mac main loops. It can bundle resources and self-package itself, so cargo run builds and executes an app bundle, and you can easily access icon and image resources in the bundle. See here: https://github.com/mrmekon/fruitbasket
After making the menu bar stuff, I made touch bar support for Connectr. This is split out into another library (rubrail), and is much cleaner. It supports infinite recursion and loading images from various sources. If I did the menu bar API again, it would look more like that, but maybe with a Builder pattern and Drop traits to avoid memory leaks. That API is documented here: https://mrmekon.github.io/rubrail-rs/rubrail/trait.TTouchbar.html
For tracing memory leaks, it's super convenient to subclass Obj-C classes and either print or add breakpoints to their retain/release/dealloc methods. I wrote a macro to do that: https://github.com/mrmekon/rubrail-rs/blob/master/src/wrapper.rs
Where the systray/menubar UI isn't quite enough - like needing text input - I've taken to spawning a local web server that serves a static HTML form and returns key/value pairs. This is cross-platform enough. My plan was to split the menu bar stuff out into one library, the web config stuff into a separate library, and recommend using them together. Anyway, it's a strategy worth considering when building cross-platform apps in a world with no cross-platform GUIs: https://github.com/mrmekon/connectr/blob/master/src/settings/mod.rs#L65
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.