regolith-linux / regolith-desktop

Meta package for the Regolith Desktop Environment
1.48k stars 31 forks source link

a bug in `regolith-look refresh` and (hopefully) a simple solution #744

Closed ywpkwon closed 1 year ago

ywpkwon commented 1 year ago

Describe the bug I'm using Regolith 2.1 on Ubuntu 22.04 --- so cool so far. But I faced one minor bug.

The command regolith-look refresh relies on load_regolith_xres() function defined in /usr/lib/regolith/regolith-session-common.sh If you look at the function below, as it states, it loads two times (before and after the regolith look loading). But the problem is, the first load doesn't supports -I"$USER_XRESOURCE_SEARCH_PATH" (But the second load supports.)

So if you define some variables in $USER_XRESOURCE_SEARCH_PATH and include them in user Xresources, regolith-look refresh gives an error (due to the first load) -- But everything still works because of the second load. I think the first load should use the -I"$USER_XRESOURCE_SEARCH_PATH" option consistently.

# 1. Load the Regolith Xresource override file if exists
# 2. Load Regolith Look Xresource as defined in override or use default
# 3. Re-merge Regolith Xresource override file if exists
load_regolith_xres() {
    if [ -f "$USER_XRESOURCE_OVERRIDE_FILE" ]; then
        xrdb -merge "$USER_XRESOURCE_OVERRIDE_FILE"          # <--- no -I"$USER_XRESOURCE_SEARCH_PATH" !!
    fi

    LOOK_STYLE_ROOT_PATH=$(xrescat regolith.look.path "$DEFAULT_XRESOURCE_LOOK_PATH")
    LOOK_STYLE_ROOT_FILE="$LOOK_STYLE_ROOT_PATH/root"

    if [ -f "$LOOK_STYLE_ROOT_FILE" ]; then
        xrdb -I"$USER_XRESOURCE_SEARCH_PATH" -merge "$LOOK_STYLE_ROOT_FILE"
    fi

    if [ -f "$USER_XRESOURCE_OVERRIDE_FILE" ]; then
        xrdb -I"$USER_XRESOURCE_SEARCH_PATH" -merge "$USER_XRESOURCE_OVERRIDE_FILE"
    fi
}

To Reproduce Steps to reproduce the behavior:

  1. Define some variables in $HOME/.config/regolith2/Xresources.d
  2. Use those values using #include xxx in $HOME/.config/regolith2/Xresources
  3. Do regolith-look refresh

This will give you an uncomfortable error message as below, but functionally everything works.

❯ regolith-look refresh
/home/paul/.config/regolith2/Xresources:48:10: fatal error: colors: No such file or directory
   48 | #include "colors"
      |          ^~~~~~~~
compilation terminated.
Executing look loader script: /usr/share/regolith-look/default_loader.sh
> Updating already existing 'Regolith' profile
[SUCCESS] Reinstalled Regolith GNOME Terminal version 0.1.0 for the 'Regolith' profile!

Installation Details

kgilmer commented 1 year ago

Thanks for the super detailed @ywpkwon ! I agree with your assessment. Would you care to write the PR? If not I'll update myself sometime by the weekend.

https://github.com/regolith-linux/regolith-session/blob/main/usr/lib/regolith/regolith-session-common.sh#L54

kgilmer commented 1 year ago

Fixed in prep for 2.2 release