Powerlevel9k: [Discussion] Minimal Mode

Created on 5 Aug 2018  Â·  6Comments  Â·  Source: Powerlevel9k/powerlevel9k

This is not a bug report, it's more-so a request for comments.

Sometimes I find myself in the situation where I need to drop to a TTY, or enter a fresh system/terminal. Unfortunately in these scenarios, the colors are limited, and the font selection is very poor. I'd like to keep zsh in these situations, and having some of the information that PL9K provides is very convenient (e.g. local IP address).

_It would be phenomenal if PL9K could detect these "minimal" or "low power" environments and intelligently adjust itself so that that it doesn't display a nasty line of garbage characters or broken colors._

I would go ahead and just fork the next branch, write some code, and make a PR, but some areas are a bit fuzzy:

  • How can we detect, within some level of accuracy, that their environment...

    • doesn't support colors ($TERM ?)

    • isn't using a certain font (fc-list ?)

  • What is the best method of making adjustments such that it doesn't destroy the user's configuration? Do we

    • offer an environment variable to be read from, and expect the user to configure it himself?

    • set sensible defaults that might override user configuration?

  • Is such a feature outside of the PL9K's scope
  • Will such a feature complicate existing or future code to the point that it is not worthwhile

I guess this is more of an architectural question than anything. I'm open to any kind of criticism here, and I patiently await your thoughts.

All 6 comments

Hi @Maxattax97 ,

sorry for the late response. IMHO this is a bit out of scope. Some of these ideas may work on some systems, but it will be extremely hard to implement that consistently on all environments. We tried some of these suggestions already: detecting the color capabilities, detecting the set font with quite mixed outcome. For some standard cases/terminals that seems to work, but for some it doesn't (and they seem to be the one that would have needed a working auto-detection).
This gets increasingly harder, if you log in from a remote machine, using a (probably) less capable terminal (like putty, which seem not to be able to display double-width glyphs properly).

Don't get me wrong: I would love to have that automatically detected, but I think it's too hard. Especially, if that effect can be reached by setting some variables (thinking of putty being able to set an variable on connect, which could be used to change the layout of P9K). Btw. one of the most powerful variables in P9K is POWERLEVEL9K_MODE, which, when unset is already a pretty trimmed down icon set. Another way of an "no-icon" mode would be to override print_icon.

Thanks for the response. I'm definitely seeing the difficulty in detecting these capabilities.

I do like the idea of being able to set a variable (or execute a function, depending) that would switch to a pre-configured low power mode. If I open up a fresh zsh terminal and it complains that it's < 256 colors and has missing icons, then I could simply:

   18:29:05  max@Maxattax-OpenSUSE   192.168.10.125    1.20  9.94G 
   I   ~  pl9k_enter_low_power_mode
18:29:06 > max@Maxattax-OpenSUSE > 192.168.10.125 > L 1.20 > R 9.94G >
> I > ~ > echo "Hello, low power mode"
Hello, low power mode
18:29:07 > max@Maxattax-OpenSUSE > 192.168.10.125 > L 1.20 > R 9.94G >
> I > ~ >

Maybe throw a POWERLEVEL9K_AUTO_ADJUST_MODE variable in the mix so that when it _can_ detect missing functionality, it will automatically drop to a low power mode, but leave this off by default.

@Maxattax97 I think I've already had a solution to what you're looking for for awhile now, but it's kinda just been stuck in my zshrc since.

It detects what program is currently running the zsh session and will only switch to a powerline theme when it's a recognized program:
https://github.com/robobenklein/configs/blob/57ae617b35b5a03e36accb2b15cf98695f79a98f/zsh/zshrc#L107

I do parent-process detection at https://github.com/robobenklein/configs/blob/57ae617b35b5a03e36accb2b15cf98695f79a98f/zsh/zshrc#L9
I wrote this because I found that OSX actually had good support in setting TERM_PROGRAM and Linux wasn't, so I did it myself.

And then I conditionally enable different themes at https://github.com/robobenklein/configs/blob/57ae617b35b5a03e36accb2b15cf98695f79a98f/zsh/zshrc#L280

(I think I lived your exact scenario - I often will switch to vttys to get out of xserver stuff, etc)

@robobenklein Those snippets are gems. This definitely provides some solid options. We could add a configurable variable like POWERLEVEL9K_VALID_EMULATORS... if minimal mode detection is enabled, and the emulator does not match, it drops to minimal. This could be used for simple color support detection too.

If we can narrow down what terminal is in use, maybe we can branch out using tools like dconf to detect which fonts are in use, although this path would be a little indirect.

It might be useful to construct a list (not in this thread) of all known terminal emulators plus things like TTY's just for sake of unit testing.

I don't really think there's any reasonable way to retrieve the font capabilities in a portable manner, but it's not hard to just allow the user to drop the weird symbols that don't render:

image

I think instead of getting a list of 'supported' terminals, it's a better idea to just enable minmode on terminals that we know cannot render extra symbols. (Like the linux tty is always login for TERM_PROGRAM in my rc example.)

I am on a issue-cleaning spree. This issue hasn't had motion in quite some time, and so I am closing it out due to inactivity. If anyone would like to re-open it because they feel it is un-resolved and is something they care about, please feel free to re-raise the discussion!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

OATOMO picture OATOMO  Â·  4Comments

natemccurdy picture natemccurdy  Â·  5Comments

iiison picture iiison  Â·  3Comments

mingrammer picture mingrammer  Â·  4Comments

controversial picture controversial  Â·  4Comments