You are not logged in.
AFAIC, bunch of cry babies.
That's not really fair. GNOME users and devs not a part of GNOME have been decrying the lack of theming for over a decade now (https://en.wikipedia.org/wiki/GNOME_3) and it's a legitimate gripe. Several GNOME apps have bailed because they didn't like the dev decisions of gnome-shell. Hello, Cinnamon and Mate.
Add to that Qt theming and now you're dealing with four or five theme sets (GTK2 and 3, libadwaita, QT and independently themed apps). It's a hot mess.
I don't care what you do at home. Would you care to explain?
Offline
Here's the kicker:
https://stopthemingmy.appAFAIC, bunch of cry babies.
100% agree, I have seen similar tantrums from them in a number of places. Childish.
It's like if I were to put out a post that said "Please stop changing the default wallpaper I ship with my distro, it's not fair to ME".
Kinda like crappy karen-run HOA's here in the US that make rules on what colors you can paint your own house.
Control-freaks really don't belong in Linux.
Offline
The big IF though is whether the chosen GTK theme supports GTK4, and also whether there are full css files. Symlinks to css files which import from gtk.gresource don't work. If BL were to use this we'd have to extract the css files from gtk.gresource for each of our themes.
OK new script version:
If theme has full css files in gtk-4.0/ copy them to ~/.config/gtk-4.0 (not symlink).
If there's a gtk.gresource file and only stub css files (like the BL Carbon themes), use the resource path in the file to extract the full css files to ~/.config/gtk-4.0.
If there are no css files or no gtk-4.0/ directory, just pass the theme name as an environment variable and hope for the best. It should be usable anyway.
If the theme can't be found, just launch the app with a warning message to stderr.
If there are already gtk.css or gtk-dark.css files in ~/.config/gtk-4.0, temporarily rename them till the app has closed, then move them back.
NB this script is only for launching GTK4 apps that otherwise ignore themes and come up white, eg file-roller. If we do our best to avoid such apps in the default BL setup, it will only be needed occasionally. The command for file-roller with theming set by us would be 'gtkset file-roller' (assuming the script is named gtkset).
If anyone would like to give it a try, here it is:
#!/bin/bash
# script to launch GTK4 apps with the current GTK3 theme
# the chosen theme must support GTK4
set -eu
app=$1
shift
hash "$app" || {
echo "${0}: command ${app} not found" >&2
exit 1
}
gtk3_file=~/.config/gtk-3.0/settings.ini
[[ -r $gtk3_file ]] || {
echo "${0}: WARNING unable to read ${gtk3_file}, no theming will be applied." >&2
"$app" "$@"
exit
}
gtk3_theme=$( sed -nE 's/[[:blank:]]*gtk-theme-name[[:blank:]]*=[[:blank:]]*([^[:blank:]]+).*$/\1/p' "$gtk3_file" )
[[ -n $gtk3_theme ]] || {
echo "${0}: WARNING unable to determine GTK3 theme, no theming will be applied." >&2
"$app" "$@"
exit
}
home_theme_dir="${HOME}/.local/share/themes"
home_theme_dir_old="${HOME}/.themes"
sys_theme_dir=/usr/share/themes
if [[ -d $home_theme_dir/$gtk3_theme/gtk-4.0 ]]
then
source_dir=$home_theme_dir/$gtk3_theme/gtk-4.0
elif [[ -d $home_theme_dir_old/$gtk3_theme/gtk-4.0 ]]
then
source_dir=$home_theme_dir_old/$gtk3_theme/gtk-4.0
elif [[ -d $sys_theme_dir/$gtk3_theme/gtk-4.0 ]]
then
source_dir=$sys_theme_dir/$gtk3_theme/gtk-4.0
else
echo "${0}: cannot find theme ${gtk3_theme} gtk4 directory, using environment variable to set theme." >&2
GTK_THEME="$gtk3_theme" "$app" "$@"
exit
fi
target_dir="${HOME}/.config/gtk-4.0"
mkdir -p "$target_dir"
gresource_file=${source_dir}/gtk.gresource
src_css=${source_dir}/gtk.css
src_dark=${source_dir}/gtk-dark.css
out_css=${target_dir}/gtk.css
out_dark=${target_dir}/gtk-dark.css
get_resource_path() {
# Expect a single line like: @import url("resource:///com/ubuntu/themes/foo/4.0/gtk.css");
sed -nE 's@^[[:space:]]*\@import[[:space:]]+url\("resource://(/[^"]+)"\);.*@\1@p' "$1"
# this sed command returns 1 if the pattern '^[[:space:]]*\@import' is not found:
# sed -nE '/^[[:space:]]*\@import/{s@^[[:space:]]*\@import[[:space:]]+url\("resource://(/[^"]+)"\);.*@\1@p;q0};q1' "$file"
}
bkp_sfx=".$(date +"%Y%m%d-%H%M%S")"
cleanup() {
for i in "${out_css}" "${out_dark}"
do
[[ -e ${i}${bkp_sfx} ]] && mv -f "${i}${bkp_sfx}" "${i}"
done
}
extract_if_needed () {
local srcfile=$1 outfile=$2 res
res=$(get_resource_path "$srcfile")
if [[ -n $res ]] && [[ -r $gresource_file ]]
then
gresource extract "$gresource_file" "$res" > "$outfile"
else
cp -f "$srcfile" "$outfile"
fi
}
trap 'cleanup' EXIT
[[ -r $src_css && -r $src_dark ]] || {
echo "${0}: cannot find css files ${src_css} and ${src_dark}, using environment variable to set theme." >&2
GTK_THEME="$gtk3_theme" "$app" "$@"
exit
}
# if user css files exist, move them aside before copying
for i in "$out_css" "$out_dark"
do
[[ -e $i ]] && mv "$i" "${i}${bkp_sfx}"
done
extract_if_needed "$src_css" "$out_css"
extract_if_needed "$src_dark" "$out_dark"
"$app" "$@"...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )
Offline