pfetch: add get_palette

This commit is contained in:
Dylan Araps 2019-09-27 21:49:44 +03:00
parent d91cd1c0bf
commit ba03cb3cf4
2 changed files with 16 additions and 1 deletions

View File

@ -58,7 +58,7 @@ _/\ __)/_) pkgs 130
# Default: first example below # Default: first example below
# Valid: space separated string # Valid: space separated string
# #
# OFF by default: shell # OFF by default: shell palette
PF_INFO="ascii title distro host kernel uptime pkgs memory" PF_INFO="ascii title distro host kernel uptime pkgs memory"
# Example: Only ASCII. # Example: Only ASCII.

15
pfetch
View File

@ -576,6 +576,21 @@ get_memory() {
log memory "${mem_used:-?}M / ${mem_full:-?}M" >&6 log memory "${mem_used:-?}M / ${mem_full:-?}M" >&6
} }
get_palette() {
# Print the first 8 terminal colors. This uses the existing
# sequences to change text color with a sequence prepended
# to reverse the foreground and background colors.
#
# This allows us to save hardcoding a second set of sequences
# for background colors.
palette=" $c1 $c2 $c3 $c4 $c5 $c6 $c7 "
# Print the palette with a newline before and after.
# The '\033[%sC' moves the text to the right, the
# length of the ascii art.
printf '\n[%sC%s\n' "${ascii_width-1}" "$palette" >&6
}
get_ascii() { get_ascii() {
# This is a simple function to read the contents of # This is a simple function to read the contents of
# an ascii file from 'stdin'. It allows for the use # an ascii file from 'stdin'. It allows for the use