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

feature request: toggle night/day mode theme #592

Closed
jangorecki opened this issue Nov 19, 2019 · 5 comments
Closed

feature request: toggle night/day mode theme #592

jangorecki opened this issue Nov 19, 2019 · 5 comments
Labels
enhancement Feature request
Milestone

Comments

@jangorecki
Copy link

jangorecki commented Nov 19, 2019

Shell: bash
Operating system: Xubuntu 18.04
Liquid Prompt version (tag, commit): official apt repo

Working with themes seems to be quite complicated at the moment. Not just in liquidprompt but also in plain terminal apps, e.g. Change color scheme for xfce4 terminal manually.
I would like to request a very single theme switch option for night/day theme modes.
Basically "night mode" could be (AFAIK) as the current default one (black background), and the "day mode" could a white background theme.
Why the request?
During the day it is sometimes difficult to read console output like git status where unstaged files are listed in dark red color. Switching to a "day mode" would basically resolve problems like this. That would be a big advantage for liquidprompt over a plain bash, where you cannot easily swap colors (as explained in linked askubuntu).
Thanks for the great software!

@Rycieos
Copy link
Collaborator

Rycieos commented Jun 26, 2020

This is an interesting request. I see two parts:

  1. The ability to define multiple themes and switch between them at runtime.
  2. The ability to have the "default" background color be something other than black.\

The first part totally makes sense, and I was planning on it for v2.0 anyway, but this is a good issue to log that.

The second part might be tricky, and I'm not sure that the prompt is the right place to set that. I'm not sure that the terminal is the right place either, so I'll keep this as a feature request and dig to it more.

@Rycieos Rycieos added the enhancement Feature request label Jun 26, 2020
@Rycieos Rycieos added this to the v2.0 milestone Jun 26, 2020
@Rycieos
Copy link
Collaborator

Rycieos commented Dec 9, 2020

v2.0.0-beta.1 has the capability to switch between themes at runtime. See Switching Themes. Thanks for the suggestion!

As for

The ability to have the "default" background color be something other than black.

I do not think this is something Liquidprompt can or even should try to do. It can only control what it prints to the terminal, any other program that you run will not know that you want your "default" color to be something else, and will still use the real default color. This is something that should be managed in your terminal emulator.

@Rycieos Rycieos closed this as completed Dec 9, 2020
@jangorecki
Copy link
Author

@Rycieos do you mind extending documentation, or at least mentioning here, how to address request in question? a night/day mode. I think that can attract users to this new feature.

@Rycieos
Copy link
Collaborator

Rycieos commented Dec 10, 2020

Normally, I'm all for extending documentation. But since I would never recommend doing this, I don't think I'll add this specific solution to the docs. I will be soon adding an example that shows how to make a "lightweight" theme, which this is closely following:

My solution "hacks" the default theme, so I don't have to re-implement everything. But this makes for some issues:
image

  • It doesn't print correctly for the first prompt, because the default theme isn't expecting to need to print NO_COL when there is no color.
  • It doesn't print the background color across the whole line, but that is just how terminals work.
  • When changing back to the default theme, because I don't have any color config options set, it keeps the modified colors. This could be fixed by setting colors in your config file.
  • I am quite color blind, so the colors I picked probably don't look good to most people.

So again, I don't recommend this. You could probably fix this up a bit, but the second point will be hard to fix. Better to use a terminal emulator that lets you change colors, and swap themes there. My terminal can do it (Mintty).

But if you want to try anyway, here is the code I came up with for this:

