|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# shellcheck disable=SC2154 |
| 4 | +# shellcheck disable=SC1091 |
| 5 | + |
| 6 | +[[ "${HYDE_SHELL_INIT}" -ne 1 ]] && eval "$(hyde-shell init)" |
| 7 | + |
| 8 | +# Stores default values for the theme to avoid breakages. |
| 9 | +source "${SHARE_DIR}/hyde/theme-env" |
| 10 | + |
| 11 | +dconf_populate() { |
| 12 | + # Build the dconf content |
| 13 | + cat <<EOF |
| 14 | +[org/gnome/desktop/interface] |
| 15 | +icon-theme='$ICON_THEME' |
| 16 | +gtk-theme='$GTK_THEME' |
| 17 | +color-scheme='$COLOR_SCHEME' |
| 18 | +cursor-theme='$CURSOR_THEME' |
| 19 | +cursor-size=$CURSOR_SIZE |
| 20 | +font-name='$FONT $FONT_SIZE' |
| 21 | +document-font-name='$DOCUMENT_FONT $DOCUMENT_FONT_SIZE' |
| 22 | +monospace-font-name='$MONOSPACE_FONT $MONOSPACE_FONT_SIZE' |
| 23 | +font-antialiasing='$FONT_ANTIALIASING' |
| 24 | +font-hinting='$FONT_HINTING' |
| 25 | +
|
| 26 | +[org/gnome/desktop/default-applications/terminal] |
| 27 | +exec='$(command -v "${TERMINAL}")' |
| 28 | +
|
| 29 | +[org/gnome/desktop/wm/preferences] |
| 30 | +button-layout='$BUTTON_LAYOUT' |
| 31 | +EOF |
| 32 | + |
| 33 | +} |
| 34 | +# HYDE_THEME="$(hyq "${HYPRLAND_CONFIG}" --source --query 'hyde:theme')" |
| 35 | +COLOR_SCHEME="prefer-${dcol_mode}" |
| 36 | +GTK_THEME="Wallbash-Gtk" |
| 37 | +HYPRLAND_CONFIG=${HYPRLAND_CONFIG:-"${XDG_CONFIG_HOME:-$(xdg-user-dir CONFIG)}/hypr/hyprland.conf"} |
| 38 | + |
| 39 | +# Populate variables from hyprland config if exists |
| 40 | +if [[ -r "${HYPRLAND_CONFIG}" ]] && |
| 41 | + command -v "hyq" &>/dev/null; then |
| 42 | + |
| 43 | + eval "$( |
| 44 | + hyq "${HYPRLAND_CONFIG}" --source --export env \ |
| 45 | + -Q 'hyde:gtk-theme' \ |
| 46 | + -Q 'hyde:icon-theme' \ |
| 47 | + -Q 'hyde:cursor-theme' \ |
| 48 | + -Q 'hyde:cursor-size' \ |
| 49 | + -Q 'hyde:terminal' \ |
| 50 | + -Q 'hyde:font' \ |
| 51 | + -Q 'hyde:font-size' \ |
| 52 | + -Q 'hyde:document-font' \ |
| 53 | + -Q 'hyde:document-font-size' \ |
| 54 | + -Q 'hyde:monospace-font' \ |
| 55 | + -Q 'hyde:monospace-font-size' \ |
| 56 | + -Q 'hyde:button-layout' \ |
| 57 | + -Q 'hyde:font-antialiasing' \ |
| 58 | + -Q 'hyde:font-hinting' |
| 59 | +
|
| 60 | + )" |
| 61 | + GTK_THEME=${_hyde_gtk_theme:-$GTK_THEME} |
| 62 | + COLOR_SCHEME=${_hyde_color_scheme:-$COLOR_SCHEME} |
| 63 | + ICON_THEME=${_hyde_icon_theme:-$ICON_THEME} |
| 64 | + CURSOR_THEME=${_hyde_cursor_theme:-$CURSOR_THEME} |
| 65 | + CURSOR_SIZE=${_hyde_cursor_size:-$CURSOR_SIZE} |
| 66 | + TERMINAL=${_hyde_terminal:-$TERMINAL} |
| 67 | + FONT=${_hyde_font:-$FONT} |
| 68 | + FONT_SIZE=${_hyde_font_size:-$FONT_SIZE} |
| 69 | + DOCUMENT_FONT=${_hyde_document_font:-$DOCUMENT_FONT} |
| 70 | + DOCUMENT_FONT_SIZE=${_hyde_document_font_size:-$DOCUMENT_FONT_SIZE} |
| 71 | + MONOSPACE_FONT=${_hyde_monospace_font:-$MONOSPACE_FONT} |
| 72 | + MONOSPACE_FONT_SIZE=${_hyde_monospace_font_size:-$MONOSPACE_FONT_SIZE} |
| 73 | + BUTTON_LAYOUT=${_hyde_button_layout:-$BUTTON_LAYOUT} |
| 74 | + FONT_ANTIALIASING=${_hyde_font_antialiasing:-$FONT_ANTIALIASING} |
| 75 | + FONT_HINTING=${_hyde_font_hinting:-$FONT_HINTING} |
| 76 | +fi |
| 77 | + |
| 78 | +# Check if we need inverted colors |
| 79 | +if [[ "${revert_colors:-0}" -eq 1 ]] || |
| 80 | + [[ "${enableWallDcol:-0}" -eq 2 && "${dcol_mode:-}" == "light" ]] || |
| 81 | + [[ "${enableWallDcol:-0}" -eq 3 && "${dcol_mode:-}" == "dark" ]]; then |
| 82 | + if [[ "${dcol_mode}" == "dark" ]]; then |
| 83 | + COLOR_SCHEME="prefer-light" |
| 84 | + else |
| 85 | + COLOR_SCHEME="prefer-dark" |
| 86 | + fi |
| 87 | +fi |
| 88 | + |
| 89 | +DCONF_FILE="${XDG_CACHE_HOME:-$HOME/.cache}/hyde/dconf" |
| 90 | + |
| 91 | +{ dconf load -f / <"${DCONF_FILE}" && print_log -sec "dconf" -stat "preserve" "${DCONF_FILE}"; } || print_log -sec "dconf" -warn "failed to preserve" "${DCONF_FILE}" |
| 92 | +{ dconf_populate >"${DCONF_FILE}" && print_log -sec "dconf" -stat "populated" "${DCONF_FILE}"; } || print_log -sec "dconf" -warn "failed to populate" "${DCONF_FILE}" |
| 93 | +{ dconf reset -f / <"${DCONF_FILE}" && print_log -sec "dconf" -stat "reset" "${DCONF_FILE}"; } || print_log -sec "dconf" -warn "failed to reset" "${DCONF_FILE}" |
| 94 | +{ dconf load -f / <"${DCONF_FILE}" && print_log -sec "dconf" -stat "loaded" "${DCONF_FILE}"; } || print_log -sec "dconf" -warn "failed to load" "${DCONF_FILE}" |
| 95 | + |
| 96 | +[[ -n "${HYPRLAND_INSTANCE_SIGNATURE}" ]] && hyprctl setcursor "${CURSOR_THEME}" "${CURSOR_SIZE}" |
| 97 | + |
| 98 | +print_log -sec "dconf" -stat "Loaded dconf settings" |
| 99 | +print_log -y "#-----------------------------------------------#" |
| 100 | +dconf_populate |
| 101 | +print_log -y "#-----------------------------------------------#" |
0 commit comments