mirror of
https://github.com/swaywm/sway.git
synced 2024-11-29 03:11:27 +00:00
added small tutorial to get GTK themes & settings working
parent
e97b5e3c9b
commit
c3bdea7d24
52
GTK-3-settings-on-Wayland.md
Normal file
52
GTK-3-settings-on-Wayland.md
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
GTK+ is known for not picking up some variables from `${XDG_CONFIG_HOME}/gtk-3.0/settings.ini`, most notably themes.
|
||||||
|
|
||||||
|
This happens because when GTK+ uses the wayland backend, a subset of variables are pulled from the `gsettings` schema `org.gnome.desktop.interface`, whereas on X11 GTK talks to a XSETTINGS daemon that usually does this for you, or when missing, falls back to the user's setting.ini file.
|
||||||
|
|
||||||
|
Note that this only applies for settings that belong to `org.gnome.desktop.interface`. Some settings, like `gtk-application-prefer-dark-theme`, are still read from your `settings.ini`.
|
||||||
|
|
||||||
|
## Workarounds
|
||||||
|
|
||||||
|
### Setting GTK_THEME
|
||||||
|
|
||||||
|
If you only care about your GTK theme, you can export the `GTK_THEME` environment variable before running your GTK programs. While this is quite simple, it's also fairly limited, since there are no environment variables to set other settings, like icon/cursor themes.
|
||||||
|
|
||||||
|
### Setting values in `gsettings`
|
||||||
|
|
||||||
|
The proper workaround is to call `gsettings set org.gnome.desktop.interface <key> <value>` yourself at any point before starting any GTK program, for each setting that you want set. A good place to do so is either your shell's rc files, or using `exec` in your sway config.
|
||||||
|
|
||||||
|
You can list valid keys for the schema using `gsettings list-keys org.gnome.desktop.interface`; you most notably want to set `gtk-theme`, `cursor-theme` and `icon-theme`:
|
||||||
|
|
||||||
|
```
|
||||||
|
set $gnome-schema org.gnome.desktop.interface
|
||||||
|
|
||||||
|
exec_always {
|
||||||
|
gsettings set $gnome-schema gtk-theme 'Your theme'
|
||||||
|
gsettings set $gnome-schema icon-theme 'Your icon theme'
|
||||||
|
gsettings set $gnome-schema cursor-theme 'Your cursor Theme'
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
If you'd rather have those values picked from your settings.ini file, here is a small convenient script to just that:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# usage: import-gsettings <gsettings key>:<settings.ini key> <gsettings key>:<settings.ini key> ...
|
||||||
|
|
||||||
|
expression=""
|
||||||
|
for pair in "$@"; do
|
||||||
|
IFS=:; set -- $pair
|
||||||
|
expressions="$expressions -e 's:^$2=(.*)$:gsettings set org.gnome.desktop.interface $1 \1:e'"
|
||||||
|
done
|
||||||
|
IFS=
|
||||||
|
eval exec sed -E $expressions "${XDG_CONFIG_HOME:-$HOME/.config}"/gtk-3.0/settings.ini >/dev/null
|
||||||
|
```
|
||||||
|
|
||||||
|
Importing the gtk, icon, and cursor themes:
|
||||||
|
|
||||||
|
```
|
||||||
|
exec_always import-gsettings \
|
||||||
|
gtk-theme:gtk-theme-name \
|
||||||
|
icon-theme:gtk-icon-theme-name \
|
||||||
|
cursor-theme:gtk-cursor-theme-name
|
||||||
|
```
|
Loading…
Reference in a new issue