This commit is contained in:
Vince 2021-08-28 22:04:02 +08:00
parent 87506545d6
commit 9735e27bad
2 changed files with 15 additions and 17 deletions

View file

@ -2,14 +2,12 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
[[ -n "$PAKITHEME_VERBOSE" ]] && set -x ||:
die() {
echo "$@" >&2
exit 1
}
pakitheme() {
pakitheme_gtk3() {
local color="$(destify ${1})"
local opacity="$(destify ${2})"
local alt="$(destify ${3})"
@ -17,12 +15,12 @@ pakitheme() {
local FLATPAK_THEME="${name}${color}${opacity}${alt}${theme}"
local GTK_THEME_VER=3.22
local GTK_3_THEME_VER=3.22
local cache_home="${XDG_CACHE_HOME:-$HOME/.cache}"
local data_home="${XDG_DATA_HOME:-$HOME/.local/share}"
local pakitheme_cache="$cache_home/pakitheme"
local repo_dir="$pakitheme_cache/repo"
local app_id="org.gtk.Gtk3theme.$FLATPAK_THEME"
local gtk3_app_id="org.gtk.Gtk3theme.$FLATPAK_THEME"
local root_dir="$pakitheme_cache/$FLATPAK_THEME"
local repo_dir="$root_dir/repo"
local build_dir="$root_dir/build"
@ -57,40 +55,40 @@ pakitheme() {
cp -a "$theme_path/gtk-3.$theme_gtk_version/"* "$build_dir/files"
mkdir -p "$build_dir/files/share/appdata"
cat >"$build_dir/files/share/appdata/$app_id.appdata.xml" <<EOF
cat >"$build_dir/files/share/appdata/$gtk3_app_id.appdata.xml" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<component type="runtime">
<id>$app_id</id>
<id>$gtk3_app_id</id>
<metadata_license>CC0-1.0</metadata_license>
<name>$flatpak_name Gtk theme</name>
<summary>$flatpak_name Gtk theme (generated via pakitheme)</summary>
<name>$FLATPAK_THEME Gtk theme</name>
<summary>$FLATPAK_THEME Gtk theme (generated via pakitheme)</summary>
</component>
EOF
appstream-compose --prefix="$build_dir/files" --basename="$app_id" --origin=flatpak "$app_id"
appstream-compose --prefix="$build_dir/files" --basename="$gtk3_app_id" --origin=flatpak "$gtk3_app_id"
ostree --repo="$repo_dir" commit -b base --tree=dir="$build_dir"
bundles=()
while read -r arch; do
bundle="$root_dir/$app_id-$arch.flatpak"
bundle="$root_dir/$gtk3_app_id-$arch.flatpak"
rm -rf "$build_dir"
ostree --repo="$repo_dir" checkout -U base "$build_dir"
read -rd '' metadata <<EOF ||:
[Runtime]
name=$app_id
runtime=$app_id/$arch/$GTK_THEME_VER
sdk=$app_id/$arch/$GTK_THEME_VER
name=$gtk3_app_id
runtime=$gtk3_app_id/$arch/$GTK_3_THEME_VER
sdk=$gtk3_app_id/$arch/$GTK_3_THEME_VER
EOF
# Make sure there is no trailing newline, so xa.metadata doesn't get confused later
echo -n "$metadata" > "$build_dir/metadata"
ostree --repo="$repo_dir" commit -b "runtime/$app_id/$arch/$GTK_THEME_VER" \
ostree --repo="$repo_dir" commit -b "runtime/$gtk3_app_id/$arch/$GTK_3_THEME_VER" \
--add-metadata-string "xa.metadata=$(cat $build_dir/metadata)" --link-checkout-speedup "$build_dir"
flatpak build-bundle --runtime "$repo_dir" "$bundle" "$app_id" "$GTK_THEME_VER"
flatpak build-bundle --runtime "$repo_dir" "$bundle" "$gtk3_app_id" "$GTK_3_THEME_VER"
trap 'rm "$bundle"' EXIT

View file

@ -741,7 +741,7 @@ connect_flatpak() {
for alt in "${alts[@]}"; do
for theme in "${themes[@]}"; do
for color in "${colors[@]}"; do
pakitheme "${color}" "${opacity}" "${alt}" "${theme}"
pakitheme_gtk3 "${color}" "${opacity}" "${alt}" "${theme}"
done
done
done