Skip to content

Commit

Permalink
Add conditionnal enabling for the battery meter
Browse files Browse the repository at this point in the history
Early detection when `acpi` is missing.
Update the README.
  • Loading branch information
nojhan committed Aug 16, 2012
1 parent b48a0cc commit 39ba4c3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ the path
path
* `LP_HOSTNAME_ALWAYS`, choose between always displaying the hostname or showing
it only when connected with a remote shell

You can also force some features to be disabled, to save some time in the prompt
building:
* `LP_ENABLE_PERM`, if you want to detect if the directory is writable
* `LP_ENABLE_SHORTEN_PATH`, if you to shorten the path display
* `LP_ENABLE_PROXY`, if you want to detect if a proxy is used
Expand All @@ -117,10 +120,11 @@ it only when connected with a remote shell
* `LP_ENABLE_SVN`, if you want to have subversion informations
* `LP_ENABLE_HG`, if you want to have mercurial informations

Please note that all the `LP_ENABLE_…` variables override the templates, ie if you use `$LP_BATT` in your template and
you set `LP_ENABLE_BATT=0` in your config file, you will not have the battery informations.

# vim: set et sts=4 sw=4 tw=120 ft=sh:
Note that if required commands are not installed, enabling the
corresponding feature will have no effect.
Note also that all the `LP_ENABLE_…` variables override the templates,
i.e. if you use `$LP_BATT` in your template and you set `LP_ENABLE_BATT=0`
in your config file, you will not have the battery informations.


## PUT THE PROMPT IN A DIFFERENT ORDER
Expand Down
9 changes: 5 additions & 4 deletions liquidprompt
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,10 @@ _lp_source_config()
_lp_source_config

# Disable features if the tool is not installed
[[ "$LP_ENABLE_GIT" = 1 ]] && { command -v git >/dev/null || LP_ENABLE_GIT=0 ; }
[[ "$LP_ENABLE_SVN" = 1 ]] && { command -v svn >/dev/null || LP_ENABLE_SVN=0 ; }
[[ "$LP_ENABLE_HG" = 1 ]] && { command -v hg >/dev/null || LP_ENABLE_HG=0 ; }
[[ "$LP_ENABLE_GIT" = 1 ]] && { command -v git >/dev/null || LP_ENABLE_GIT=0 ; }
[[ "$LP_ENABLE_SVN" = 1 ]] && { command -v svn >/dev/null || LP_ENABLE_SVN=0 ; }
[[ "$LP_ENABLE_HG" = 1 ]] && { command -v hg >/dev/null || LP_ENABLE_HG=0 ; }
[[ "$LP_ENABLE_BATT" = 1 ]] && { command -v acpi >/dev/null || LP_ENABLE_BATT=0 ; }



Expand Down Expand Up @@ -711,7 +712,7 @@ _lp_svn_branch_color()
# returns 4 if no battery support
_lp_battery()
{
command -v acpi >/dev/null 2>&1 || return 4; # or no battery support
[[ "$LP_ENABLE_BATT" == 1 ]] || return
local acpi
acpi="$(acpi --battery 2>/dev/null)"
local bat
Expand Down

0 comments on commit 39ba4c3

Please sign in to comment.