Closed bajrangCoder closed 5 days ago
I think it might be better to use zbus
to read system settings. We not only need this but also:
e.g. to get this value via dbus you can run gdbus call -e -d org.freedesktop.portal.Desktop -o /org/freedesktop/portal/desktop -m org.freedesktop.portal.Settings.Read '"org.gnome.desktop.interface"' '"overlay-scrolling"'
I think it might be better to use
zbus
to read system settings. We not only need this but also:
- Cursor size and theme (mainly for Gnome Wayland)
- Middle click paste enabled/disabled
- Double click time
- Dark mode (can also be retrieved via a portal, see Get the color scheme through xdg-desktop-portal #11926)
- Possibly others?
e.g. to get this value via dbus you can run
gdbus call -e -d org.freedesktop.portal.Desktop -o /org/freedesktop/portal/desktop -m org.freedesktop.portal.Settings.Read '"org.gnome.desktop.interface"' '"overlay-scrolling"'
Initially, I considered using the ashpd
xdg library, which relies on zbus
, to retrieve these settings. However, this approach requires asynchronous calls, and in zed
, making a function asynchronous involves spawning tasks (as I observed in the codebase). Additionally, we need to implement equivalent macOS code, as the maintainer has mentioned in several conversations. Therefore, I believe this alternative solution would be more suitable here. But I'm ready to modify it. 😊
We can also get several other settings value by just changing key in this approach
Well, the only reason the code is working right now is that we block the main thread until that external Command
completes. How about we try using the zbus approach, but use the same blocking IO, something like:
self.with_common(|common| {
common.background_executor.block(zbus_async_call)
})
If that doesn't work out, maybe because zbus
noticeably lags Zed or the borrowing doesn't work, then we could also try changing this should_auto_hide_scrollbars()
API to return a Task<bool>
, and do the async spawning as you mentioned. Then we would have change the Zed codebase, which shouldn't be too hard :)
The only problem with the org.freedesktop.portal.Settings
portal is that it expose show all settings, but only a subset of them. For example the one telling you which of the close, maximize, minimize should be visible, in what order and on which side, and some mouse related ones especially around accessibility like double click speed, aren’t exposed. We should still use it when we can, and fill the gap with gsettings when absolutely necessary.
Well, the only reason the code is working right now is that we block the main thread until that external
Command
completes. How about we try using the zbus approach, but use the same blocking IO, something like:self.with_common(|common| { common.background_executor.block(zbus_async_call) })
If that doesn't work out, maybe because
zbus
noticeably lags Zed or the borrowing doesn't work, then we could also try changing thisshould_auto_hide_scrollbars()
API to return aTask<bool>
, and do the async spawning as you mentioned. Then we would have change the Zed codebase, which shouldn't be too hard :)
Ok , soon I will commit the zbus implementation
Note, that this PR has built some nice infrastructure for getting events from xdg into Zed: https://github.com/zed-industries/zed/pull/11926.
Might be good to improve that approach with this configuration setting :)
Implemented the
should_auto_hide_scrollbars
method for Linux. This method uses thegsettings
GNOME utility to retrieve the setting. Thegsettings
utility comes pre-installed on many desktop environments such as KDE, GNOME, and others.The method has been tested on:
Release Notes: