It’s not an easy task. Especially because some programs use gtk, some use qt and those themes are difficult to edit.
In theory you can set up bunch of template files in which you will specify tags {colorX} (where X is a number). Note that if you want to use {} in generated files you have to double them {{}}.
It will be a lot of work so it is up to you if you are up for it.
This function require a wallpaper, creates a symlink with a fixed name (name of the wallpaper can then be static in some configs like lightdm or feh). Then it generates colors from the wallpaper and creates new files in .cache/wal. All that remains is copy of all generated files to their proper locations.
But this is very simple example. I do not change gtk/qt themes because they are way too complex with many more than 16 colors pywal can generate. There could be some option to select “closest theme from predefined bunch” but I do not know how to categorise colors from hex codes.
pywal script example
# main change theme procedure based on a wallpaper (set color theme) - wallpaper is the first argument
change_theme()
{
WALLPAPER="$1"
# use wallpaper for login screen
ln -sf "${WALLPAPER}" "${wlink_storage}"
# setup theme
wal -e --backend wal -i "${WALLPAPER}" -o "${HOME}/.config/wal/wal_cleanup.sh"
## link config files to .cache/wal
# i3 config
# [[ -d "$HOME/.config/i3" ]] && ln -sf "${wal_cache}/i3config" "$HOME/.config/i3/config"
[[ -d "$HOME/.config/i3" ]] && cp -f "${wal_cache}/i3config" "${HOME}/.config/i3/config"
# dmenu
# [[ -x /usr/bin/dmenu ]] && ln -sf "${wal_cache}/dmenurc" "$HOME/.config/dmenurc"
[[ -x /usr/bin/dmenu ]] && cp -f "${wal_cache}/dmenurc" "${HOME}/.config/dmenurc"
# alacritty terminal
# [[ -x /usr/bin/alacritty ]] && ln -sf "${wal_cache}/alacritty.yml" "$HOME/.config/alacritty/alacritty.yml"
[[ -x /usr/bin/alacritty ]] && cp -f "${wal_cache}/alacritty.yml" "${HOME}/.config/alacritty/alacritty.yml"
# speedcrunch
# [[ -x /usr/bin/speedcrunch ]] && ln -sf "${wal_cache}/speedcrunch.json" "$HOME/.local/share/SpeedCrunch/color-schemes/pywal-theme.json"
[[ -x /usr/bin/speedcrunch ]] && cp -f "${wal_cache}/speedcrunch.json" "${HOME}/.local/share/SpeedCrunch/color-schemes/pywal-theme.json"
# dunst
if [[ -x /usr/bin/dunst ]]; then
# ln -sf "${wal_cache}/dunstrc" "${HOME}/.config/dunst/dunstrc"
cp -f "${wal_cache}/dunstrc" "${HOME}/.config/dunst/dunstrc"
killall dunst
fi
# restart i3 to apply new theme
i3-msg restart
# some delay for proper init - maybe not needed - prevent too fast reruns
sleep 2
}
Some template files
speedcrunch_template_example
{{
"_comment1": "speedcrunch theme file",
"_comment2": "this file is automaticaly generated from ~/.config/wal/template file",
"_comment3": "don't edit it directly but use pywal template",
"cursor": "{cursor}",
"number": "{foreground}",
"parens": "{color13}",
"result": "{color12}",
"comment": "{color8}",
"matched": "{color4}",
"function": "{color1}",
"operator": "{color3}",
"variable": "{color2}",
"scrollbar": "{color3}",
"separator": "{color3}",
"background": "{background}",
"editorbackground": "{background}"
}}
dmenurc template
# dmenurc file
# this file is automaticaly generated from ~/.config/wal/template file
# don't edit it directly but use pywal template
# pywal theming
DMENU_FN="iosevka_mono_serif:Regular:size=12"
DMENU_NB="{background}"
DMENU_NF="{foreground}"
DMENU_SB="{color2}"
DMENU_SF="{color7}"
## command for the terminal application to be used:
TERMINAL_CMD="alacritty -e"
## export our variables
DMENU_OPTIONS="-fn ${{DMENU_FN}} -nb $DMENU_NB -nf $DMENU_NF -sf $DMENU_SF -sb $DMENU_SB"
dmenurc after conversion located in .cache/wal directory
# dmenurc file
# this file is automaticaly generated from ~/.config/wal/template file
# don't edit it directly but use pywal template
# pywal theming
DMENU_FN="iosevka_mono_serif:Regular:size=12"
DMENU_NB="#070706"
DMENU_NF="#dbd6d0"
DMENU_SB="#CDA772"
DMENU_SF="#dbd6d0"
## command for the terminal application to be used:
TERMINAL_CMD="alacritty -e"
## export our variables
DMENU_OPTIONS="-fn ${DMENU_FN} -nb $DMENU_NB -nf $DMENU_NF -sf $DMENU_SF -sb $DMENU_SB"