feat: Add gschema-overrides module (#110)

* feat: Add `gschema-overrides` module

* chore: Clarify "including prefix" section better

* chore: Some formatting fix

* chore: Don't mention higher prefix, as it can confuse users

* fix: Add partial troubleshooting of most preferred gschema-overide

It does not support aborting on fail currently, as I have to think on how to implement it when multiple gschema-override files are included in the module.

* Revert "fix: Add partial troubleshooting of most preferred gschema-overide"

This reverts commit 1dde51938e45648c7f53b696e61249339a2eb277.

* fix: Use `z1-` prefix for to avoid future conflict with Universal Blue images

* chore: Fix some README remarks from xynydev

* chore: Note that GTK DEs other than Gnome are also supported

* chore: Be more specific about GTK-based DEs

* chore: Clarify using module section a tiny bit better

* chore: Add editing gschema.overrides section & make README formatting cleaner

* chore: Reword some sentences better

* fix: don't use multiple toplevel headings, replace <br> tags with spammed spaces

---------

Co-authored-by: xyny <60004820+xynydev@users.noreply.github.com>
This commit is contained in:
fiftydinar 2024-02-02 18:57:00 +01:00 committed by GitHub
parent 9b66c64563
commit b528a0acc9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 142 additions and 0 deletions

View file

@ -0,0 +1,93 @@
# `gschema-overrides` module for BlueBuild
The `gschema-overrides` module can be used for including system-setting overrides for GTK-based desktop environments.
GTK-based desktop environments include Gnome, Cinnamon, MATE, Budgie & such.
This module is similar to using `dconf` configuration, but is better because it doesn't require a systemd service & supports build-time troubleshooting.
What does this module do?
- It copies all content from `/usr/share/glib-2.0/schemas`, except existing gschema.overrides to avoid conflicts, into temporary test location.
- It copies your gschema.overrides you provided in this module from `/usr/share/glib-2.0/schemas` into temporary test location.
- It tests them for errors in temporary test location by using `glib-compile-schemas` with `--strict` flag. If errors are found, build will fail.
- If test is passed successfully, compile gschema using `glib-compile-schemas` in `/usr/share/glib-2.0/schemas` to include your changes.
Temporary test location is:
`/tmp/bluebuild-schema-test`
## Usage
To use this module, you need to include your gschema.override file(s) in this location:
`/usr/share/glib-2.0/schemas`
Then you need to include those file(s) in recipe file, like in example configuration.
It is highly recommended to use `z1-` prefix before your gschema.override name, to ensure that your changes are going to be applied.
Also don't forget to rename your file(s) too with this prefix in `/usr/share/glib-2.0/schemas`.
### Example configuration
```yaml
type: gschema-overrides
include:
- z1-myoverride.gschema.override
- z1-myoverride2.gschema.override
```
## Editing gschema.override files
Gschema.override files use `gsettings` keyfile format for settings output.
### Example of gschema.override settings
```
[org.gnome.desktop.peripherals.touchpad]
tap-to-click=true
[org.gnome.settings-daemon.plugins.power]
power-button-action='interactive'
[org.gnome.mutter]
check-alive-timeout=uint32 20000
[org.gnome.shell.extensions.blur-my-shell]
sigma=5
```
### Example of gschema.override lockscreen settings (Gnome)
```
[org.gnome.desktop.peripherals.touchpad:GNOME-Greeter]
tap-to-click=true
```
- To gather setting change after you input the command, use this:
`dconf watch /`
When you change some setting toggle or option when this command is active,
you will notice that command will output the key for the changed setting,
which you can use & write into gschema.override file in the format shown in example above.
- To gather current & available settings on booted system, you can use this command:
`gsettings list-recursively`
You should use this command everytime when you want to apply some setting override,
to ensure that it's listed as available.
**Gschema.override files don't support relocatable schemas & locking settings.**
For that functionality, you should use `dconf-update-service` module.
Relocatable schemas are rare, so most users won't run into this scenario.
### Example of relocatable schemas
```
gsettings format:
[org.gnome.desktop.app-folders.folder:/org/gnome/desktop/app-folders/folders/Utilities/]
[org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/]
dconf format:
[org/gnome/desktop/app-folders/folders/Utilities]
[org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0]
```

View file

@ -0,0 +1,49 @@
#!/usr/bin/env bash
set -euo pipefail
get_yaml_array INCLUDE '.include[]' "$1"
schema_test_location="/tmp/bluebuild-schema-test"
schema_location="/usr/share/glib-2.0/schemas"
gschema_extension=false
echo "Installing gschema-overrides module"
# Abort build if file in module is not included
if [[ ${#INCLUDE[@]} == 0 ]]; then
echo "Module failed because gschema-overrides aren't included into the module."
exit 1
fi
# Abort build if included file does not have .gschema.override extension
if [[ ${#INCLUDE[@]} -gt 0 ]]; then
for file in "${INCLUDE[@]}"; do
file="${file//$'\n'/}"
if [[ $file == *.gschema.override ]]; then
gschema_extension=true
else
echo "Module failed because included files in module don't have .gschema.override extension."
exit 1
fi
done
fi
# Apply gschema-override when all conditions above are satisfied
if [[ ${#INCLUDE[@]} -gt 0 ]] && $gschema_extension; then
printf "Applying the following gschema-overrides:\n"
for file in "${INCLUDE[@]}"; do
file="${file//$'\n'/}"
printf "%s\n" "$file"
done
mkdir -p "$schema_test_location" "$schema_location"
find "$schema_location" -type f ! -name "*.gschema.override" -exec cp {} "$schema_test_location" \;
for file in "${INCLUDE[@]}"; do
file_path="${schema_location}/${file//$'\n'/}"
cp "$file_path" "$schema_test_location"
done
echo "Running error-checking test for your gschema-overrides. If test fails, build also fails."
glib-compile-schemas --strict "$schema_test_location"
echo "Compiling gschema to include your changes with gschema-override"
glib-compile-schemas "$schema_location" &>/dev/null
fi