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
df2ecf9f
Commit
df2ecf9f
authored
Nov 06, 2016
by
Dylan Araps
Committed by
GitHub
Nov 06, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #425 from dylanaraps/fixes2
General: Function cleanup
parents
ba0c7e44
fec45f7a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
77 deletions
+41
-77
neofetch
neofetch
+41
-77
No files found.
neofetch
View file @
df2ecf9f
...
...
@@ -229,10 +229,8 @@ getdistro() {
distro=
"
${
distro
/DragonFly/DragonFlyBSD
}
"
# Workaround
for PCBSD as uname still displays FreeBSD
.
# Workaround
s for FreeBSD based distros
.
[ -f
"/etc/pcbsd-lang"
] && distro=
"PCBSD"
# Workaround for PacBSD as uname displays FreeBSD.
[ -f
"/etc/pacbsd-release"
] && distro=
"PacBSD"
;;
...
...
@@ -284,20 +282,14 @@ getkernel() {
esac
# Hardcode kernel settings in BSDs
case "
$os
" in
"
BSD
")
case "
$distro
" in
"
PacBSD
"* | "
PCBSD
"*) kernel="
$(
uname
$kernel_flags
)
" ;;
*)
if [ "
$os
" == "
BSD
" ] && [[ ! "
$distro
" =~ (PacBSD|PCBSD) ]]; then
case "
$distro_shorthand
" in
"
on
" | "
tiny
") kernel=
$(
uname
-r
)
;;
*) unset kernel ;;
esac
;;
esac
;;
*) kernel="
$(
uname
$kernel_flags
)
" ;;
esac
else
kernel="
$(
uname
$kernel_flags
)
"
fi
}
# }}}
...
...
@@ -305,7 +297,6 @@ getkernel() {
# Uptime {{{
getuptime() {
# Since Haiku's uptime cannot be fetched in seconds, a case outside
# the usual case is needed
case "
$os
" in
...
...
@@ -496,30 +487,31 @@ getshell() {
if [ "
$shell_version
" == "
on
" ]; then
shell+="
"
case "
$
shell
" in
*"
bash
"*
)
shell+="
$(
bash
--version
|
head
-n
1
)
"
case "
$
{
SHELL
##*/
}
" in
"
bash
"
)
shell+="
$(
bash
--version
)
"
shell="
${
shell
/ *, version
}
"
shell="
${
shell
/
$'
\n
'
*
}
"
;;
*"
zsh
"*
)
"
zsh
"
)
shell+="
$(
zsh
--version
)
"
shell="
${
shell
/ zsh
}
"
;;
*"
mksh
"* | *
"
ksh
")
"
mksh
" |
"
ksh
")
shell+="
$(
"
$SHELL
"
-c
'printf "%s" "$KSH_VERSION"'
)
"
shell="
${
shell
/ * KSH
}
"
;;
*"
tcsh
"* | *"
csh
"*
)
"
tcsh
" | "
csh
"
)
shell+="
$(
"
$SHELL
"
--version
)
"
shell="
${
shell
/tcsh
}
"
shell="
${
shell
/\(*
}
"
;;
*"
fish
"*
)
shell+="
$(
"
$SHELL
"
-c
'printf "%s" "$FISH_VERSION"'
)
"
"
fish
"
)
shell+="
$(
fish
-c
'printf "%s" "$FISH_VERSION"'
)
"
;;
esac
shell="
${
shell
/\(*\)
}
"
...
...
@@ -767,15 +759,6 @@ getcpu() {
"logical"
|
"on"
) cores=
"
$(
grep
-c
^processor /proc/cpuinfo
)
"
;;
"physical"
) cores=
"
$(
grep
"^core id"
/proc/cpuinfo |
sort
-u
|
wc
-l
)
"
;;
esac
# Fix for speeds under 1ghz
if [ -z
"
${
speed
:1
}
"
]; then
speed=
"0.
${
speed
}
"
else
speed=
"
${
speed
:0:1
}
.
${
speed
:1
}
"
fi
cpu=
"
$cpu
@
${
speed
}
GHz
$temp
"
;;
"Mac OS X"
)
...
...
@@ -828,15 +811,6 @@ getcpu() {
# Get cpu cores
cores=
"
$(
sysctl
-n
hw.ncpu
)
"
# Fix for speeds under 1ghz
if [ -z
"
${
speed
:1
}
"
]; then
speed=
"0.
${
speed
}
"
else
speed=
"
${
speed
:0:1
}
.
${
speed
:1
}
"
fi
cpu=
"
$cpu
@
${
speed
}
GHz"
;;
"Solaris"
)
...
...
@@ -854,15 +828,6 @@ getcpu() {
"logical"
|
"on"
) cores=
"
$(
kstat
-m
cpu_info |
grep
-c
"chip_id"
)
"
;;
"physical"
) cores=
"
$(
psrinfo
-p
)
"
;;
esac
# Fix for speeds under 1ghz
if [ -z
"
${
speed
:1
}
"
]; then
speed=
"0.
${
speed
}
"
else
speed=
"
${
speed
:0:1
}
.
${
speed
:1
}
"
fi
cpu=
"
$cpu
@
${
speed
}
GHz"
;;
"Haiku"
)
...
...
@@ -872,15 +837,21 @@ getcpu() {
speed=
"
${
speed
/MHz
}
"
speed=
"
$((
speed
/
100
))
"
cores=
"
$(
sysinfo
-cpu
|
grep
-c
'CPU #'
)
"
;;
esac
# Fix for speed under 1ghz
if [ -z ]
"
${
speed
:1
}
"
; then
# Format the output
case
"
$os
"
in
"Mac OS X"
|
"iPhone OS"
) ;;
*)
# Fix for speeds under 1ghz
if [ -z
"
${
speed
:1
}
"
]; then
speed=
"0.
${
speed
}
"
else
speed=
"
${
speed
:0:1
}
.
${
speed
:1
}
"
fi
cpu=
"
$cpu
@
${
speed
}
GHz"
cpu=
"
$cpu
@
${
speed
}
GHz
$temp
"
;;
esac
...
...
@@ -892,10 +863,11 @@ getcpu() {
cpu=
"
${
cpu
//(R)
}
"
cpu=
"
${
cpu
//CPU
}
"
cpu=
"
${
cpu
//Processor
}
"
cpu=
"
${
cpu
//Six-Core
}
"
cpu=
"
${
cpu
//Eight-Core
}
"
cpu=
"
${
cpu
//Core
}
"
cpu=
"
${
cpu
//Dual-Core
}
"
cpu=
"
${
cpu
//Quad-Core
}
"
cpu=
"
${
cpu
//Six-Core
}
"
cpu=
"
${
cpu
//Eight-Core
}
"
cpu=
"
${
cpu
//with Radeon HD Graphics
}
"
# Add cpu cores to output
...
...
@@ -1116,13 +1088,15 @@ getmemory() {
"BSD"
)
case
"
$distro
"
in
"NetBSD"
*
)
memfree
=
"
$(($(
awk
-F
':|kB'
'/MemFree:/ {printf $2}'
/proc/meminfo
)
/
1024
))
"
;;
*
)
memfree
=
"
$(($(
vmstat |
awk
'END{printf $5}'
)
/
1024
))
"
;;
esac
"NetBSD"
*
)
memfree
=
"
$(($(
awk
-F
':|kB'
'/MemFree:/ {printf $2}'
/proc/meminfo
)
/
1024
))
"
memtotal
=
"
$(($(
sysctl
-n
hw.physmem64
)
/
1024
/
1024
))
"
;;
case
"
$distro
"
in
"NetBSD"
*
)
memtotal
=
"
$(($(
sysctl
-n
hw.physmem64
)
/
1024
/
1024
))
"
;;
*
)
memtotal
=
"
$(($(
sysctl
-n
hw.physmem
)
/
1024
/
1024
))
"
;;
*
)
memfree
=
"
$(($(
vmstat |
awk
'END{printf $5}'
)
/
1024
))
"
memtotal
=
"
$(($(
sysctl
-n
hw.physmem
)
/
1024
/
1024
))
"
;;
esac
case
"
$distro
"
in
...
...
@@ -1297,8 +1271,7 @@ getresolution() {
resolution="
${
resolution
//x??@/ @
}
"
else
resolution="
$(
system_profiler SPDisplaysDataType |
\
awk
'/Resolution:/ {printf $2"x"$4" @ "$6"Hz, "}'
)
"
resolution="
$(
system_profiler SPDisplaysDataType |
awk
'/Resolution:/ {printf $2"x"$4" @ "$6"Hz, "}'
)
"
fi
scale_factor="
$(
/usr/libexec/PlistBuddy
-c
"Print DisplayAnyUserSets:0:0:Resolution"
/Library/Preferences/com.apple.windowserver.plist
)
"
...
...
@@ -1322,16 +1295,13 @@ getresolution() {
height="
$(
wmic path Win32_VideoController get CurrentVerticalResolution /value
)
"
height="
${
height
/CurrentVerticalResolution
'='
/
}
"
[ "
$width
" ] &&
\
resolution="
${
width
}
x
${
height
}
"
[ "
$width
" ] && resolution="
${
width
}
x
${
height
}
"
;;
"
Haiku
")
resolution="
$(
screenmode |
awk
-F
' |, '
'{printf $2 "x" $3 " @ " $6 $7}'
)
"
case "
$refresh_rate
" in
"
off
") resolution="
${
resolution
/ @*
}
" ;;
esac
[ "
$refresh_rate
" == "
off
" ] && resolution="
${
resolution
/ @*
}
"
;;
esac
...
...
@@ -1747,8 +1717,7 @@ getbattery() {
"
Windows
")
battery="
$(
wmic Path Win32_Battery get EstimatedChargeRemaining /value
)
"
battery="
${
battery
/EstimatedChargeRemaining
'='
}
"
[ "
$battery
" ] &&
\
battery+="
%
"
[ "
$battery
" ] && battery+="
%
"
;;
"
Haiku
")
...
...
@@ -1758,9 +1727,7 @@ getbattery() {
;;
esac
case "
$battery_state
" in
"
charging
"*) battery+="
Charging
" ;;
esac
[ "
$battery_state
" ] && battery+="
Charging
"
case "
$battery_display
" in
"
bar
") battery="
$(
bar
"
${
battery
/
'%'
*
}
"
100
)
" ;;
...
...
@@ -2473,13 +2440,10 @@ prin() {
# Underline {{{
getunderline
()
{
case
"
$underline_enabled
"
in
"on"
)
if
[
"
$underline_enabled
"
==
"on"
]
;
then
underline
=
"
$(
printf
%
"
$length
"
s
)
"
underline
=
"
${
underline
// /
$underline_char
}
"
;;
"off"
)
underline
=
""
;;
esac
fi
}
# }}}
...
...
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