]> arthur.barton.de Git - ax-zsh.git/blob - plugins/neofetch/neofetch.ax-io
neofetch: Add support for fastfetch(1)
[ax-zsh.git] / plugins / neofetch / neofetch.ax-io
1 # AX-ZSH: Alex' Modular ZSH Configuration
2 # neofetch.ax-io: Show fastfetch(1) [preferred] or neofetch(1) system information.
3
4 # Make sure that fastfetch(1) or neofetch(1) is installed.
5 (( $+commands[fastfetch] )) || (( $+commands[neofetch] )) || return 1
6
7 # Don't run this plugin on "check-plugins"!
8 [[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 0
9
10 axzsh_neofetch() {
11         if (( $+commands[fastfetch] )); then
12                 fastfetch \
13                         --structure Title:Separator:OS:Host:Kernel:Uptime:Packages:Shell:Display:DE:WM:WMTheme:Theme:Terminal:TerminalFont:CPU:GPU:Memory:Battery:PowerAdapter:Break \
14                         --percent-type 3 \
15                         --separator-string '~'
16         elif (( $+commands[neofetch] )); then
17                 neofetch \
18                         --color_blocks off \
19                         --disable packages \
20                         --shell_path on \
21                         --underline_char '~'
22         else
23                 echo "Neither fastfetch(1) nor neofetch(1) was found!" >&2
24                 return 1
25         fi
26 }
27
28 # Don't show any info when ~/.hushlogin exists ...
29 [[ -r ~/.hushlogin ]] && return 0
30
31 # Check if neofetch(1) infos have been shown during last 60 minutes, and if so,
32 # don't show them now but return.
33 [[ -z $(find "$XDG_CACHE_HOME/axzsh_last_neofetch" -mmin -60 2>/dev/null) ]] || return 0
34
35 axzsh_neofetch
36
37 # Wtite "stamp" file.
38 [[ -w ~/ ]] && touch "$XDG_CACHE_HOME/axzsh_last_neofetch"