Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
neofetch
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ximper Linux
neofetch
Commits
d25b77b7
Commit
d25b77b7
authored
Nov 06, 2016
by
Dylan Araps
Committed by
GitHub
Nov 06, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #426 from dylanaraps/doublebracket
General: Swap to double bracket tests everywhere
parents
d9136113
880e6a43
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
175 additions
and
174 deletions
+175
-174
neofetch
neofetch
+175
-174
No files found.
neofetch
View file @
d25b77b7
...
@@ -43,19 +43,19 @@ getos() {
...
@@ -43,19 +43,19 @@ getos() {
getmodel
()
{
getmodel
()
{
case
"
$os
"
in
case
"
$os
"
in
"Linux"
)
"Linux"
)
if
[
-d
"/system/app/"
]
&&
[
-d
"/system/priv-app"
]
;
then
if
[
[
-d
"/system/app/"
&&
-d
"/system/priv-app"
]
]
;
then
model
=
"
$(
getprop ro.product.brand
)
$(
getprop ro.product.model
)
"
model
=
"
$(
getprop ro.product.brand
)
$(
getprop ro.product.model
)
"
elif
[
-f
/sys/devices/virtual/dmi/id/product_name
]
||
\
elif
[
[
-f
/sys/devices/virtual/dmi/id/product_name
]
]
||
\
[
-f
/sys/devices/virtual/dmi/id/product_version
]
;
then
[
[
-f
/sys/devices/virtual/dmi/id/product_version
]
]
;
then
model
=
"
$(
< /sys/devices/virtual/dmi/id/product_name
)
"
model
=
"
$(
< /sys/devices/virtual/dmi/id/product_name
)
"
model+
=
"
$(
< /sys/devices/virtual/dmi/id/product_version
)
"
model+
=
"
$(
< /sys/devices/virtual/dmi/id/product_version
)
"
model
=
"
${
model
/To Be Filled*
}
"
model
=
"
${
model
/To Be Filled*
}
"
elif
[
-f
/sys/firmware/devicetree/base/model
]
;
then
elif
[
[
-f
/sys/firmware/devicetree/base/model
]
]
;
then
model
=
"
$(
< /sys/firmware/devicetree/base/model
)
"
model
=
"
$(
< /sys/firmware/devicetree/base/model
)
"
elif
[
-f
/tmp/sysinfo/model
]
;
then
elif
[
[
-f
/tmp/sysinfo/model
]
]
;
then
model
=
"
$(
< /tmp/sysinfo/model
)
"
model
=
"
$(
< /tmp/sysinfo/model
)
"
fi
fi
;;
;;
...
@@ -123,7 +123,7 @@ getmodel() {
...
@@ -123,7 +123,7 @@ getmodel() {
# Distro {{{
# Distro {{{
getdistro
()
{
getdistro
()
{
[
"
$distro
"
]
&&
return
[
[
"
$distro
"
]
]
&&
return
case
"
$os
"
in
case
"
$os
"
in
"Linux"
|
"GNU"
)
"Linux"
|
"GNU"
)
...
@@ -136,7 +136,7 @@ getdistro() {
...
@@ -136,7 +136,7 @@ getdistro() {
esac
esac
ascii_distro
=
"Windows 10"
ascii_distro
=
"Windows 10"
elif
[
-f
"/etc/redstar-release"
]
;
then
elif
[
[
-f
"/etc/redstar-release"
]
]
;
then
case
"
$distro_shorthand
"
in
case
"
$distro_shorthand
"
in
"on"
|
"tiny"
)
distro
=
"Red Star OS"
;;
"on"
|
"tiny"
)
distro
=
"Red Star OS"
;;
*
)
distro
=
"Red Star OS
$(
awk
-F
'[^0-9*]'
'$0=$2'
/etc/redstar-release
)
"
*
)
distro
=
"Red Star OS
$(
awk
-F
'[^0-9*]'
'$0=$2'
/etc/redstar-release
)
"
...
@@ -160,7 +160,7 @@ getdistro() {
...
@@ -160,7 +160,7 @@ getdistro() {
"tiny"
)
distro
=
"
${
distro
//version*
}
"
;;
"tiny"
)
distro
=
"
${
distro
//version*
}
"
;;
esac
esac
elif
[
-d
"/system/app/"
]
&&
[
-d
"/system/priv-app"
]
;
then
elif
[
[
-d
"/system/app/"
&&
-d
"/system/priv-app"
]
]
;
then
distro
=
"Android
$(
getprop ro.build.version.release
)
"
distro
=
"Android
$(
getprop ro.build.version.release
)
"
else
else
...
@@ -169,6 +169,7 @@ getdistro() {
...
@@ -169,6 +169,7 @@ getdistro() {
source
"
$file
"
source
"
$file
"
done
done
# The 3rd line down matches the fold marker syntax. {{{
case
"
$distro_shorthand
"
in
case
"
$distro_shorthand
"
in
"on"
)
distro
=
"
${
NAME
:-${
DISTRIB_ID
}}
${
VERSION_ID
:-${
DISTRIB_RELEASE
}}
"
;;
"on"
)
distro
=
"
${
NAME
:-${
DISTRIB_ID
}}
${
VERSION_ID
:-${
DISTRIB_RELEASE
}}
"
;;
"tiny"
)
distro
=
"
${
NAME
:-${
DISTRIB_ID
:-${
TAILS_PRODUCT_NAME
}}}
"
;;
"tiny"
)
distro
=
"
${
NAME
:-${
DISTRIB_ID
:-${
TAILS_PRODUCT_NAME
}}}
"
;;
...
@@ -176,8 +177,8 @@ getdistro() {
...
@@ -176,8 +177,8 @@ getdistro() {
esac
esac
# Workarounds for distros that go against the os-release standard.
# Workarounds for distros that go against the os-release standard.
[
-z
"
${
distro
//
}
"
]
&&
distro
=
"
$(
awk
'/BLAG/ {print $1; exit}'
/etc/
*
ease /usr/lib/
*
ease
)
"
[
[
-z
"
${
distro
//
}
"
]
]
&&
distro
=
"
$(
awk
'/BLAG/ {print $1; exit}'
/etc/
*
ease /usr/lib/
*
ease
)
"
[
-z
"
${
distro
//
}
"
]
&&
distro
=
"
$(
awk
-F
'='
'{print $2; exit}'
/etc/
*
ease /usr/lib/
*
ease
)
"
[
[
-z
"
${
distro
//
}
"
]
]
&&
distro
=
"
$(
awk
-F
'='
'{print $2; exit}'
/etc/
*
ease /usr/lib/
*
ease
)
"
fi
fi
distro
=
"
${
distro
//\
"}"
distro
=
"
${
distro
//\
"}"
distro=
"
${
distro
//\
'}"
distro=
"
${
distro
//\
'}"
...
@@ -230,8 +231,8 @@ getdistro() {
...
@@ -230,8 +231,8 @@ getdistro() {
distro=
"
${
distro
/DragonFly/DragonFlyBSD
}
"
distro=
"
${
distro
/DragonFly/DragonFlyBSD
}
"
# Workarounds for FreeBSD based distros.
# Workarounds for FreeBSD based distros.
[
-f
"/etc/pcbsd-lang"
] && distro=
"PCBSD"
[
[ -f
"/etc/pcbsd-lang"
]
] && distro=
"PCBSD"
[
-f
"/etc/pacbsd-release"
] && distro=
"PacBSD"
[
[ -f
"/etc/pacbsd-release"
]
] && distro=
"PacBSD"
;;
;;
"Windows"
)
"Windows"
)
...
@@ -256,10 +257,10 @@ getdistro() {
...
@@ -256,10 +257,10 @@ getdistro() {
esac
esac
# Get architecture
# Get architecture
[
"
$os_arch
"
==
"on"
] && \
[
[
"
$os_arch
"
==
"on"
]
] && \
distro+=
"
$(
uname
-m
)
"
distro+=
"
$(
uname
-m
)
"
[
"
${
ascii_distro
:-
auto
}
"
==
"auto"
] && \
[
[
"
${
ascii_distro
:-
auto
}
"
==
"auto"
]
] && \
ascii_distro=
"
$(
trim
"
$distro
"
)
"
ascii_distro=
"
$(
trim
"
$distro
"
)
"
}
}
...
@@ -282,7 +283,7 @@ getkernel() {
...
@@ -282,7 +283,7 @@ getkernel() {
esac
esac
# Hardcode kernel settings in BSDs
# Hardcode kernel settings in BSDs
if [
"
$os
" == "
BSD
" ] && [[
! "
$distro
" =~ (PacBSD|PCBSD) ]]; then
if [
[ "
$os
" == "
BSD
" &&
! "
$distro
" =~ (PacBSD|PCBSD) ]]; then
case "
$distro_shorthand
" in
case "
$distro_shorthand
" in
"
on
" | "
tiny
") kernel=
$(
uname
-r
)
;;
"
on
" | "
tiny
") kernel=
$(
uname
-r
)
;;
*) unset kernel ;;
*) unset kernel ;;
...
@@ -405,7 +406,7 @@ getpackages() {
...
@@ -405,7 +406,7 @@ getpackages() {
if type -p pkg >/dev/null; then
if type -p pkg >/dev/null; then
packages="
$((
packages+
=
$(
ls
-1
/var/db/pkg |
wc
-l
)))
"
packages="
$((
packages+
=
$(
ls
-1
/var/db/pkg |
wc
-l
)))
"
[
"
$packages
" == "
0
"
] && packages="
$((
packages+
=
$(
pkg list |
wc
-l
)))
"
[
[ "
$packages
" == "
0
" ]
] && packages="
$((
packages+
=
$(
pkg list |
wc
-l
)))
"
fi
fi
type -p emerge >/dev/null &&
\
type -p emerge >/dev/null &&
\
...
@@ -431,7 +432,7 @@ getpackages() {
...
@@ -431,7 +432,7 @@ getpackages() {
;;
;;
"
Mac OS X
")
"
Mac OS X
")
[
-d "
/
usr/local/bin
"
] &&
\
[
[ -d "
/
usr/local/bin
" ]
] &&
\
packages="
$(($(
ls
-l
/usr/local/bin/ |
grep
-v
"
\(
../Cellar/
\|
brew
\)
"
|
wc
-l
)
-
1
))
"
packages="
$(($(
ls
-l
/usr/local/bin/ |
grep
-v
"
\(
../Cellar/
\|
brew
\)
"
|
wc
-l
)
-
1
))
"
type -p port >/dev/null &&
\
type -p port >/dev/null &&
\
...
@@ -463,7 +464,7 @@ getpackages() {
...
@@ -463,7 +464,7 @@ getpackages() {
packages="
$(
cygcheck
-cd
|
wc
-l
)
"
packages="
$(
cygcheck
-cd
|
wc
-l
)
"
# Count chocolatey packages
# Count chocolatey packages
[
-d "
/
cygdrive/c/ProgramData/chocolatey/lib
"
] &&
\
[
[ -d "
/
cygdrive/c/ProgramData/chocolatey/lib
" ]
] &&
\
packages="
$((
packages+
=
$(
ls
-1
/cygdrive/c/ProgramData/chocolatey/lib |
wc
-l
)))
"
packages="
$((
packages+
=
$(
ls
-1
/cygdrive/c/ProgramData/chocolatey/lib |
wc
-l
)))
"
;;
;;
...
@@ -472,7 +473,7 @@ getpackages() {
...
@@ -472,7 +473,7 @@ getpackages() {
;;
;;
esac
esac
[
"
$packages
" == "
0
"
] && unset packages
[
[ "
$packages
" == "
0
" ]
] && unset packages
}
}
# }}}
# }}}
...
@@ -485,7 +486,7 @@ getshell() {
...
@@ -485,7 +486,7 @@ getshell() {
"
off
") shell="
${
SHELL
##*/
}
" ;;
"
off
") shell="
${
SHELL
##*/
}
" ;;
esac
esac
if [
"
$shell_version
" == "
on
"
]; then
if [
[ "
$shell_version
" == "
on
" ]
]; then
shell+="
"
shell+="
"
case "
${
SHELL
##*/
}
" in
case "
${
SHELL
##*/
}
" in
"
bash
")
"
bash
")
...
@@ -538,7 +539,7 @@ getde() {
...
@@ -538,7 +539,7 @@ getde() {
;;
;;
esac
esac
if [
-n "
$DISPLAY
" ] && [ -z "
$de
"
]; then
if [
[ -n "
$DISPLAY
" && -z "
$de
" ]
]; then
de="
$(
xprop
-root
|
awk
'/KDE_SESSION_VERSION|^_MUFFIN|xfce4|xfce5/'
)
"
de="
$(
xprop
-root
|
awk
'/KDE_SESSION_VERSION|^_MUFFIN|xfce4|xfce5/'
)
"
case "
$de
" in
case "
$de
" in
...
@@ -556,7 +557,7 @@ getde() {
...
@@ -556,7 +557,7 @@ getde() {
# Window Manager {{{
# Window Manager {{{
getwm() {
getwm() {
if [
-n "
$DISPLAY
" ] && [ "
$os
" != "
Mac OS X
"
]; then
if [
[ -n "
$DISPLAY
" && "
$os
" != "
Mac OS X
" ]
]; then
id="
$(
xprop
-root
-notype
|
awk
'$1=="_NET_SUPPORTING_WM_CHECK:"{print $5}'
)
"
id="
$(
xprop
-root
-notype
|
awk
'$1=="_NET_SUPPORTING_WM_CHECK:"{print $5}'
)
"
wm="
$(
xprop
-id
"
$id
"
-notype
-f
_NET_WM_NAME 8t
)
"
wm="
$(
xprop
-id
"
$id
"
-notype
-f
_NET_WM_NAME 8t
)
"
wm="
${
wm
/*_NET_WM_NAME =
}
"
wm="
${
wm
/*_NET_WM_NAME =
}
"
...
@@ -573,7 +574,7 @@ getwm() {
...
@@ -573,7 +574,7 @@ getwm() {
"Mac OS X"
) wm=
"Quartz Compositor"
;;
"Mac OS X"
) wm=
"Quartz Compositor"
;;
"Windows"
)
"Windows"
)
wm=
"
$(
tasklist |
grep
-m
1
-o
-F
-e
"bugn"
-e
"Windawesome"
-e
"blackbox"
-e
"emerge"
-e
"litestep"
)
"
wm=
"
$(
tasklist |
grep
-m
1
-o
-F
-e
"bugn"
-e
"Windawesome"
-e
"blackbox"
-e
"emerge"
-e
"litestep"
)
"
[
"
$wm
"
==
"blackbox"
] && wm=
"bbLean (Blackbox)"
[
[
"
$wm
"
==
"blackbox"
]
] && wm=
"bbLean (Blackbox)"
wm=
"
${
wm
:+
$wm
,
}
Explorer"
wm=
"
${
wm
:+
$wm
,
}
Explorer"
;;
;;
esac
esac
...
@@ -585,8 +586,8 @@ getwm() {
...
@@ -585,8 +586,8 @@ getwm() {
# Window Manager Theme {{{
# Window Manager Theme {{{
getwmtheme() {
getwmtheme() {
[
-z "
$wm
"
] && getwm
[
[ -z "
$wm
" ]
] && getwm
[
-z "
$de
"
] && getde
[
[ -z "
$de
" ]
] && getde
case "
$wm
" in
case "
$wm
" in
"
E16
") wmtheme="
$(
awk
-F
"= "
'/theme.name/ {print $2}'
"
$HOME
/.e16/e_config--0.0.cfg"
)
";;
"
E16
") wmtheme="
$(
awk
-F
"= "
'/theme.name/ {print $2}'
"
$HOME
/.e16/e_config--0.0.cfg"
)
";;
...
@@ -602,7 +603,7 @@ getwmtheme() {
...
@@ -602,7 +603,7 @@ getwmtheme() {
if type -p gsettings >/dev/null; then
if type -p gsettings >/dev/null; then
wmtheme="
$(
gsettings get org.gnome.shell.extensions.user-theme name
)
"
wmtheme="
$(
gsettings get org.gnome.shell.extensions.user-theme name
)
"
[
-z "
${
wmtheme
//\
'}"
] && \
[
[ -z "
${
wmtheme
//\
'}" ]
] && \
wmtheme="$(gsettings get org.gnome.desktop.wm.preferences theme)"
wmtheme="$(gsettings get org.gnome.desktop.wm.preferences theme)"
elif type -p gconftool-2 >/dev/null; then
elif type -p gconftool-2 >/dev/null; then
...
@@ -611,7 +612,7 @@ getwmtheme() {
...
@@ -611,7 +612,7 @@ getwmtheme() {
;;
;;
"Metacity"*)
"Metacity"*)
if [
"$de" == "Deepin"
]; then
if [
[ "$de" == "Deepin" ]
]; then
wmtheme="$(gsettings get com.deepin.wrap.gnome.desktop.wm.preferences theme)"
wmtheme="$(gsettings get com.deepin.wrap.gnome.desktop.wm.preferences theme)"
else
else
...
@@ -628,20 +629,20 @@ getwmtheme() {
...
@@ -628,20 +629,20 @@ getwmtheme() {
;;
;;
"Fluxbox"
)
"Fluxbox"
)
[
-f
"
$HOME
/.fluxbox/init"
] && \
[
[ -f
"
$HOME
/.fluxbox/init"
]
] && \
wmtheme=
"
$(
awk
-F
"/"
'/styleFile/ {print $NF}'
"
$HOME
/.fluxbox/init"
)
"
wmtheme=
"
$(
awk
-F
"/"
'/styleFile/ {print $NF}'
"
$HOME
/.fluxbox/init"
)
"
;;
;;
"IceWM"
*)
"IceWM"
*)
[
-f
"
$HOME
/.icewm/theme"
] && \
[
[ -f
"
$HOME
/.icewm/theme"
]
] && \
wmtheme=
"
$(
awk
-F
"[
\"
,/]"
'!/#/ {print $2}'
"
$HOME
/.icewm/theme"
)
"
wmtheme=
"
$(
awk
-F
"[
\"
,/]"
'!/#/ {print $2}'
"
$HOME
/.icewm/theme"
)
"
;;
;;
"Openbox"
)
"Openbox"
)
if [
"
$de
"
==
"LXDE"
] && [ -f
"
${
HOME
}
/.config/openbox/lxde-rc.xml"
]; then
if [
[
"
$de
"
==
"LXDE"
&& -f
"
${
HOME
}
/.config/openbox/lxde-rc.xml"
]
]; then
ob_file=
"lxde-rc"
ob_file=
"lxde-rc"
elif [
-f
"
${
HOME
}
/.config/openbox/rc.xml"
]; then
elif [
[ -f
"
${
HOME
}
/.config/openbox/rc.xml"
]
]; then
ob_file=
"rc"
ob_file=
"rc"
fi
fi
...
@@ -649,12 +650,12 @@ getwmtheme() {
...
@@ -649,12 +650,12 @@ getwmtheme() {
;;
;;
"PekWM"
)
"PekWM"
)
[
-f
"
$HOME
/.pekwm/config"
] && \
[
[ -f
"
$HOME
/.pekwm/config"
]
] && \
wmtheme=
"
$(
awk
-F
"/"
'/Theme/ {gsub(/\"/,""); print $NF}'
"
$HOME
/.pekwm/config"
)
"
wmtheme=
"
$(
awk
-F
"/"
'/Theme/ {gsub(/\"/,""); print $NF}'
"
$HOME
/.pekwm/config"
)
"
;;
;;
"Xfwm4"
)
"Xfwm4"
)
[
-f
"
${
HOME
}
/.config/xfce4/xfconf/xfce-perchannel-xml/xfwm4.xml"
] && \
[
[ -f
"
${
HOME
}
/.config/xfce4/xfconf/xfce-perchannel-xml/xfwm4.xml"
]
] && \
wmtheme=
"
$(
xfconf-query
-c
xfwm4
-p
/general/theme
)
"
wmtheme=
"
$(
xfconf-query
-c
xfwm4
-p
/general/theme
)
"
;;
;;
...
@@ -662,17 +663,17 @@ getwmtheme() {
...
@@ -662,17 +663,17 @@ getwmtheme() {
kdeconfigdir
kdeconfigdir
kde_config_dir=
"
${
kde_config_dir
%/
}
"
kde_config_dir=
"
${
kde_config_dir
%/
}
"
if [
-f
"
$kde_config_dir
/share/config/kwinrc"
]; then
if [
[ -f
"
$kde_config_dir
/share/config/kwinrc"
]
]; then
wmtheme=
"
$(
awk
'/PluginLib=kwin3_/{gsub(/PluginLib=kwin3_/,"",$0); print $0; exit}'
"
$kde_config_dir
/share/config/kwinrc"
)
"
wmtheme=
"
$(
awk
'/PluginLib=kwin3_/{gsub(/PluginLib=kwin3_/,"",$0); print $0; exit}'
"
$kde_config_dir
/share/config/kwinrc"
)
"
elif [
-f
"
$kde_config_dir
/share/config/kdebugrc"
]; then
elif [
[ -f
"
$kde_config_dir
/share/config/kdebugrc"
]
]; then
wmtheme=
"
$(
awk
'/(decoration)/ {gsub(/\[/,"",$1); print $1; exit}'
"
$kde_config_dir
/share/config/kdebugrc"
)
"
wmtheme=
"
$(
awk
'/(decoration)/ {gsub(/\[/,"",$1); print $1; exit}'
"
$kde_config_dir
/share/config/kdebugrc"
)
"
fi
fi
;;
;;
"Quartz Compositor"
)
"Quartz Compositor"
)
wmtheme=
"
$(
/usr/libexec/PlistBuddy
-c
"Print AppleAquaColorVariant"
~/Library/Preferences/.GlobalPreferences.plist
)
"
wmtheme=
"
$(
/usr/libexec/PlistBuddy
-c
"Print AppleAquaColorVariant"
~/Library/Preferences/.GlobalPreferences.plist
)
"
if [
-z
"
$wmtheme
"
] || [
"
$wmtheme
"
==
"1"
]; then
if [
[ -z
"
$wmtheme
"
||
"
$wmtheme
"
==
"1"
]
]; then
wmtheme=
"Blue"
wmtheme=
"Blue"
else
else
wmtheme=
"Graphite"
wmtheme=
"Graphite"
...
@@ -700,7 +701,7 @@ getwmtheme() {
...
@@ -700,7 +701,7 @@ getwmtheme() {
esac
esac
wmtheme=
"
${
wmtheme
//\
'}"
wmtheme=
"
${
wmtheme
//\
'}"
[
"$version" -ge 4
] && wmtheme="${wmtheme^}"
[
[ "$version" -ge 4 ]
] && wmtheme="${wmtheme^}"
}
}
# }}}
# }}}
...
@@ -726,7 +727,7 @@ getcpu() {
...
@@ -726,7 +727,7 @@ getcpu() {
temp_dir=
"/sys/class/hwmon/hwmon0/temp1_input"
temp_dir=
"/sys/class/hwmon/hwmon0/temp1_input"
# Get cpu speed
# Get cpu speed
if [
-d
"
$speed_dir
"
]; then
if [
[ -d
"
$speed_dir
"
]
]; then
case
"
$speed_type
"
in
case
"
$speed_type
"
in
current) speed_type=
"scaling_cur_freq"
;;
current) speed_type=
"scaling_cur_freq"
;;
min) speed_type=
"scaling_min_freq"
;;
min) speed_type=
"scaling_min_freq"
;;
...
@@ -748,7 +749,7 @@ getcpu() {
...
@@ -748,7 +749,7 @@ getcpu() {
fi
fi
# Get cpu temp
# Get cpu temp
if [
"
$cpu_temp
"
==
"on"
] && [ -f
"
$temp_dir
"
]; then
if [
[
"
$cpu_temp
"
==
"on"
&& -f
"
$temp_dir
"
]
]; then
temp=
"
$(
<
"
$temp_dir
"
)
"
temp=
"
$(
<
"
$temp_dir
"
)
"
temp=
"
$((
temp
*
100
/
10000
))
"
temp=
"
$((
temp
*
100
/
10000
))
"
temp=
"[
${
temp
/
${
temp
:
-1
}}
.
${
temp
:
-1
}
°C]"
temp=
"[
${
temp
/
${
temp
:
-1
}}
.
${
temp
:
-1
}
°C]"
...
@@ -806,7 +807,7 @@ getcpu() {
...
@@ -806,7 +807,7 @@ getcpu() {
# Get cpu speed
# Get cpu speed
speed=
"
$(
sysctl
-n
hw.cpuspeed
)
"
speed=
"
$(
sysctl
-n
hw.cpuspeed
)
"
[
-z
"
$speed
"
] && speed=
"
$(
sysctl
-n
hw.clockrate
)
"
[
[ -z
"
$speed
"
]
] && speed=
"
$(
sysctl
-n
hw.clockrate
)
"
speed=
"
$((
speed
/
100
))
"
speed=
"
$((
speed
/
100
))
"
# Get cpu cores
# Get cpu cores
...
@@ -845,7 +846,7 @@ getcpu() {
...
@@ -845,7 +846,7 @@ getcpu() {
"Mac OS X"
|
"iPhone OS"
) ;;
"Mac OS X"
|
"iPhone OS"
) ;;
*)
*)
# Fix for speeds under 1ghz
# Fix for speeds under 1ghz
if [
-z
"
${
speed
:1
}
"
]; then
if [
[ -z
"
${
speed
:1
}
"
]
]; then
speed=
"0.
${
speed
}
"
speed=
"0.
${
speed
}
"
else
else
speed=
"
${
speed
:0:1
}
.
${
speed
:1
}
"
speed=
"
${
speed
:0:1
}
.
${
speed
:1
}
"
...
@@ -871,11 +872,11 @@ getcpu() {
...
@@ -871,11 +872,11 @@ getcpu() {
cpu=
"
${
cpu
//with Radeon HD Graphics
}
"
cpu=
"
${
cpu
//with Radeon HD Graphics
}
"
# Add cpu cores to output
# Add cpu cores to output
[
"
$cpu_cores
"
!=
"off"
] && [
"
$cores
"
] && \
[
[
"
$cpu_cores
"
!=
"off"
&&
"
$cores
"
]
] && \
cpu=
"
${
cpu
/@/(
${
cores
}
) @
}
"
cpu=
"
${
cpu
/@/(
${
cores
}
) @
}
"
# Remove speed from output
# Remove speed from output
[
"
$cpu_speed
"
==
"off"
] && \
[
[
"
$cpu_speed
"
==
"off"
]
] && \
cpu=
"
${
cpu
/@ *GHz
}
"
cpu=
"
${
cpu
/@ *GHz
}
"
# Make the output of cpu shorter
# Make the output of cpu shorter
...
@@ -910,7 +911,7 @@ getcpu_usage() {
...
@@ -910,7 +911,7 @@ getcpu_usage() {
"Linux"
|
"Mac OS X"
|
"iPhone OS"
|
"BSD"
|
"Solaris"
|
"GNU"
)
"Linux"
|
"Mac OS X"
|
"iPhone OS"
|
"BSD"
|
"Solaris"
|
"GNU"
)
# Get cores if unset
# Get cores if unset
if
[
-z
"
$cores
"
]
;
then
if
[
[
-z
"
$cores
"
]
]
;
then
case
"
$os
"
in
case
"
$os
"
in
"Linux"
)
cores
=
"
$(
awk
-F
': '
'/siblings/ {printf $2; exit}'
/proc/cpuinfo
)
"
;;
"Linux"
)
cores
=
"
$(
awk
-F
': '
'/siblings/ {printf $2; exit}'
/proc/cpuinfo
)
"
;;
"Mac OS X"
|
"BSD"
)
cores
=
"
$(
sysctl
-n
hw.ncpu
)
"
;;
"Mac OS X"
|
"BSD"
)
cores
=
"
$(
sysctl
-n
hw.ncpu
)
"
;;
...
@@ -941,12 +942,12 @@ getgpu() {
...
@@ -941,12 +942,12 @@ getgpu() {
case
"
$os
"
in
case
"
$os
"
in
"Linux"
|
"GNU"
)
"Linux"
|
"GNU"
)
# Use cache if it exists
# Use cache if it exists
if
[
-f
"/tmp/neofetch/gpu"
]
;
then
if
[
[
-f
"/tmp/neofetch/gpu"
]
]
;
then
source
"/tmp/neofetch/gpu"
source
"/tmp/neofetch/gpu"
else
else
bdf_number
=
"
$(
PATH
=
"/sbin:
$PATH
"
lspci
-k
|
grep
-A2
-F
'VGA'
|
grep
-B2
-F
'Kernel driver in use'
|
awk
'/^\w/ {print $1}'
)
"
bdf_number
=
"
$(
PATH
=
"/sbin:
$PATH
"
lspci
-k
|
grep
-A2
-F
'VGA'
|
grep
-B2
-F
'Kernel driver in use'
|
awk
'/^\w/ {print $1}'
)
"
if
[
-z
"
$bdf_number
"
]
;
then
if
[
[
-z
"
$bdf_number
"
]
]
;
then
# Fallback if no kernel driver is in use
# Fallback if no kernel driver is in use
gpu
=
"
$(
PATH
=
"/sbin:
$PATH
"
lspci
-mm
|
awk
-F
'\\"|\\" \\"'
'/3D|VGA/ {print $3 " " $4}'
)
"
gpu
=
"
$(
PATH
=
"/sbin:
$PATH
"
lspci
-mm
|
awk
-F
'\\"|\\" \\"'
'/3D|VGA/ {print $3 " " $4}'
)
"
...
@@ -983,7 +984,7 @@ getgpu() {
...
@@ -983,7 +984,7 @@ getgpu() {
"Mac OS X"
)
"Mac OS X"
)
# Use cache if it exists
# Use cache if it exists
if
[
-f
"/Library/Caches/neofetch/gpu"
]
;
then
if
[
[
-f
"/Library/Caches/neofetch/gpu"
]
]
;
then
source
"/Library/Caches/neofetch/gpu"
source
"/Library/Caches/neofetch/gpu"
else
else
gpu
=
"
$(
system_profiler SPDisplaysDataType |
awk
-F
': '
'/^\ *Chipset Model:/ {printf $2 ", "}'
)
"
gpu
=
"
$(
system_profiler SPDisplaysDataType |
awk
-F
': '
'/^\ *Chipset Model:/ {printf $2 ", "}'
)
"
...
@@ -1050,7 +1051,7 @@ getgpu() {
...
@@ -1050,7 +1051,7 @@ getgpu() {
;;
;;
esac
esac
if
[
"
$gpu_brand
"
==
"off"
]
;
then
if
[
[
"
$gpu_brand
"
==
"off"
]
]
;
then
gpu
=
"
${
gpu
/AMD
}
"
gpu
=
"
${
gpu
/AMD
}
"
gpu
=
"
${
gpu
/NVIDIA
}
"
gpu
=
"
${
gpu
/NVIDIA
}
"
gpu
=
"
${
gpu
/Intel
}
"
gpu
=
"
${
gpu
/Intel
}
"
...
@@ -1231,11 +1232,11 @@ getsong() {
...
@@ -1231,11 +1232,11 @@ getsong() {
esac
esac
# Display Artist and Title on seperate lines.
# Display Artist and Title on seperate lines.
if [
"
$song_shorthand
"
==
"on"
]; then
if [
[
"
$song_shorthand
"
==
"on"
]
]; then
artist=
"
${
song
/ -*
}
"
artist=
"
${
song
/ -*
}
"
song=
"
${
song
/
$artist
-
}
"
song=
"
${
song
/
$artist
-
}
"
if [
"
$song
"
!=
"
$artist
"
]; then
if [
[
"
$song
"
!=
"
$artist
"
]
]; then
prin
"Artist"
"
$artist
"
prin
"Artist"
"
$artist
"
prin
"Song"
"
$song
"
prin
"Song"
"
$song
"
else
else
...
@@ -1276,10 +1277,10 @@ getresolution() {
...
@@ -1276,10 +1277,10 @@ getresolution() {
scale_factor="
$(
/usr/libexec/PlistBuddy
-c
"Print DisplayAnyUserSets:0:0:Resolution"
/Library/Preferences/com.apple.windowserver.plist
)
"
scale_factor="
$(
/usr/libexec/PlistBuddy
-c
"Print DisplayAnyUserSets:0:0:Resolution"
/Library/Preferences/com.apple.windowserver.plist
)
"
[
"
${
scale_factor
%.*
}
" == "
2
"
] &&
\
[
[ "
${
scale_factor
%.*
}
" == "
2
" ]
] &&
\
resolution="
${
resolution
// @/@2x @
}
"
resolution="
${
resolution
// @/@2x @
}
"
if [
"
$refresh_rate
" == "
off
"
]; then
if [
[ "
$refresh_rate
" == "
off
" ]
]; then
resolution="
${
resolution
// @ [0-9][0-9]Hz
}
"
resolution="
${
resolution
// @ [0-9][0-9]Hz
}
"
resolution="
${
resolution
// @ [0-9][0-9][0-9]Hz
}
"
resolution="
${
resolution
// @ [0-9][0-9][0-9]Hz
}
"
fi
fi
...
@@ -1295,13 +1296,13 @@ getresolution() {
...
@@ -1295,13 +1296,13 @@ getresolution() {
height="
$(
wmic path Win32_VideoController get CurrentVerticalResolution /value
)
"
height="
$(
wmic path Win32_VideoController get CurrentVerticalResolution /value
)
"
height="
${
height
/CurrentVerticalResolution
'='
/
}
"
height="
${
height
/CurrentVerticalResolution
'='
/
}
"
[
"
$width
"
] && resolution="
${
width
}
x
${
height
}
"
[
[ "
$width
" ]
] && resolution="
${
width
}
x
${
height
}
"
;;
;;
"
Haiku
")
"
Haiku
")
resolution="
$(
screenmode |
awk
-F
' |, '
'{printf $2 "x" $3 " @ " $6 $7}'
)
"
resolution="
$(
screenmode |
awk
-F
' |, '
'{printf $2 "x" $3 " @ " $6 $7}'
)
"
[
"
$refresh_rate
" == "
off
"
] && resolution="
${
resolution
/ @*
}
"
[
[ "
$refresh_rate
" == "
off
" ]
] && resolution="
${
resolution
/ @*
}
"
;;
;;
esac
esac
...
@@ -1343,20 +1344,20 @@ getstyle() {
...
@@ -1343,20 +1344,20 @@ getstyle() {
;;
;;
esac
esac
if [
-n "
$DISPLAY
" ] && [ "
$os
" != "
Mac OS X
"
]; then
if [
[ -n "
$DISPLAY
" && "
$os
" != "
Mac OS X
" ]
]; then
# Get DE if user has disabled the function.
# Get DE if user has disabled the function.
[
-z "
$de
"
] && getde
[
[ -z "
$de
" ]
] && getde
case "
$de
" in
case "
$de
" in
"
KDE
"*)
"
KDE
"*)
kdeconfigdir
kdeconfigdir
if [
-f "
${
kde_config_dir
}
/share/config/kdeglobals
"
]; then
if [
[ -f "
${
kde_config_dir
}
/share/config/kdeglobals
" ]
]; then
kde_config_file="
${
kde_config_dir
}
/share/config/kdeglobals
"
kde_config_file="
${
kde_config_dir
}
/share/config/kdeglobals
"
theme="
$(
grep
"^[^#]*
$kde
"
"
$kde_config_file
"
)
"
theme="
$(
grep
"^[^#]*
$kde
"
"
$kde_config_file
"
)
"
theme="
${
theme
/
${
kde
}
*=
}
"
theme="
${
theme
/
${
kde
}
*=
}
"
[
"
$version
" -ge 4
] && theme="
${
theme
^
}
"
[
[ "
$version
" -ge 4 ]
] && theme="
${
theme
^
}
"
gtk_shorthand="
on
"
gtk_shorthand="
on
"
return
return
...
@@ -1392,14 +1393,14 @@ getstyle() {
...
@@ -1392,14 +1393,14 @@ getstyle() {
esac
esac
# Check for gtk2 theme
# Check for gtk2 theme
if [
-z "
$gtk2theme
"
]; then
if [
[ -z "
$gtk2theme
" ]
]; then
if [
-f "
${
GTK2_RC_FILES
:-
$HOME
/.gtkrc-2.0
}
"
]; then
if [
[ -f "
${
GTK2_RC_FILES
:-
$HOME
/.gtkrc-2.0
}
" ]
]; then
gtk2theme="
$(
grep
"^[^#]*
$name
"
"
${
GTK2_RC_FILES
:-
$HOME
/.gtkrc-2.0
}
"
)
"
gtk2theme="
$(
grep
"^[^#]*
$name
"
"
${
GTK2_RC_FILES
:-
$HOME
/.gtkrc-2.0
}
"
)
"
elif [
-f "
/usr/share/gtk-2.0/gtkrc
"
]; then
elif [
[ -f "
/usr/share/gtk-2.0/gtkrc
" ]
]; then
gtk2theme="
$(
grep
"^[^#]*
$name
"
/usr/share/gtk-2.0/gtkrc
)
"
gtk2theme="
$(
grep
"^[^#]*
$name
"
/usr/share/gtk-2.0/gtkrc
)
"
elif [
-f "
/etc/gtk-2.0/gtkrc
"
]; then
elif [
[ -f "
/etc/gtk-2.0/gtkrc
" ]
]; then
gtk2theme="
$(
grep
"^[^#]*
$name
"
/etc/gtk-2.0/gtkrc
)
"
gtk2theme="
$(
grep
"^[^#]*
$name
"
/etc/gtk-2.0/gtkrc
)
"
fi
fi
...
@@ -1407,17 +1408,17 @@ getstyle() {
...
@@ -1407,17 +1408,17 @@ getstyle() {
fi
fi
# Check for gtk3 theme
# Check for gtk3 theme
if [
-z "
$gtk3theme
"
]; then
if [
[ -z "
$gtk3theme
" ]
]; then
if [
-f "
$XDG_CONFIG_HOME
/gtk-3.0/settings.ini
"
]; then
if [
[ -f "
$XDG_CONFIG_HOME
/gtk-3.0/settings.ini
" ]
]; then
gtk3theme="
$(
grep
"^[^#]*
$name
"
"
$XDG_CONFIG_HOME
/gtk-3.0/settings.ini"
)
"
gtk3theme="
$(
grep
"^[^#]*
$name
"
"
$XDG_CONFIG_HOME
/gtk-3.0/settings.ini"
)
"
elif type -p gsettings >/dev/null; then
elif type -p gsettings >/dev/null; then
gtk3theme="
$(
gsettings get org.gnome.desktop.interface
"
$gsettings
"
)
"
gtk3theme="
$(
gsettings get org.gnome.desktop.interface
"
$gsettings
"
)
"
elif [
-f "
/usr/share/gtk-3.0/settings.ini
"
]; then
elif [
[ -f "
/usr/share/gtk-3.0/settings.ini
" ]
]; then
gtk3theme="
$(
grep
"^[^#]*
$name
"
/usr/share/gtk-3.0/settings.ini
)
"
gtk3theme="
$(
grep
"^[^#]*
$name
"
/usr/share/gtk-3.0/settings.ini
)
"
elif [
-f "
/etc/gtk-3.0/settings.ini
"
]; then
elif [
[ -f "
/etc/gtk-3.0/settings.ini
" ]
]; then
gtk3theme="
$(
grep
"^[^#]*
$name
"
/etc/gtk-3.0/settings.ini
)
"
gtk3theme="
$(
grep
"^[^#]*
$name
"
/etc/gtk-3.0/settings.ini
)
"
fi
fi
...
@@ -1431,37 +1432,37 @@ getstyle() {
...
@@ -1431,37 +1432,37 @@ getstyle() {
gtk3theme=${gtk3theme//\'
}
gtk3theme=${gtk3theme//\'
}
# Uppercase the first letter of each gtk theme
# Uppercase the first letter of each gtk theme
if [
"
$version
" -ge 4
]; then
if [
[ "
$version
" -ge 4 ]
]; then
gtk2theme="
${
gtk2theme
^
}
"
gtk2theme="
${
gtk2theme
^
}
"
gtk3theme="
${
gtk3theme
^
}
"
gtk3theme="
${
gtk3theme
^
}
"
fi
fi
# Toggle visibility of gtk themes.
# Toggle visibility of gtk themes.
[
"
$gtk2
" == "
off
"
] && unset gtk2theme
[
[ "
$gtk2
" == "
off
" ]
] && unset gtk2theme
[
"
$gtk3
" == "
off
"
] && unset gtk3theme
[
[ "
$gtk3
" == "
off
" ]
] && unset gtk3theme
# Trim whitespace
# Trim whitespace
gtk2theme="
$(
trim
"
$gtk2theme
"
)
"
gtk2theme="
$(
trim
"
$gtk2theme
"
)
"
gtk3theme="
$(
trim
"
$gtk3theme
"
)
"
gtk3theme="
$(
trim
"
$gtk3theme
"
)
"
# Format the string based on which themes exist
# Format the string based on which themes exist
if [
"
$gtk2theme
" ] && [ "
$gtk2theme
" == "
$gtk3theme
"
]; then
if [
[ "
$gtk2theme
" && "
$gtk2theme
" == "
$gtk3theme
" ]
]; then
gtk3theme+="
[GTK2/3]
"
gtk3theme+="
[GTK2/3]
"
unset gtk2theme
unset gtk2theme
elif [
"
$gtk2theme
" ] && [ "
$gtk3theme
"
]; then
elif [
[ "
$gtk2theme
" && "
$gtk3theme
" ]
]; then
gtk2theme+="
[GTK2],
"
gtk2theme+="
[GTK2],
"
gtk3theme+="
[GTK3]
"
gtk3theme+="
[GTK3]
"
else
else
[
"
$gtk2theme
"
] && gtk2theme+="
[GTK2]
"
[
[ "
$gtk2theme
" ]
] && gtk2theme+="
[GTK2]
"
[
"
$gtk3theme
"
] && gtk3theme+="
[GTK3]
"
[
[ "
$gtk3theme
" ]
] && gtk3theme+="
[GTK3]
"
fi
fi
# Final string
# Final string
theme="
${
gtk2theme
}${
gtk3theme
}
"
theme="
${
gtk2theme
}${
gtk3theme
}
"
# Make the output shorter by removing "
[GTKX]
" from the string
# Make the output shorter by removing "
[GTKX]
" from the string
if [
"
$gtk_shorthand
" == "
on
"
]; then
if [
[ "
$gtk_shorthand
" == "
on
" ]
]; then
theme="
${
theme
/
'[GTK2]'
}
"
theme="
${
theme
/
'[GTK2]'
}
"
theme="
${
theme
/
'[GTK3]'
}
"
theme="
${
theme
/
'[GTK3]'
}
"
theme="
${
theme
/
'[GTK2/3]'
}
"
theme="
${
theme
/
'[GTK2/3]'
}
"
...
@@ -1536,7 +1537,7 @@ getterm() {
...
@@ -1536,7 +1537,7 @@ getterm() {
# Terminal Emulator Font {{{
# Terminal Emulator Font {{{
gettermfont() {
gettermfont() {
[
-z "
$term
"
] && getterm
[
[ -z "
$term
" ]
] && getterm
case "
$term
" in
case "
$term
" in
"
urxvt
" | "
urxvtd
" | "
xterm
")
"
urxvt
" | "
urxvtd
" | "
xterm
")
...
@@ -1583,7 +1584,7 @@ gettermfont() {
...
@@ -1583,7 +1584,7 @@ gettermfont() {
;;
;;
esac
esac
[
"
$version
" -ge 4
] && termfont="
${
termfont
^
}
"
[
[ "
$version
" -ge 4 ]
] && termfont="
${
termfont
^
}
"
}
}
# }}}
# }}}
...
@@ -1632,14 +1633,14 @@ getdisk() {
...
@@ -1632,14 +1633,14 @@ getdisk() {
disk_total="
${
disk_total
/G
}
"
disk_total="
${
disk_total
/G
}
"
# Convert Terabytes to Gigabytes.
# Convert Terabytes to Gigabytes.
if [
"
$disk_display
" != "
off
"
]; then
if [
[ "
$disk_display
" != "
off
" ]
]; then
disk_used="
${
disk_used
/\.
}
"
disk_used="
${
disk_used
/\.
}
"
disk_total="
${
disk_total
/\.
}
"
disk_total="
${
disk_total
/\.
}
"
[
"
${
disk_used
:
-1
}
" == "
T
"
] &&
\
[
[ "
${
disk_used
:
-1
}
" == "
T
" ]
] &&
\
disk_used="
$((${
disk_used
/T
}
*
100
))
"
disk_used="
$((${
disk_used
/T
}
*
100
))
"
[
"
${
disk_total
:
-1
}
" == "
T
"
] &&
\
[
[ "
${
disk_total
:
-1
}
" == "
T
" ]
] &&
\
disk_total="
$((${
disk_total
/T
}
*
100
))
"
disk_total="
$((${
disk_total
/T
}
*
100
))
"
fi
fi
...
@@ -1660,7 +1661,7 @@ getbattery() {
...
@@ -1660,7 +1661,7 @@ getbattery() {
"
Linux
")
"
Linux
")
# We use 'prin' here and exit the function early so that we can
# We use 'prin' here and exit the function early so that we can
# do multi battery support with a single battery per line.
# do multi battery support with a single battery per line.
if [
-f /sys/class/power_supply/**/capacity
]; then
if [
[ -f /sys/class/power_supply/**/capacity ]
]; then
for bat in "
/sys/class/power_supply/BAT
"*; do
for bat in "
/sys/class/power_supply/BAT
"*; do
capacity="
$(
<
"
${
bat
}
/capacity"
)
"
capacity="
$(
<
"
${
bat
}
/capacity"
)
"
status="
$(
<
"
${
bat
}
/status"
)
"
status="
$(
<
"
${
bat
}
/status"
)
"
...
@@ -1668,7 +1669,7 @@ getbattery() {
...
@@ -1668,7 +1669,7 @@ getbattery() {
# Fix for bash on Windows 10 which includes /proc files
# Fix for bash on Windows 10 which includes /proc files
# for battery usage despite there not being a battery
# for battery usage despite there not being a battery
# installed.
# installed.
[
-z "
$capacity
"
] && return
[
[ -z "
$capacity
" ]
] && return
battery="
${
capacity
}
% [
${
status
}
]
"
battery="
${
capacity
}
% [
${
status
}
]
"
...
@@ -1704,7 +1705,7 @@ getbattery() {
...
@@ -1704,7 +1705,7 @@ getbattery() {
battery0now="
$(
sysctl
-n
hw.sensors.acpibat0.watthour3
)
"
battery0now="
$(
sysctl
-n
hw.sensors.acpibat0.watthour3
)
"
battery0now="
${
battery0now
/ Wh*
}
"
battery0now="
${
battery0now
/ Wh*
}
"
[
"
$battery0full
"
] &&
\
[
[ "
$battery0full
" ]
] &&
\
battery="
$((
100
*
${
battery0now
/\.
}
/
${
battery0full
/\.
}))
%
"
battery="
$((
100
*
${
battery0now
/\.
}
/
${
battery0full
/\.
}))
%
"
;;
;;
esac
esac
...
@@ -1718,7 +1719,7 @@ getbattery() {
...
@@ -1718,7 +1719,7 @@ getbattery() {
"
Windows
")
"
Windows
")
battery="
$(
wmic Path Win32_Battery get EstimatedChargeRemaining /value
)
"
battery="
$(
wmic Path Win32_Battery get EstimatedChargeRemaining /value
)
"
battery="
${
battery
/EstimatedChargeRemaining
'='
}
"
battery="
${
battery
/EstimatedChargeRemaining
'='
}
"
[
"
$battery
"
] && battery+="
%
"
[
[ "
$battery
" ]
] && battery+="
%
"
;;
;;
"
Haiku
")
"
Haiku
")
...
@@ -1728,7 +1729,7 @@ getbattery() {
...
@@ -1728,7 +1729,7 @@ getbattery() {
;;
;;
esac
esac
[
"
$battery_state
"
] && battery+="
Charging
"
[
[ "
$battery_state
" ]
] && battery+="
Charging
"
case "
$battery_display
" in
case "
$battery_display
" in
"
bar
") battery="
$(
bar
"
${
battery
/
'%'
*
}
"
100
)
" ;;
"
bar
") battery="
$(
bar
"
${
battery
/
'%'
*
}
"
100
)
" ;;
...
@@ -1749,7 +1750,7 @@ getlocalip() {
...
@@ -1749,7 +1750,7 @@ getlocalip() {
"
Mac
OS X
" | "
iPhone
OS
")
"
Mac
OS X
" | "
iPhone
OS
")
localip="
$(
ipconfig getifaddr en0
)
"
localip="
$(
ipconfig getifaddr en0
)
"
[
-z "
$localip
"
] && localip="
$(
ipconfig getifaddr en1
)
"
[
[ -z "
$localip
" ]
] && localip="
$(
ipconfig getifaddr en1
)
"
;;
;;
"
BSD
" | "
Solaris
")
"
BSD
" | "
Solaris
")
...
@@ -1772,11 +1773,11 @@ getpublicip() {
...
@@ -1772,11 +1773,11 @@ getpublicip() {
publicip="
$(
dig +time
=
1 +tries
=
1 +short myip.opendns.com @resolver1.opendns.com
)
"
publicip="
$(
dig +time
=
1 +tries
=
1 +short myip.opendns.com @resolver1.opendns.com
)
"
fi
fi
if [
-z "
$publicip
"
] && type -p curl >/dev/null; then
if [
[ -z "
$publicip
" ]
] && type -p curl >/dev/null; then
publicip="
$(
curl
--max-time
10
-w
'\n'
"
$public_ip_host
"
)
"
publicip="
$(
curl
--max-time
10
-w
'\n'
"
$public_ip_host
"
)
"
fi
fi
if [
-z "
$publicip
"
] && type -p wget >/dev/null; then
if [
[ -z "
$publicip
" ]
] && type -p wget >/dev/null; then
publicip="
$(
wget
-T
10
-qO-
"
$public_ip_host
"
;
printf
"%s"
)
"
publicip="
$(
wget
-T
10
-qO-
"
$public_ip_host
"
;
printf
"%s"
)
"
fi
fi
}
}
...
@@ -1855,11 +1856,11 @@ getbirthday() {
...
@@ -1855,11 +1856,11 @@ getbirthday() {
birthday="
${
birthday
/
:??
/
}
"
birthday="
${
birthday
/
:??
/
}
"
# Pretty output
# Pretty output
[
"
$birthday_shorthand
" == "
off
"
] &&
\
[
[ "
$birthday_shorthand
" == "
off
" ]
] &&
\
birthday="
${
date_cmd
//+( )/
}
"
birthday="
${
date_cmd
//+( )/
}
"
# Toggle showing the time
# Toggle showing the time
[
"
$birthday_time
" == "
off
"
] &&
\
[
[ "
$birthday_time
" == "
off
" ]
] &&
\
birthday="
${
birthday
/??
:??
*
}
"
birthday="
${
birthday
/??
:??
*
}
"
}
}
...
@@ -1868,13 +1869,13 @@ getbirthday() {
...
@@ -1868,13 +1869,13 @@ getbirthday() {
# Terminal colors {{{
# Terminal colors {{{
getcols() {
getcols() {
if [
"
$color_blocks
" == "
on
"
]; then
if [
[ "
$color_blocks
" == "
on
" ]
]; then
# Convert the width to space chars.
# Convert the width to space chars.
block_width="
$(
printf
"%
${
block_width
}
s"
)
"
block_width="
$(
printf
"%
${
block_width
}
s"
)
"
block_width="
${
block_width
// /█
}
"
block_width="
${
block_width
// /█
}
"
# Generate the string.
# Generate the string.
while [
"
$start
" -le "
$end
"
]; do
while [
[ "
$start
" -le "
$end
" ]
]; do
case "
$start
" in
case "
$start
" in
[0-6]) blocks+="
${
reset
}
\033[3
${
start
}
m
\033[4
${
start
}
m
${
block_width
}
" ;;
[0-6]) blocks+="
${
reset
}
\033[3
${
start
}
m
\033[4
${
start
}
m
${
block_width
}
" ;;
7) blocks+="
${
reset
}
\033[3
${
start
}
m
\033[4
${
start
}
m
${
block_width
}
" ;;
7) blocks+="
${
reset
}
\033[3
${
start
}
m
\033[4
${
start
}
m
${
block_width
}
" ;;
...
@@ -1887,8 +1888,8 @@ getcols() {
...
@@ -1887,8 +1888,8 @@ getcols() {
spaces="
$(
printf
"%
${
block_height
}
s"
)
"
spaces="
$(
printf
"%
${
block_height
}
s"
)
"
# Convert the spaces into rows of blocks.
# Convert the spaces into rows of blocks.
[
"
$blocks
"
] && cols+="
${
spaces
// /
${
blocks
}${
reset
}
nl
}
"
[
[ "
$blocks
" ]
] && cols+="
${
spaces
// /
${
blocks
}${
reset
}
nl
}
"
[
"
$blocks2
"
] && cols+="
${
spaces
// /
${
blocks2
}${
reset
}
nl
}
"
[
[ "
$blocks2
" ]
] && cols+="
${
spaces
// /
${
blocks2
}${
reset
}
nl
}
"
# Add newlines to the string.
# Add newlines to the string.
cols="
${
cols
%%
'nl'
}
"
cols="
${
cols
%%
'nl'
}
"
...
@@ -1907,7 +1908,7 @@ getcols() {
...
@@ -1907,7 +1908,7 @@ getcols() {
getwallpaper() {
getwallpaper() {
case "
$os
" in
case "
$os
" in
"
Linux
" | "
BSD
")
"
Linux
" | "
BSD
")
if type -p feh >/dev/null && [
-f "
$HOME
/.fehbg
"
]; then
if type -p feh >/dev/null && [
[ -f "
$HOME
/.fehbg
" ]
]; then
img="
$(
awk
-F
\'
'/feh/ {printf $2}'
"
$HOME
/.fehbg"
)
"
img="
$(
awk
-F
\'
'/feh/ {printf $2}'
"
$HOME
/.fehbg"
)
"
elif type -p nitrogen >/dev/null; then
elif type -p nitrogen >/dev/null; then
...
@@ -1915,7 +1916,7 @@ getwallpaper() {
...
@@ -1915,7 +1916,7 @@ getwallpaper() {
elif type -p gsettings >/dev/null; then
elif type -p gsettings >/dev/null; then
# Get DE if user has disabled the function.
# Get DE if user has disabled the function.
[
-z "
$de
"
] && getde
[
[ -z "
$de
" ]
] && getde
case "
$de
" in
case "
$de
" in
"
MATE
"*) img="
$(
gsettings get org.mate.background picture-filename
)
" ;;
"
MATE
"*) img="
$(
gsettings get org.mate.background picture-filename
)
" ;;
...
@@ -1950,10 +1951,10 @@ getwallpaper() {
...
@@ -1950,10 +1951,10 @@ getwallpaper() {
esac
esac
# If img is an xml file don'
t
use it.
# If img is an xml file don'
t
use it.
[
"
${
img
/*\./
}
"
==
"xml"
] && img=
""
[
[
"
${
img
/*\./
}
"
==
"xml"
]
] && img=
""
# Error msg
# Error msg
[
-z
"
$img
"
] && err
"Image: Wallpaper detection failed, falling back to ascii mode."
[
[ -z
"
$img
"
]
] && err
"Image: Wallpaper detection failed, falling back to ascii mode."
}
}
#
}
}}
#
}
}}
...
@@ -1961,37 +1962,37 @@ getwallpaper() {
...
@@ -1961,37 +1962,37 @@ getwallpaper() {
# Ascii {{{
# Ascii {{{
getascii() {
getascii() {
if [
! -f "
$ascii
" ] || [ "
$ascii
" == "
distro
"
]; then
if [
[ ! -f "
$ascii
" || "
$ascii
" == "
distro
" ]
]; then
# Error message
# Error message
[
"
$ascii
" != "
distro
"
] &&
\
[
[ "
$ascii
" != "
distro
" ]
] &&
\
[
! -f "
$ascii
"
] && err "
Ascii: Ascii file not found, using distro ascii
"
[
[ ! -f "
$ascii
" ]
] && err "
Ascii: Ascii file not found, using distro ascii
"
# Lowercase the distro name
# Lowercase the distro name
if [
"
$version
" -le 3
]; then
if [
[ "
$version
" -le 3 ]
]; then
ascii="
$(
tr
'[:upper:]'
'[:lower:]'
<<<
"
$ascii_distro
"
)
"
ascii="
$(
tr
'[:upper:]'
'[:lower:]'
<<<
"
$ascii_distro
"
)
"
else
else
ascii="
${
ascii_distro
,,
}
"
ascii="
${
ascii_distro
,,
}
"
fi
fi
if [
"
$ascii_logo_size
" == "
small
"
]; then
if [
[ "
$ascii_logo_size
" == "
small
" ]
]; then
ascii="
${
ascii
/ *
}
_small
"
ascii="
${
ascii
/ *
}
_small
"
prompt_loc="
3
"
prompt_loc="
3
"
fi
fi
if [
-f "
/usr/share/neofetch/ascii/distro/
${
ascii
/ *
}
"
]; then
if [
[ -f "
/usr/share/neofetch/ascii/distro/
${
ascii
/ *
}
" ]
]; then
ascii="
/usr/share/neofetch/ascii/distro/
${
ascii
/ *
}
"
ascii="
/usr/share/neofetch/ascii/distro/
${
ascii
/ *
}
"
elif [
-f "
/usr/local/share/neofetch/ascii/distro/
${
ascii
/ *
}
"
]; then
elif [
[ -f "
/usr/local/share/neofetch/ascii/distro/
${
ascii
/ *
}
" ]
]; then
ascii="
/usr/local/share/neofetch/ascii/distro/
${
ascii
/ *
}
"
ascii="
/usr/local/share/neofetch/ascii/distro/
${
ascii
/ *
}
"
elif [
-f "
/data/data/com.termux/files/usr/share/neofetch/ascii/distro/
${
ascii
/ *
}
"
]; then
elif [
[ -f "
/data/data/com.termux/files/usr/share/neofetch/ascii/distro/
${
ascii
/ *
}
" ]
]; then
ascii="
/data/data/com.termux/files/usr/share/neofetch/ascii/distro/
${
ascii
/ *
}
"
ascii="
/data/data/com.termux/files/usr/share/neofetch/ascii/distro/
${
ascii
/ *
}
"
else
else
getscriptdir 2>/dev/null
getscriptdir 2>/dev/null
# If the ascii file doesn't exist fallback to text mode.
# If the ascii file doesn't exist fallback to text mode.
if [
! -f "
$script_dir
/ascii/distro/
${
ascii
/ *
}
"
]; then
if [
[ ! -f "
$script_dir
/ascii/distro/
${
ascii
/ *
}
" ]
]; then
padding="
\0
33[0C
"
padding="
\0
33[0C
"
image="
off
"
image="
off
"
err "
Ascii: Ascii file not found, falling back to text mode.
"
err "
Ascii: Ascii file not found, falling back to text mode.
"
...
@@ -2017,12 +2018,12 @@ getascii() {
...
@@ -2017,12 +2018,12 @@ getascii() {
# Get lines/columns of the ascii file.
# Get lines/columns of the ascii file.
lines=1
lines=1
while IFS='
\n
' read -r line 2>/dev/null; do
while IFS='
\n
' read -r line 2>/dev/null; do
[
"
${#
line
}
" -gt "
${
ascii_length
:-
0
}
"
] && ascii_length="
${#
line
}
"
[
[ "
${#
line
}
" -gt "
${
ascii_length
:-
0
}
" ]
] && ascii_length="
${#
line
}
"
lines="
$((
lines+
=
1
))
"
lines="
$((
lines+
=
1
))
"
done <<< "
$ascii_strip
"
done <<< "
$ascii_strip
"
# Overwrite padding if ascii_length_force is set.
# Overwrite padding if ascii_length_force is set.
[
"
$ascii_length_force
"
] && ascii_length="
$ascii_length_force
"
[
[ "
$ascii_length_force
" ]
] && ascii_length="
$ascii_length_force
"
padding="
\0
33[
$((
ascii_length
+
gap
))
C
"
padding="
\0
33[
$((
ascii_length
+
gap
))
C
"
printf "
%b%s
" "
$print
"
printf "
%b%s
" "
$print
"
...
@@ -2041,7 +2042,7 @@ getimage() {
...
@@ -2041,7 +2042,7 @@ getimage() {
"
wall
") getwallpaper 2>/dev/null ;;
"
wall
") getwallpaper 2>/dev/null ;;
"
ascii
") getascii; return ;;
"
ascii
") getascii; return ;;
*)
*)
if [
-d "
$image
"
]; then
if [
[ -d "
$image
" ]
]; then
files=("
${
image
%/
}
"/*.{png,jpg,jpeg})
files=("
${
image
%/
}
"/*.{png,jpg,jpeg})
img="
$(
printf
"%s"
"
${
files
[RANDOM % (
${#
files
[@]
}
- 1)]
}
"
)
"
img="
$(
printf
"%s"
"
${
files
[RANDOM % (
${#
files
[@]
}
- 1)]
}
"
)
"
else
else
...
@@ -2050,11 +2051,11 @@ getimage() {
...
@@ -2050,11 +2051,11 @@ getimage() {
;;
;;
esac
esac
if [
-n "
$TMUX
"
]; then
if [
[ -n "
$TMUX
" ]
]; then
printf "
%b%s
" "
\0
33Ptmux
;
\0
33
\0
33[14t
\0
33
\0
33[c
\0
33
\\
"
printf "
%b%s
" "
\0
33Ptmux
;
\0
33
\0
33[14t
\0
33
\0
33[c
\0
33
\\
"
read_flags="
-d
c
"
read_flags="
-d
c
"
elif [
"
$image_backend
" == "
tycat
"
]; then
elif [
[ "
$image_backend
" == "
tycat
" ]
]; then
printf "
%b%s
" "
\0
33
}
qs
\0
00
"
printf "
%b%s
" "
\0
33
}
qs
\0
00
"
else
else
...
@@ -2066,7 +2067,7 @@ getimage() {
...
@@ -2066,7 +2067,7 @@ getimage() {
builtin read -s -t 1
${
read_flags
}
-r term_size
builtin read -s -t 1
${
read_flags
}
-r term_size
# Split the string
# Split the string
if [
"
$image_backend
" == "
tycat
"
]; then
if [
[ "
$image_backend
" == "
tycat
" ]
]; then
term_size=(
${
term_size
//;/
}
)
term_size=(
${
term_size
//;/
}
)
term_width="
$((
term_size[2]
*
term_size[0]
))
"
term_width="
$((
term_size[2]
*
term_size[0]
))
"
term_height="
$((
term_size[3]
*
term_size[1]
))
"
term_height="
$((
term_size[3]
*
term_size[1]
))
"
...
@@ -2081,9 +2082,9 @@ getimage() {
...
@@ -2081,9 +2082,9 @@ getimage() {
fi
fi
# Get terminal width and height if
\0
33[14t is unsupported.
# Get terminal width and height if
\0
33[14t is unsupported.
if [
"
${#
term_size
}
" -le 5 ] && [ "
$image_backend
" != "
tycat
"
]; then
if [
[ "
${#
term_size
}
" -le 5 && "
$image_backend
" != "
tycat
" ]
]; then
if type -p xdotool >/dev/null 2>&1 &&
\
if type -p xdotool >/dev/null 2>&1 &&
\
[
"
$image_backend
" != "
iterm2
"
]; then
[
[ "
$image_backend
" != "
iterm2
" ]
]; then
current_window="
$(
xdotool getactivewindow
)
"
current_window="
$(
xdotool getactivewindow
)
"
eval "
$(
xdotool getwindowgeometry
--shell
"
$current_window
"
)
"
eval "
$(
xdotool getwindowgeometry
--shell
"
$current_window
"
)
"
...
@@ -2093,7 +2094,7 @@ getimage() {
...
@@ -2093,7 +2094,7 @@ getimage() {
elif type -p xwininfo >/dev/null 2>&1 &&
\
elif type -p xwininfo >/dev/null 2>&1 &&
\
type -p xdpyinfo >/dev/null 2>&1 ||
\
type -p xdpyinfo >/dev/null 2>&1 ||
\
type -p xprop >/dev/null 2>&1 &&
\
type -p xprop >/dev/null 2>&1 &&
\
[
"
$image_backend
" != "
iterm2
"
]; then
[
[ "
$image_backend
" != "
iterm2
" ]
]; then
if type -p xdpyinfo >/dev/null 2>&1; then
if type -p xdpyinfo >/dev/null 2>&1; then
current_window="
$(
xdpyinfo |
grep
-F
"focus"
|
grep
-E
-o
0x[0-9a-f]+
)
"
current_window="
$(
xdpyinfo |
grep
-F
"focus"
|
grep
-E
-o
0x[0-9a-f]+
)
"
...
@@ -2108,13 +2109,13 @@ getimage() {
...
@@ -2108,13 +2109,13 @@ getimage() {
fi
fi
# If
$img
isn't a file fallback to ascii mode.
# If
$img
isn't a file fallback to ascii mode.
if [
! -f "
$img
" ] || [ -z "
$term_width
" ] || [ "
$term_width
" -le 10
]; then
if [
[ ! -f "
$img
" || -z "
$term_width
" || "
$term_width
" -le 10 ]
]; then
image="
ascii
"
image="
ascii
"
getascii
getascii
# Error messages
# Error messages
[
! -f "
$img
"
] && err "
Image:
\$
img, isn
't a file, falling back to ascii mode."
[
[ ! -f "
$img
" ]
] && err "
Image:
\$
img, isn
't a file, falling back to ascii mode."
[
"${#term_size}" -le 5
] && err "Image: Your terminal doesn'
t support
\\\0
33[14t, falling back to ascii mode.
"
[
[ "${#term_size}" -le 5 ]
] && err "Image: Your terminal doesn'
t support
\\\0
33[14t, falling back to ascii mode.
"
return
return
else
else
...
@@ -2137,7 +2138,7 @@ getimage() {
...
@@ -2137,7 +2138,7 @@ getimage() {
image_size="
$((
columns
*
font_width
/
2
))
"
image_size="
$((
columns
*
font_width
/
2
))
"
term_height="
$((
term_height
-
term_height
/
4
))
"
term_height="
$((
term_height
-
term_height
/
4
))
"
[
"
$term_height
" -lt "
$image_size
"
] &&
\
[
[ "
$term_height
" -lt "
$image_size
" ]
] &&
\
image_size="
$term_height
"
image_size="
$term_height
"
;;
;;
...
@@ -2145,7 +2146,7 @@ getimage() {
...
@@ -2145,7 +2146,7 @@ getimage() {
percent="
${
image_size
/\%
}
"
percent="
${
image_size
/\%
}
"
image_size="
$((
percent
*
term_width
/
100
))
"
image_size="
$((
percent
*
term_width
/
100
))
"
[
"
$((
percent
*
term_height
/
50
))
" -lt "
$image_size
"
] &&
\
[
[ "
$((
percent
*
term_height
/
50
))
" -lt "
$image_size
" ]
] &&
\
image_size="
$((
percent
*
term_height
/
100
))
"
image_size="
$((
percent
*
term_height
/
100
))
"
;;
;;
...
@@ -2178,9 +2179,9 @@ getimage() {
...
@@ -2178,9 +2179,9 @@ getimage() {
esac
esac
# Check to see if the thumbnail exists before we do any cropping.
# Check to see if the thumbnail exists before we do any cropping.
if [
! -f "
$thumbnail_dir
/
$imgname
"
]; then
if [
[ ! -f "
$thumbnail_dir
/
$imgname
" ]
]; then
# Get image size so that we can do a better crop
# Get image size so that we can do a better crop
if [
-z "
$size
"
]; then
if [
[ -z "
$size
" ]
]; then
size="
$(
identify
-format
"%w %h"
"
$img
"
)
"
size="
$(
identify
-format
"%w %h"
"
$img
"
)
"
og_width="
${
size
%% *
}
"
og_width="
${
size
%% *
}
"
og_height="
${
size
##*
}
"
og_height="
${
size
##*
}
"
...
@@ -2188,7 +2189,7 @@ getimage() {
...
@@ -2188,7 +2189,7 @@ getimage() {
# This checks to see if height is geater than width
# This checks to see if height is geater than width
# so we can do a better crop of portrait images.
# so we can do a better crop of portrait images.
size="
$og_height
"
size="
$og_height
"
[
"
$og_height
" -gt "
$og_width
"
] && size="
$og_width
"
[
[ "
$og_height
" -gt "
$og_width
" ]
] && size="
$og_width
"
fi
fi
case "
$crop_mode
" in
case "
$crop_mode
" in
...
@@ -2239,19 +2240,19 @@ getimage() {
...
@@ -2239,19 +2240,19 @@ getimage() {
# Find w3mimgdisplay automatically
# Find w3mimgdisplay automatically
getw3m_img_path() {
getw3m_img_path() {
if [
-x "
$w3m_img_path
"
]; then
if [
[ -x "
$w3m_img_path
" ]
]; then
return
return
elif [
-x "
/usr/lib/w3m/w3mimgdisplay
"
]; then
elif [
[ -x "
/usr/lib/w3m/w3mimgdisplay
" ]
]; then
w3m_img_path="
/usr/lib/w3m/w3mimgdisplay
"
w3m_img_path="
/usr/lib/w3m/w3mimgdisplay
"
elif [
-x "
/usr/libexec/w3m/w3mimgdisplay
"
]; then
elif [
[ -x "
/usr/libexec/w3m/w3mimgdisplay
" ]
]; then
w3m_img_path="
/usr/libexec/w3m/w3mimgdisplay
"
w3m_img_path="
/usr/libexec/w3m/w3mimgdisplay
"
elif [
-x "
/usr/lib64/w3m/w3mimgdisplay
"
]; then
elif [
[ -x "
/usr/lib64/w3m/w3mimgdisplay
" ]
]; then
w3m_img_path="
/usr/lib64/w3m/w3mimgdisplay
"
w3m_img_path="
/usr/lib64/w3m/w3mimgdisplay
"
elif [
-x "
/usr/libexec64/w3m/w3mimgdisplay
"
]; then
elif [
[ -x "
/usr/libexec64/w3m/w3mimgdisplay
" ]
]; then
w3m_img_path="
/usr/libexec64/w3m/w3mimgdisplay
"
w3m_img_path="
/usr/libexec64/w3m/w3mimgdisplay
"
else
else
...
@@ -2265,7 +2266,7 @@ getw3m_img_path() {
...
@@ -2265,7 +2266,7 @@ getw3m_img_path() {
# Display image {{{
# Display image {{{
displayimage() {
displayimage() {
if [
"$image" != "ascii"
]; then
if [
[ "$image" != "ascii" ]
]; then
case "$image_backend" in
case "$image_backend" in
"w3m")
"w3m")
# Add a tiny delay to fix issues with images not
# Add a tiny delay to fix issues with images not
...
@@ -2291,10 +2292,10 @@ displayimage() {
...
@@ -2291,10 +2292,10 @@ displayimage() {
# Get image backend {{{
# Get image backend {{{
getimagebackend() {
getimagebackend() {
if [
-n "$ITERM_PROFILE"
]; then
if [
[ -n "$ITERM_PROFILE" ]
]; then
image_backend="iterm2"
image_backend="iterm2"
elif [
"$(tycat 2>/dev/null)"
]; then
elif [
[ "$(tycat 2>/dev/null)" ]
]; then
image_backend="tycat"
image_backend="tycat"
else
else
...
@@ -2308,7 +2309,7 @@ getimagebackend() {
...
@@ -2308,7 +2309,7 @@ getimagebackend() {
takescrot() {
takescrot() {
$scrot_cmd "${scrot_dir}${scrot_name}"
$scrot_cmd "${scrot_dir}${scrot_name}"
[
"$scrot_upload" == "on"
] && scrot_upload
[
[ "$scrot_upload" == "on" ]
] && scrot_upload
}
}
# }}}
# }}}
...
@@ -2333,7 +2334,7 @@ scrot_upload() {
...
@@ -2333,7 +2334,7 @@ scrot_upload() {
"imgur")
"imgur")
image_url="$(curl -sH "Authorization: Client-ID $imgur_client_id" -F image="@${image_file}" "https://api.imgur.com/3/upload")"
image_url="$(curl -sH "Authorization: Client-ID $imgur_client_id" -F image="@${image_file}" "https://api.imgur.com/3/upload")"
image_url="$(awk -F '
id
:|,
' '
{
printf
$2
}
' <<< "${image_url//\"}")"
image_url="$(awk -F '
id
:|,
' '
{
printf
$2
}
' <<< "${image_url//\"}")"
[
"$image_url"
] && image_url="https://i.imgur.com/${image_url}.png"
[
[ "$image_url" ]
] && image_url="https://i.imgur.com/${image_url}.png"
;;
;;
esac
esac
...
@@ -2360,11 +2361,11 @@ info() {
...
@@ -2360,11 +2361,11 @@ info() {
output="$(trim "$output")"
output="$(trim "$output")"
# If prin was used in the function, stop here.
# If prin was used in the function, stop here.
[
"$prin"
] && \
[
[ "$prin" ]
] && \
unset prin && return
unset prin && return
# If the output is empty, don'
t print anything.
# If the output is empty, don'
t print anything.
[
-z
"
${
output
//
}
"
]
&&
\
[
[
-z
"
${
output
//
}
"
]
]
&&
\
err
"Info: Couldn't detect
$subtitle
"
&&
return
err
"Info: Couldn't detect
$subtitle
"
&&
return
case
"
$1
"
in
case
"
$1
"
in
...
@@ -2384,7 +2385,7 @@ info() {
...
@@ -2384,7 +2385,7 @@ info() {
esac
esac
# If there's no subtitle don't print one
# If there's no subtitle don't print one
[
-z
"
$2
"
]
&&
string
=
"
${
string
/*
:
}
"
[
[
-z
"
$2
"
]
]
&&
string
=
"
${
string
/*
:
}
"
# Print the string
# Print the string
printf
"%b%s
\n
"
"
${
padding
}${
zws
}${
string
}${
reset
}
"
printf
"%b%s
\n
"
"
${
padding
}${
zws
}${
string
}${
reset
}
"
...
@@ -2395,7 +2396,7 @@ info() {
...
@@ -2395,7 +2396,7 @@ info() {
# Fix rendering issues with w3m and lines that
# Fix rendering issues with w3m and lines that
# wrap to the next line by adding a max line
# wrap to the next line by adding a max line
# length.
# length.
if
[
"
$image
"
!=
"off"
]
&&
[
"
$image
"
!=
"ascii"
]
&&
[
"
$1
"
!=
"cols"
]
;
then
if
[
[
"
$image
"
!=
"off"
&&
"
$image
"
!=
"ascii"
&&
"
$1
"
!=
"cols"
]
]
;
then
padding_num
=
"
${
padding
/\\033\[
}
"
padding_num
=
"
${
padding
/\\033\[
}
"
output
=
"
$(
printf
"%.
$((
columns
-
${
padding_num
/C
}
-
gap
-
${#
subtitle
}))
s"
"
$output
"
)
"
output
=
"
$(
printf
"%.
$((
columns
-
${
padding_num
/C
}
-
gap
-
${#
subtitle
}))
s"
"
$output
"
)
"
fi
fi
...
@@ -2409,7 +2410,7 @@ prin() {
...
@@ -2409,7 +2410,7 @@ prin() {
string
=
"
${
1
//
$'
\0
33[0m'
}${
2
:+:
$2
}
"
string
=
"
${
1
//
$'
\0
33[0m'
}${
2
:+:
$2
}
"
# If $2 doesn't exist we format $1 as info
# If $2 doesn't exist we format $1 as info
[
-z
"
$2
"
]
&&
local
subtitle_color
=
"
$info_color
"
[
[
-z
"
$2
"
]
]
&&
local
subtitle_color
=
"
$info_color
"
# Format the output
# Format the output
string
=
"
${
string
/
:/
${
reset
}${
colon_color
}
:
${
info_color
}}
"
string
=
"
${
string
/
:/
${
reset
}${
colon_color
}
:
${
info_color
}}
"
...
@@ -2427,7 +2428,7 @@ prin() {
...
@@ -2427,7 +2428,7 @@ prin() {
# Fix rendering issues with w3m and lines that
# Fix rendering issues with w3m and lines that
# wrap to the next line by adding a max line
# wrap to the next line by adding a max line
# length.
# length.
if
[
"
$image
"
!=
"off"
]
&&
[
"
$image
"
!=
"ascii"
]
;
then
if
[
[
"
$image
"
!=
"off"
&&
"
$image
"
!=
"ascii"
]
]
;
then
padding_num
=
"
${
padding
/\\033\[
}
"
padding_num
=
"
${
padding
/\\033\[
}
"
string
=
"
$(
printf
"%.
$((
columns
-
${
padding_num
/C
}
-
gap
))
s"
"
$string
"
)
"
string
=
"
$(
printf
"%.
$((
columns
-
${
padding_num
/C
}
-
gap
))
s"
"
$string
"
)
"
fi
fi
...
@@ -2441,7 +2442,7 @@ prin() {
...
@@ -2441,7 +2442,7 @@ prin() {
# Underline {{{
# Underline {{{
getunderline
()
{
getunderline
()
{
if
[
"
$underline_enabled
"
==
"on"
]
;
then
if
[
[
"
$underline_enabled
"
==
"on"
]
]
;
then
underline
=
"
$(
printf
%
"
$length
"
s
)
"
underline
=
"
$(
printf
%
"
$length
"
s
)
"
underline
=
"
${
underline
// /
$underline_char
}
"
underline
=
"
${
underline
// /
$underline_char
}
"
fi
fi
...
@@ -2628,7 +2629,7 @@ colors() {
...
@@ -2628,7 +2629,7 @@ colors() {
# Overwrite distro colors if '$ascii_colors' doesn't
# Overwrite distro colors if '$ascii_colors' doesn't
# equal 'distro'.
# equal 'distro'.
[
"
${
ascii_colors
[0]
}
"
!=
"distro"
]
&&
\
[
[
"
${
ascii_colors
[0]
}
"
!=
"distro"
]
]
&&
\
setcolors
${
ascii_colors
[@]
}
setcolors
${
ascii_colors
[@]
}
}
}
...
@@ -2640,7 +2641,7 @@ setcolors() {
...
@@ -2640,7 +2641,7 @@ setcolors() {
c5
=
"
$(
color
"
$5
"
)${
ascii_bold
}
"
c5
=
"
$(
color
"
$5
"
)${
ascii_bold
}
"
c6
=
"
$(
color
"
$6
"
)${
ascii_bold
}
"
c6
=
"
$(
color
"
$6
"
)${
ascii_bold
}
"
if
[
"
${
colors
[0]
}
"
==
"distro"
]
;
then
if
[
[
"
${
colors
[0]
}
"
==
"distro"
]
]
;
then
title_color
=
"
$(
color
"
$1
"
)
"
title_color
=
"
$(
color
"
$1
"
)
"
at_color
=
"
$reset
"
at_color
=
"
$reset
"
underline_color
=
"
$reset
"
underline_color
=
"
$reset
"
...
@@ -2649,8 +2650,8 @@ setcolors() {
...
@@ -2649,8 +2650,8 @@ setcolors() {
info_color
=
"
$reset
"
info_color
=
"
$reset
"
# If the second color is white use the first for the subtitle
# If the second color is white use the first for the subtitle
[
"
$2
"
==
7
]
&&
subtitle_color
=
"
$(
color
"
$1
"
)
"
[
[
"
$2
"
==
7
]
]
&&
subtitle_color
=
"
$(
color
"
$1
"
)
"
[
"
$1
"
==
7
]
&&
title_color
=
"
$reset
"
[
[
"
$1
"
==
7
]
]
&&
title_color
=
"
$reset
"
else
else
title_color
=
"
$(
color
"
${
colors
[0]
}
"
)
"
title_color
=
"
$(
color
"
${
colors
[0]
}
"
)
"
at_color
=
"
$(
color
"
${
colors
[1]
}
"
)
"
at_color
=
"
$(
color
"
${
colors
[1]
}
"
)
"
...
@@ -2660,7 +2661,7 @@ setcolors() {
...
@@ -2660,7 +2661,7 @@ setcolors() {
info_color
=
"
$(
color
"
${
colors
[5]
}
"
)
"
info_color
=
"
$(
color
"
${
colors
[5]
}
"
)
"
fi
fi
if
[
"
$progress_color_elapsed
"
==
"distro"
]
;
then
if
[
[
"
$progress_color_elapsed
"
==
"distro"
]
]
;
then
progress_color_elapsed
=
"
$(
color
fg
)
"
progress_color_elapsed
=
"
$(
color
fg
)
"
else
else
progress_color_elapsed
=
"
$(
color
"
$progress_color_elapsed
"
)
"
progress_color_elapsed
=
"
$(
color
"
$progress_color_elapsed
"
)
"
...
@@ -2745,10 +2746,10 @@ err() {
...
@@ -2745,10 +2746,10 @@ err() {
# Check for old flags {{{
# Check for old flags {{{
checkoldflags
()
{
checkoldflags
()
{
[
-n
"
$osx_buildversion
"
]
&&
err
"Config:
\$
osx_buildversion is deprecated, use
\$
distro_shorthand instead."
[
[
-n
"
$osx_buildversion
"
]
]
&&
err
"Config:
\$
osx_buildversion is deprecated, use
\$
distro_shorthand instead."
[
-n
"
$osx_codename
"
]
&&
err
"Config:
\$
osx_codename is deprecated, use
\$
distro_shorthand instead."
[
[
-n
"
$osx_codename
"
]
]
&&
err
"Config:
\$
osx_codename is deprecated, use
\$
distro_shorthand instead."
[
-n
"
$progress_char
"
]
&&
err
"Config:
\$
progress_char is deprecated, use
\$
progress_char_elapsed and
\$
progress_char_total instead."
[
[
-n
"
$progress_char
"
]
]
&&
err
"Config:
\$
progress_char is deprecated, use
\$
progress_char_elapsed and
\$
progress_char_total instead."
[
"
$cpu_cores
"
==
"on"
]
&&
err
"Config:
\$
cpu_cores='on' is deprecated, use
\$
cpu_cores='logical|physical|off' instead."
[
[
"
$cpu_cores
"
==
"on"
]
]
&&
err
"Config:
\$
cpu_cores='on' is deprecated, use
\$
cpu_cores='logical|physical|off' instead."
}
}
# }}}
# }}}
...
@@ -2756,14 +2757,14 @@ checkoldflags() {
...
@@ -2756,14 +2757,14 @@ checkoldflags() {
# Get script directory {{{
# Get script directory {{{
getscriptdir
()
{
getscriptdir
()
{
[
"
$script_dir
"
]
&&
return
[
[
"
$script_dir
"
]
]
&&
return
# Use $0 to get the script's physical path.
# Use $0 to get the script's physical path.
cd
"
${
0
%/*
}
"
||
exit
cd
"
${
0
%/*
}
"
||
exit
script_dir
=
"
${
0
##*/
}
"
script_dir
=
"
${
0
##*/
}
"
# Iterate down a (possible) chain of symlinks.
# Iterate down a (possible) chain of symlinks.
while
[
-L
"
$script_dir
"
]
;
do
while
[
[
-L
"
$script_dir
"
]
]
;
do
script_dir
=
"
$(
readlink
"
$script_dir
"
)
"
script_dir
=
"
$(
readlink
"
$script_dir
"
)
"
cd
"
${
script_dir
%/*
}
"
||
exit
cd
"
${
script_dir
%/*
}
"
||
exit
script_dir
=
"
${
script_dir
##*/
}
"
script_dir
=
"
${
script_dir
##*/
}
"
...
@@ -2778,13 +2779,13 @@ getscriptdir() {
...
@@ -2778,13 +2779,13 @@ getscriptdir() {
# Source default config {{{
# Source default config {{{
getdefaultconfig
()
{
getdefaultconfig
()
{
if
[
-f
"/usr/share/neofetch/config"
]
;
then
if
[
[
-f
"/usr/share/neofetch/config"
]
]
;
then
default_config
=
"/usr/share/neofetch/config"
default_config
=
"/usr/share/neofetch/config"
elif
[
-f
"/usr/local/share/neofetch/config"
]
;
then
elif
[
[
-f
"/usr/local/share/neofetch/config"
]
]
;
then
default_config
=
"/usr/local/share/neofetch/config"
default_config
=
"/usr/local/share/neofetch/config"
elif
[
-f
"/data/data/com.termux/files/usr/share/neofetch/config"
]
;
then
elif
[
[
-f
"/data/data/com.termux/files/usr/share/neofetch/config"
]
]
;
then
default_config
=
"/data/data/com.termux/files/usr/share/neofetch/config"
default_config
=
"/data/data/com.termux/files/usr/share/neofetch/config"
else
else
...
@@ -2806,12 +2807,12 @@ getdefaultconfig() {
...
@@ -2806,12 +2807,12 @@ getdefaultconfig() {
getuserconfig
()
{
getuserconfig
()
{
# Check $config_file
# Check $config_file
if
[
-f
"
$config_file
"
]
;
then
if
[
[
-f
"
$config_file
"
]
]
;
then
source
"
$config_file
"
source
"
$config_file
"
err
"Config: Sourced user config (
$config_file
)"
err
"Config: Sourced user config (
$config_file
)"
return
return
elif
[
"
$config_file
"
==
"travis"
]
;
then
elif
[
[
"
$config_file
"
==
"travis"
]
]
;
then
source
"
$travis_config
"
source
"
$travis_config
"
err
"Config: Sourced user config (
$travis_config
)"
err
"Config: Sourced user config (
$travis_config
)"
return
return
...
@@ -2820,14 +2821,14 @@ getuserconfig() {
...
@@ -2820,14 +2821,14 @@ getuserconfig() {
# Check $XDG_CONFIG_HOME/neofetch and create the
# Check $XDG_CONFIG_HOME/neofetch and create the
# dir/files if they don't exist.
# dir/files if they don't exist.
if
[
-f
"
$XDG_CONFIG_HOME
/neofetch/config"
]
;
then
if
[
[
-f
"
$XDG_CONFIG_HOME
/neofetch/config"
]
]
;
then
config_file
=
"
$XDG_CONFIG_HOME
/neofetch/config"
config_file
=
"
$XDG_CONFIG_HOME
/neofetch/config"
elif
[
-f
"/usr/share/neofetch/config"
]
;
then
elif
[
[
-f
"/usr/share/neofetch/config"
]
]
;
then
cp
"/usr/share/neofetch/config"
"
$XDG_CONFIG_HOME
/neofetch"
cp
"/usr/share/neofetch/config"
"
$XDG_CONFIG_HOME
/neofetch"
config_file
=
"
$XDG_CONFIG_HOME
/neofetch/config"
config_file
=
"
$XDG_CONFIG_HOME
/neofetch/config"
elif
[
-f
"/usr/local/share/neofetch/config"
]
;
then
elif
[
[
-f
"/usr/local/share/neofetch/config"
]
]
;
then
cp
"/usr/local/share/neofetch/config"
"
$XDG_CONFIG_HOME
/neofetch"
cp
"/usr/local/share/neofetch/config"
"
$XDG_CONFIG_HOME
/neofetch"
config_file
=
"
$XDG_CONFIG_HOME
/neofetch/config"
config_file
=
"
$XDG_CONFIG_HOME
/neofetch/config"
...
@@ -2859,7 +2860,7 @@ bar() {
...
@@ -2859,7 +2860,7 @@ bar() {
bar+
=
"
${
progress_color_total
}${
total
// /
$progress_char_total
}
"
bar+
=
"
${
progress_color_total
}${
total
// /
$progress_char_total
}
"
# Borders
# Borders
if
[
"
$progress_border
"
==
"on"
]
;
then
if
[
[
"
$progress_border
"
==
"on"
]
]
;
then
bar+
=
"
$(
color
fg
)
]"
bar+
=
"
$(
color
fg
)
]"
bar
=
"
$(
color
fg
)
[
$bar
"
bar
=
"
$(
color
fg
)
[
$bar
"
fi
fi
...
@@ -2881,7 +2882,7 @@ cache() {
...
@@ -2881,7 +2882,7 @@ cache() {
# KDE config directory {{{
# KDE config directory {{{
kdeconfigdir
()
{
kdeconfigdir
()
{
if
[
-n
"
$KDE_CONFIG_DIR
"
]
;
then
if
[
[
-n
"
$KDE_CONFIG_DIR
"
]
]
;
then
kde_config_dir
=
"
$KDE_CONFIG_DIR
"
kde_config_dir
=
"
$KDE_CONFIG_DIR
"
elif
type
-p
kde5-config
>
/dev/null 2>&1
;
then
elif
type
-p
kde5-config
>
/dev/null 2>&1
;
then
...
@@ -2909,7 +2910,7 @@ kdeconfigdir() {
...
@@ -2909,7 +2910,7 @@ kdeconfigdir() {
# URxvt.
# URxvt.
gettermpadding
()
{
gettermpadding
()
{
[
-z
"
$term
"
]
&&
getterm
[
[
-z
"
$term
"
]
]
&&
getterm
case
"
$term
"
in
case
"
$term
"
in
"URxvt"
*
)
"URxvt"
*
)
...
@@ -2925,7 +2926,7 @@ gettermpadding() {
...
@@ -2925,7 +2926,7 @@ gettermpadding() {
dynamicprompt
()
{
dynamicprompt
()
{
# Calculate image height in terminal cells.
# Calculate image height in terminal cells.
if
[
"
$image
"
!=
"ascii"
]
;
then
if
[
[
"
$image
"
!=
"ascii"
]
]
;
then
gettermpadding
gettermpadding
lines
=
"
$((
(
height
+
(
${
border
:-
0
}
*
2
)
+
${
yoffset
:-
0
}
)
/
font_height
))
"
lines
=
"
$((
(
height
+
(
${
border
:-
0
}
*
2
)
+
${
yoffset
:-
0
}
)
/
font_height
))
"
else
else
...
@@ -2934,14 +2935,14 @@ dynamicprompt() {
...
@@ -2934,14 +2935,14 @@ dynamicprompt() {
# If the info is higher than the ascii/image place the prompt
# If the info is higher than the ascii/image place the prompt
# based on the info height instead of the ascii/image height.
# based on the info height instead of the ascii/image height.
if
[
"
${
lines
:-
0
}
"
-lt
"
${
info_height
:-
0
}
"
]
;
then
if
[
[
"
${
lines
:-
0
}
"
-lt
"
${
info_height
:-
0
}
"
]
]
;
then
lines
=
"-2"
lines
=
"-2"
else
else
lines
=
"
$((
lines
-
info_height
))
"
lines
=
"
$((
lines
-
info_height
))
"
fi
fi
# Set the prompt location
# Set the prompt location
if
[
"
$lines
"
-lt
0
]
;
then
if
[
[
"
$lines
"
-lt
0
]
]
;
then
printf
"
\0
33[
${
lines
/-
}
A"
printf
"
\0
33[
${
lines
/-
}
A"
else
else
printf
"
\0
33[
${
lines
}
B"
printf
"
\0
33[
${
lines
}
B"
...
@@ -3112,9 +3113,9 @@ getargs() {
...
@@ -3112,9 +3113,9 @@ getargs() {
*
"--config"
*
)
config
=
"off"
;;
*
"--config"
*
)
config
=
"off"
;;
esac
esac
[
"
${
config
:-
on
}
"
==
"on"
]
&&
getuserconfig 2>/dev/null
[
[
"
${
config
:-
on
}
"
==
"on"
]
]
&&
getuserconfig 2>/dev/null
while
[
"
$1
"
]
;
do
while
[
[
"
$1
"
]
]
;
do
case
"
$1
"
in
case
"
$1
"
in
# Info
# Info
--os_arch
)
os_arch
=
"
$2
"
;;
--os_arch
)
os_arch
=
"
$2
"
;;
...
@@ -3292,12 +3293,12 @@ main() {
...
@@ -3292,12 +3293,12 @@ main() {
printf
"
\0
33[?25l
\0
33[?7l"
printf
"
\0
33[?25l
\0
33[?7l"
# Display the image
# Display the image
if
[
"
$image
"
!=
"off"
]
;
then
if
[
[
"
$image
"
!=
"off"
]
]
;
then
getimagebackend
getimagebackend
# Find w3mimgdisplay
# Find w3mimgdisplay
[
"
$image_backend
"
==
"w3m"
]
&&
\
[
[
"
$image_backend
"
==
"w3m"
]
]
&&
\
[
"
$image
"
!=
"ascii"
]
&&
\
[
[
"
$image
"
!=
"ascii"
]
]
&&
\
getw3m_img_path
getw3m_img_path
# Get the image src
# Get the image src
...
@@ -3317,21 +3318,21 @@ main() {
...
@@ -3317,21 +3318,21 @@ main() {
printinfo 2>/dev/null
printinfo 2>/dev/null
# Prompt calculation
# Prompt calculation
if
[
"
$image
"
!=
"off"
]
;
then
if
[
[
"
$image
"
!=
"off"
]
]
;
then
dynamicprompt
dynamicprompt
# w3m-img: Draw the image a second time to fix
# w3m-img: Draw the image a second time to fix
# rendering issues in specific terminal emulators.
# rendering issues in specific terminal emulators.
[
"
$image_backend
"
==
"w3m"
]
&&
displayimage
[
[
"
$image_backend
"
==
"w3m"
]
]
&&
displayimage
fi
fi
# Re-enable line wrap
# Re-enable line wrap
printf
"%b%s"
"
\0
33[?7h"
printf
"%b%s"
"
\0
33[?7h"
[
"
$scrot
"
==
"on"
]
&&
takescrot
[
[
"
$scrot
"
==
"on"
]
]
&&
takescrot
# Show error messages
# Show error messages
[
"
$verbose
"
==
"on"
]
&&
printf
"%b%s"
"
$err
"
[
[
"
$verbose
"
==
"on"
]
]
&&
printf
"%b%s"
"
$err
"
# Reset exit status of the tests above
# Reset exit status of the tests above
printf
"%s"
printf
"%s"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment