-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Customizing Info
The neofetch config file contains a function near the top which gives you total freedom over customizing how info is displayed in the info column. Since the config file is a bash script and this is a function, you can use any bash syntax to customize it.
I've also created a few "helper" functions to make customization easier. The functions are called prin
, info
and color
.
- Config File Location
- Print Info Function
- Adding Custom Info
- Removing Info
- Rearranging info
- More complex examples
The per-user location for neofetch's config is ${HOME}/.config/neofetch/config.conf
and neofetch will copy its default config here on first run if installed correctly (Using the Makefile or a Distro package).
Neofetch also installs a system-wide editable config file at /etc/neofetch/config.conf
(This is where it copies the user config from).
The strings in double quotes ("Model") are the subtitles for each info line and can be changed to whatever title you like or just removed altogether.
Here's what the function looks like:
print_info () {
info title
info underline
info "Host" model
info "OS" distro
info "Kernel" kernel
info "Uptime" uptime
info "Packages" packages
info "Shell" shell
info "Resolution" resolution
info "DE" de
info "WM" wm
info "WM Theme" wm_theme
info "Theme" theme
info "Icons" icons
info "Terminal" term
info "Terminal Font" term_font
info "CPU" cpu
info "GPU" gpu
info "Memory" memory
# The lines below with a '#' in front are additional info functions
# that are disabled by default. Removing the '#' enables them and adding
# a '#' to the start disables them again. You can add a '#' to any of the
# lines in this function to disable their output.
# info "CPU Usage" cpu_usage
# info "Disk" disk
# info "Battery" battery
# info "Font" font
# info "Song" song
# info "Local IP" local_ip
# info "Public IP" public_ip
# info "Users" users
# info "Birthday" birthday
info cols
}
The script comes with two helper functions that make it easier to display more info.
Usage: info "subtitle" function
Usage: info function
# Print Memory
info "Memory" memory # Memory: 100MB / 1000MB
info memory # 100MB / 1000MB
Full list of functions:
distro
model
kernel
uptime
packages
shell
resolution
de
wm
wm_theme
theme
icons
cpu
gpu
memory
font
disk
battery
song
local_ip
public_ip
users
birthday
term
term_font
cpu_usage
Special functions:
underline
title
Old functions:
-
line_break
– removed in 85a1bd0, useprin
instead
You can also just use printf
or echo
but you'll have to format/color
the text yourself.
Usage: prin "Custom message" or prin "Subtitle" "Custom message"
# Print a custom message
prin "They call me Stacy"
# Print a custom info line
prin "Date" "$(date)"
# Print a custom message and color it blue
prin "$(color 4)That's not my name"
# Print the current weather
prin "Weather" "$(curl wttr.in/?0?q?T | awk '/°(C|F)/ {printf $(NF-1) $(NF) " ("a")"} /,/ {a=$0}')"
This function allows you to add color to strings.
Usage: color num
color fg # fg is the default foreground color of your colorscheme.
# Print a custom message and color it blue
prin "$(color 4)That's not my name"
# Print a custom message and color it.
prin "$(color 1)Hi, $(color 2)They $(color 3)call $(color 4)me $(color 5)Stacy!"
# Using echo
echo "hello, world"
echo -e "$(color 3)Date: $(color 7)$(date)"
# Using printf
printf "%s\n" "hello, world"
printf "%s\n" "$(color 3)Date: $(color 7)$(date)"
You can easily disable info from printing by adding a #
to the start of the line. See below where I disable Packages from printing:
print_info() {
info title
info underline
info "Model" model
info "OS" distro
info "Kernel" kernel
info "Uptime" uptime
# info "Packages" packages
info "Shell" shell
info "Resolution" resolution
info "DE" de
info "WM" wm
info "WM Theme" wm_theme
info "Theme" theme
# ...
}
You can also move the lines inside the print_info()
function around to change the order they get printed in. See this custom ordering below:
print_info() {
info cols
info "OS" distro
info "Uptime" uptime
info "Kernel" kernel
prin
info "Model" model
info "Packages" packages
info "Shell" shell
info "Resolution" resolution
info "DE" de
info "WM" wm
info "WM Theme" wm_theme
info "Theme" theme
# ...
}
prin "Weather" "$(curl wttr.in/?0?q?T | awk '/°(C|F)/ {printf $(NF-1) $(NF) " ("a")"} /,/ {a=$0}')"
print_info () {
info cols
info "Model" model
info "OS" distro
info "Kernel" kernel
info "Uptime" uptime
info "Packages" packages
info "Shell" shell
info "Resolution" resolution
info "DE" de
info "WM" wm
info "WM Theme" wm_theme
info cols
}
You can make the script 2x faster by gathering the info asynchronously, the only caveat is that the order that all of the info is printed in will be based on what completes first. You can add this to your printinfo function by adding an &
sign to the info lines you want to be asynchronous then by adding a single wait
to the bottom of the function.
print_info () {
# Lines without an '&' sign will be displayed in
# the order they appear here.
info title
info underline
info "OS" distro &
info "Kernel" kernel &
info "Uptime" uptime &
info "Packages" packages &
info "Shell" shell &
info "Window Manager" wm &
info "GTK Theme" theme &
info "Icons" icons &
info "CPU" cpu &
info "GPU" gpu &
info "Memory" memory &
# Wait for the functions to complete
wait
info cols
}