_lp_default_inverted_theme_activate() {
    local lp_terminal_format

    LP_COLORMAP=("")

    # Black on white
    lp_terminal_format 232 255 0 0 0 7
    NO_COL=$lp_terminal_format

    # Green on white
    lp_terminal_format 28 -2 0 0 2
    LP_COLORMAP+=("$lp_terminal_format")
    LP_COLOR_X11_ON=$lp_terminal_format
    LP_COLOR_WRITE=$lp_terminal_format
    LP_COLOR_UP=$lp_terminal_format
    LP_COLOR_CHARGING_ABOVE=$lp_terminal_format

    # Bold green on white
    lp_terminal_format -2 -2 1 0
    LP_COLORMAP+=("$lp_terminal_format")

    # Yellow on white
    lp_terminal_format 40 -2 0 0 3
    LP_COLORMAP+=("$lp_terminal_format")
    LP_COLOR_JOB_D=$lp_terminal_format
    LP_COLOR_JOB_D=$lp_terminal_format
    LP_COLOR_X11_OFF=$lp_terminal_format
    LP_COLOR_COMMITS=$lp_terminal_format
    LP_COLOR_CHARGING_UNDER=$lp_terminal_format
    LP_COLOR_DISCHARGING_ABOVE=$lp_terminal_format
    LP_COLOR_RUNTIME=$lp_terminal_format

    # Bold yellow on white
    lp_terminal_format -2 -2 1 0
    LP_COLORMAP+=("$lp_terminal_format")
    LP_COLOR_PATH_ROOT=$lp_terminal_format
    LP_COLOR_JOB_R=$lp_terminal_format
    LP_COLOR_JOB_Z=$lp_terminal_format
    LP_COLOR_USER_ROOT=$lp_terminal_format
    LP_COLOR_SU=$lp_terminal_format

    # Blue on white
    lp_terminal_format 18 -2 0 0 4
    LP_COLOR_SSH=$lp_terminal_format
    LP_COLOR_TIME=$lp_terminal_format

    # Bold blue on white
    lp_terminal_format -2 -2 1 0
    LP_COLOR_PROXY=$lp_terminal_format
    LP_COLOR_IN_MULTIPLEXER=$lp_terminal_format

    # Magenta on white
    lp_terminal_format 24 -2 0 0 5
    LP_COLOR_ERR=$lp_terminal_format
    LP_COLOR_DIFF=$lp_terminal_format

    # Cyan on white
    lp_terminal_format 30 -2 0 0 6
    LP_COLOR_VIRTUALENV=$lp_terminal_format

    # Red on white
    lp_terminal_format 52 -2 0 0 1
    LP_COLORMAP+=("$lp_terminal_format")
    LP_COLOR_NOWRITE=$lp_terminal_format
    LP_COLOR_CHANGES=$lp_terminal_format
    LP_COLOR_DISCHARGING_UNDER=$lp_terminal_format

    # Bold red on white
    lp_terminal_format -2 -2 1 0
    LP_COLORMAP+=("$lp_terminal_format")
    LP_COLOR_MARK_ROOT=$lp_terminal_format
    LP_COLOR_MARK_SUDO=$LP_COLOR_MARK_ROOT
    LP_COLOR_COMMITS_BEHIND=$lp_terminal_format

    # Bold black on red
    lp_terminal_format 232 -3 1 0 0
    LP_COLORMAP+=("$lp_terminal_format")

    # Bold white on red
    lp_terminal_format 255 -2 1 0 7
    LP_COLORMAP+=("$lp_terminal_format")

    # Bold yellow on red
    lp_terminal_format 40 -2 1 0 3
    LP_COLORMAP+=("$lp_terminal_format")

    _lp_default_theme_activate
}

_lp_default_inverted_theme_directory() {
    _lp_default_theme_directory
}

_lp_default_inverted_theme_prompt() {
    _lp_default_theme_prompt
}

There is probably also a simpler solution involving setting the color variables to one of two settings in your config file if you have a flag enabled or something, but again, I don't think this is a good idea.

@Rycieos
Copy link
Collaborator

Rycieos commented Feb 7, 2021

Thanks to discussion on #657, the default theme since v2.0.1 now "supports" running in both light and dark mode. The trick is that Liquidprompt can and does not control that; it is still up to the terminal emulator.

But now you only need to set the default foreground and background colors, and Liquidprompt should still display correctly. See the screenshots in this #657 (comment)

If you still want to do that on the fly with a toggle button, I'm afraid that is still outside the scope of Liquidprompt, and is something your terminal emulator will need to support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request
Projects
None yet
Development

No branches or pull requests

2 participants