Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Console colors are completely broken after sdm run #212

Closed
ykharuzhy opened this issue May 30, 2024 · 9 comments
Closed

Console colors are completely broken after sdm run #212

ykharuzhy opened this issue May 30, 2024 · 9 comments

Comments

@ykharuzhy
Copy link

ykharuzhy commented May 30, 2024

I use Konsole and colors are not restored after run (right sub-window shows original console colors)

image

@gitbls
Copy link
Owner

gitbls commented May 30, 2024

Thanks for trying sdm. Sorry to hear that you're having an issue.

Unfortunately, the problem you are seeing with konsole appears to be due to a deficiency in the konsole terminal emulator. From my testing, konsole returns the correct FG and BG colors, but does not return the cursor color. Further, when sdm presents the appropriate colors to konsole for restoring, they are not honored by konsole.

This code works correctly when using the xterm terminal emulator and others, which properly and completely honor the color escape sequences.

To avoid this unpleasant mis-colorization sdm will be updated to enable the console colorizing to be disabled using a specific setting (--mcolors 0 for mount and --ecolors 0 for explore and customize). In this case sdm will not modify the terminal colors and they will remain at whatever they are prior to running sdm.

Addenda: Curiously, the following bash function (which you can add to your .bashrc if desired) does work on konsole. But this is the same code that sdm uses, and I've verified that sdm is doing the right thing. I don't understand why it works with this function and not in sdm, but the above workaround will be implemented in lieu of spending time chasing down the root cause, which is likely to be some konsole oddity.

function xtset() {
    #
    # set xterm color. can specify 3 sets of pairs (e.g., fg yellow bg black cursor red)
    # $1=fg|bg|cursor
    # $2=color to set
    # if 'xtset reset' is used, the terminal colors are reset to white bg and black fg
    # Colors are listed in /etc/X11/rgb.txt (or /usr/share/X11/rgb.txt)
    #
    function xtsetx() {
        case "$1" in
            fg) printf "\e]10;${2}\a"
                ;;
            bg) printf "\e]11;${2}\a"
                ;;
            cur*) printf "\e]12;${2}\a"
                  ;;
            *) echo "Usage: xtset fg|bg|cur*sor color..."
               ;;
        esac
    }
    [ "$1" == "reset" ] && xtsetx fg black && xtsetx bg white && return
    [ "$1" != "" ] && xtsetx "$1" "$2"
    [ "$3" != "" ] && xtsetx "$3" "$4"
    [ "$5" != "" ] && xtsetx "$5" "$6"
} ; declare -fx xtset

@ykharuzhy
Copy link
Author

Thanks. A switch to disable colorizing completely would be a good solution. Personally I use the sdm in an image building script for CI, so colors have no sense there.

@gitbls
Copy link
Owner

gitbls commented May 31, 2024

Thanks. A switch to disable colorizing completely would be a good solution. Personally I use the sdm in an image building script for CI, so colors have no sense there.

Are you using the --batch switch on your customize command? sdm won't colorize the terminal and operates non-interactively to completion.

@ykharuzhy
Copy link
Author

Yes, i use --batch but sdm uses colors anyway.

@gitbls
Copy link
Owner

gitbls commented May 31, 2024

Could you provide the (appropriately redacted) command string that you are using? It shouldn't be coloring with --batch.

What I see at the end of your screen output is:

  * Enter shell command prompt
    'exit' to back to host system

which will not appear if you use --batch:

* Customization complete
* Batch Mode exit
umount: /mnt/sdm/boot/firmware unmounted

Thx

@ykharuzhy
Copy link
Author

Yes, I added --batch later. I rechecked with unmodified sdm (I disabled color changing in the code before) — you are right, with --batch background color is changed to blue during of phase 1 but restored successfully.

@gitbls
Copy link
Owner

gitbls commented Jun 3, 2024

OK. --batch should preclude the color from changing at all. I've modified the code in sdm to honor --batch so it won't change at all.

This will be in the next update to sdm later this week.

@gitbls
Copy link
Owner

gitbls commented Jun 7, 2024

--ecolors 0 and --mcolors 0 added in V12.3. Please test/verify. Thx

@gitbls
Copy link
Owner

gitbls commented Jul 3, 2024

No activity so closing issue.

@gitbls gitbls closed this as completed Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants