@@ -14,8 +14,102 @@ provide parts of the desktop environment that are missing from such setups,
1414and does so using keyboard friendly, terminal first UI components. Some of its
1515features are:
1616
17- * Replace the typical File Open/Save dialogs used in GUI programs with the
18- fast and keyboard centric :doc: `choose-files </kittens/choose-files >` kitten
19- running in a semi-transparent kitty overlay.
17+ * Replace the typical File Open/Save dialogs used in GUI programs with the
18+ fast and keyboard centric :doc: `choose-files </kittens/choose-files >` kitten
19+ running in a semi-transparent kitty overlay.
2020
21- * Allow simple command line based management of the desktop light/dark modes.
21+ * Allow simple command line based management of the desktop light/dark modes.
22+
23+
24+ How to install
25+ -------------------
26+
27+ .. note ::
28+
29+ This kitten relies on the :doc: `panel kitten </kittens/panel >`
30+ under the hood to supply UI components. Check :ref: `the documentation <panel_compat >`
31+ of that kitten to see if your window manager works with it.
32+
33+ First, run::
34+
35+ kitten desktop-ui enable-portal
36+
37+ Then, set the following two environment variables, *system wide *, that means in
38+ :file: `/etc/environment ` or the equivalent for your distribution::
39+
40+ QT_QPA_PLATFORMTHEME=xdgdesktopportal
41+ GTK_USE_PORTAL=1
42+
43+
44+ Finally, reboot. Now, when you open a file dialog in most GUI applications, it
45+ should open the :doc: `choose-files kitten </kittens/choose-files >` instead
46+ of a normal file open dialog. You can change the current light/dark mode of
47+ your desktop by running::
48+
49+ kitten desktop-ui set-color-scheme dark
50+ kitten desktop-ui set-color-scheme light
51+
52+ Check the current value using::
53+
54+ dbus-send --session --print-reply --dest=org.freedesktop.portal.Desktop /org/freedesktop/portal/desktop org.freedesktop.portal.Settings.Read string:org.freedesktop.appearance string:color-scheme
55+
56+ How it works
57+ ----------------
58+
59+ Modern Linux desktops have so called `portals
60+ <https://flatpak.github.io/xdg-desktop-portal/docs/index.html> `__ that were
61+ invented for sandboxed applications and provide various facilities to such
62+ applications over DBUS, including file open dialogs, common desktop settings,
63+ etc. This kitten works by implementing a backend for some of these services.
64+
65+ Normal GUI applications can then be told to make use of these services, thereby
66+ allowing us to replace parts of the desktop experience as needed.
67+
68+ There are multiple competing implementations of the backends. Each desktop
69+ environment like KDE or GNOME has it's own backend and many window managers
70+ provide implementations for some backends as well. Service discovery and
71+ configuring which backend to use happens via the :file: `xdg-desktop-portal `
72+ program, usually found at :file: `/usr/lib/xdg-desktop-portal `.
73+
74+ It can be configured by files in :file: `~/.local/share/xdg-desktop-portal `. See
75+ `man portals.conf <https://man.archlinux.org/man/portals.conf.5 >`__. The
76+ ``kitten desktop-ui enable-portal `` command takes care of the setup for you
77+ automatically. If you want to customize exactly which services to use this
78+ kitten for, run the command and then edit the conf file that the command says
79+ it has patched.
80+
81+
82+ Troubleshooting
83+ -------------------
84+
85+ First, ensure that DBUS is able to auto-start the kitten when it is needed. If
86+ the kitten is not already running, try the following command::
87+
88+ dbus-send --session --print-reply --dest=org.freedesktop.impl.portal.desktop.kitty \
89+ /net/kovidgoyal/kitty/portal org.freedesktop.DBus.Properties.GetAll \
90+ string:net.kovidgoyal.kitty.settings
91+
92+ If DBUS is able to start the kitten or if it is already running it will print
93+ out the version property, otherwise it will fail with an error. If it fails,
94+ check the file
95+ :file: `.local/share/dbus-1/services/org.freedesktop.impl.portal.desktop.kitty.service `
96+ that should have been created by the ``enable-portal `` command. It's ``Exec ``
97+ key must point to the full path to the kitten executable.
98+
99+ Next, check that the XDG portal system is actually using this kitten for its
100+ settings backend. Run::
101+
102+ dbus-send --session --print-reply --dest=org.freedesktop.portal.Desktop \
103+ /org/freedesktop/portal/desktop org.freedesktop.portal.Settings.Read \
104+ string:net.kovidgoyal.kitty string:status
105+
106+ If this returns a reply then the kitten is being used, as expected. If it
107+ returns a not found error, then some other backend is being used for settings.
108+
109+ Read the ``portals.conf `` man page and run::
110+
111+ /usr/lib/xdg-desktop-portal -r v
112+
113+ this will output a lot of debug information, which should tell you which
114+ backend is chosen for which service. Read the debug output carefully to
115+ determine why the kitten is not being selected.
0 commit comments