-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make zbus
Optional, Remove anyhow
, Fix notify
Example
#40
Conversation
This makes more sense to me, especially because on some systems e.g. windows the default was not `Mode::Default`
There's still no proper error type, I replaced some of them with `Box<dyn Error>` instead, but at least we don't have the dependency anymore.
It's not necessary and very easily conflicts
This **significantly** reduces compile time and binary size on linux. Depending on my fork is not ideal, I opened a PR upstream: frewsxcv/rust-dark-light#40 but frewsxcv/rust-dark-light#15 doesn't give me confidence.
This would be nice to merge if someone has the time to review. There are currently a number of PRs which are providing essential fixes, which are now spinning off into forks since they don't get merged in time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
First, please limit pull requests to one topic so each change can be discussed independently. I'll limit the rest of this comment to making zbus optional; please split off the other commits to separate pull requests.
Making zbus optional was already discussed and dismissed in #15. It doesn't solve any actual problems; shifting dependencies from Rust to C doesn't remove the dependencies. But if you really really insist and are willing to implement it yourself, replacing zbus with a C alternative could be an option off by default. I don't generally expect Rust crates to have a dependency on a C library or external executables unless it's a binding crate to a C library. I would be quite annoyed if I got a build or run time error because of that when an upstream crate could've just used a Rust crate.
As far as the implementation, I think calling external executables is a questionable approach. There's no guarantee those exectuables exist on any particular system. Even if they happen to be shipped by many distros by default now (which as far as I can tell, you haven't investigated if that's the case), there's no guarantee they will continue doing so in the future. The author of zbus is working on busd, a Rust replacement for dbus-daemon. I suspect some distros will switch to shipping that instead of dbus-daemon in the coming years. It's conceivable that project could continue to a Rust replacement for dbus-send and dbus-monitor in the future, perhaps with incompatible CLIs. Also, returning Mode::NoPreference
when those exectuables aren't found is incorrect; it's not that there is no system preference, but that detecting it failed. The downstream developer/packager gets no indication that there's any problem at build time nor run time; end users would just not have dark/light mode detected correctly and have no information why.
So, I think that if you really want to not use zbus, it would be better to implement that using the dbus crate which depends on the libdbus C library. That way the C dependency is clear; downstream developers would get an error at build time if the dependency isn't found, and packagers would need to ensure that libdbus is specified as a dependency. That would obviate the need for a run time error in case an external exectuable isn't found.
I'd also be okay with simply rejecting this change and not merging any alternative to zbus if @frewsxcv and @edfloreshz agree. I don't think there's any compelling reason to maintain multiple implementations. |
👍
Like I said, it does solve an actual problem: compile time and binary size. I tested my change on iced, and not relying on
It's on an external executable, so a build-time error is irrelevant.
This is delightfully hypocritical, this is literally what is already being done with dconf_rs. No sane distro will stop shipping I've looked a bit at the dbus FAQ and README and it's not entirely clear what stability the dbus binaries have:
The main reason I opted for the binaries over linking with
That is simply not true. For |
Please open separate pull requests for these separate changes |
Can we resolve the |
Please open separate pull requests for the separate commits |
If you think that, then let's just drop this. Bringing in a C library dependency or a dependency on an external executable by default is IMO a nonstarter. (Just because others call external executables for this too doesn't make it a great idea.) You know what takes longer than 4 seconds? Making this pull request and commenting on it. Or having your build fail because you don't have libdbus' development package installed, figuring out why your build failed, and fixing the build. Or debugging why an application isn't detecting your dark/light mode preference, finding out you don't have This crate is only for GUI applications. 2.5 MiB additional binary size is not ideal, but hardly a pressing problem. If this was a crate for running on microcontrollers with constrained memory, that would be more concerning, but that's not what this crate is for. If you're really concerned about zbus' binary size, improve that upstream instead of introducing novel problems to downstream dependencies. |
Yeah and it's not great. That was the only crate available when the implementation was written. Turns out someone wrote Rust bindings for the dconf C library recently, so I'll switch to using those, which should be done anyway considering dconf_rs is unmaintained. If someone writes a pure Rust replacement for the dconf C library in the future, that'd be even better. |
I discovered
--print-reply=literal
fordbus-send
andargN=
fordbus-monitor
which make the logic nicer,detect
is in a very good state,subscribe
is a bit more fragile in terms of forward compatibility, but I think it's good enough to merge it.On my system
notify
sends each notification twice, I originally had some logic to deduplicate it, but it also happens withzbus
so it's probably a Gnome bug. (It might still be useful to have it regardless?)Fixes #34, #15 (FWIW, I agree with @parasyte, being pure-rust isn't a very compelling argument for a abstraction crate such as this, and this crate being important for accessibility and
zbus
being used inaccesskit
has almost nothing to do with how this crate is implemented. This crate feels like it should be light, so it should be light - depending on an heavy crate breaks user expectation and leads to frustration.)Edit: I'm not sure if
Mode::Preference
implementingDefault
is a good idea, people might think it detects the theme, and I can't think of a reason to use it outside the implementation, as users will most likely convert it to their own type. I'm not sure it evenMode::Preference
needs to exist, asOption<Mode>
can express the same thing.