Add support for Dragonfly BSD and PC BSD
This commit is contained in:
parent
39dde925fc
commit
be63101894
2 changed files with 3279 additions and 75 deletions
126
neofetch
126
neofetch
|
@ -450,8 +450,7 @@ shopt -s nocasematch extglob
|
||||||
case "$(uname)" in
|
case "$(uname)" in
|
||||||
"Linux") os="Linux" ;;
|
"Linux") os="Linux" ;;
|
||||||
"Darwin") os="$(sw_vers -productName)" ;;
|
"Darwin") os="$(sw_vers -productName)" ;;
|
||||||
"OpenBSD") os="OpenBSD" ;;
|
*"BSD" | "DragonFly") os="BSD" ;;
|
||||||
*"BSD") os="BSD" ;;
|
|
||||||
"CYGWIN"*) os="Windows" ;;
|
"CYGWIN"*) os="Windows" ;;
|
||||||
*) printf "%s\n" "Unknown OS detected: $(uname)"; exit 1 ;;
|
*) printf "%s\n" "Unknown OS detected: $(uname)"; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
|
@ -507,13 +506,8 @@ getdistro () {
|
||||||
os_arch="off"
|
os_arch="off"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"OpenBSD")
|
|
||||||
distro="OpenBSD"
|
|
||||||
;;
|
|
||||||
|
|
||||||
"BSD")
|
"BSD")
|
||||||
distro="$(uname -v)"
|
distro="$(uname -sr)"
|
||||||
distro=${distro%% *}
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"Windows")
|
"Windows")
|
||||||
|
@ -582,7 +576,7 @@ getuptime () {
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"Mac OS X" | "iPhone OS" | *"BSD")
|
"Mac OS X" | "iPhone OS" | "BSD")
|
||||||
# Get boot time in seconds
|
# Get boot time in seconds
|
||||||
boot="$(sysctl -n kern.boottime)"
|
boot="$(sysctl -n kern.boottime)"
|
||||||
boot="${boot/'{ sec = '}"
|
boot="${boot/'{ sec = '}"
|
||||||
|
@ -714,7 +708,7 @@ getpackages () {
|
||||||
packages=$((packages + $(pkgin list 2>/dev/null | wc -l)))
|
packages=$((packages + $(pkgin list 2>/dev/null | wc -l)))
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*"BSD")
|
"BSD")
|
||||||
if type -p pkg_info >/dev/null 2>&1; then
|
if type -p pkg_info >/dev/null 2>&1; then
|
||||||
packages=$(pkg_info | wc -l)
|
packages=$(pkg_info | wc -l)
|
||||||
|
|
||||||
|
@ -945,6 +939,43 @@ getwmtheme () {
|
||||||
|
|
||||||
getcpu () {
|
getcpu () {
|
||||||
case "$os" in
|
case "$os" in
|
||||||
|
"Linux" | "Windows")
|
||||||
|
# Get cpu name
|
||||||
|
cpu="$(awk -F ': | @' '/model name/ {printf $2; exit}' /proc/cpuinfo)"
|
||||||
|
|
||||||
|
# Get cpu speed
|
||||||
|
if [ -d "/sys/devices/system/cpu/cpu0/cpufreq" ]; then
|
||||||
|
case "$speed_type" in
|
||||||
|
current) speed_type="scaling_cur_freq" ;;
|
||||||
|
min) speed_type="scaling_min_freq" ;;
|
||||||
|
max) speed_type="scaling_max_freq" ;;
|
||||||
|
bios) speed_type="bios_limit" ;;
|
||||||
|
scaling_current) speed_type="scaling_cur_freq" ;;
|
||||||
|
scaling_min) speed_type="scaling_min_freq" ;;
|
||||||
|
scaling_max) speed_type="scaling_max_freq" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
read -t 1 -r speed < \
|
||||||
|
/sys/devices/system/cpu/cpu0/cpufreq/${speed_type}
|
||||||
|
|
||||||
|
speed=$((speed / 100000))
|
||||||
|
else
|
||||||
|
speed=$(awk -F ': |\\.' '/cpu MHz/ {printf $2; exit}' /proc/cpuinfo)
|
||||||
|
speed=$((speed / 100))
|
||||||
|
fi
|
||||||
|
|
||||||
|
cores=$(awk -F ': ' '/siblings/ {printf $2; exit}' /proc/cpuinfo)
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
;;
|
||||||
|
|
||||||
"Mac OS X")
|
"Mac OS X")
|
||||||
cpu="$(sysctl -n machdep.cpu.brand_string)"
|
cpu="$(sysctl -n machdep.cpu.brand_string)"
|
||||||
cores=$(sysctl -n hw.ncpu)
|
cores=$(sysctl -n hw.ncpu)
|
||||||
|
@ -1060,61 +1091,19 @@ getcpu () {
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
"BSD")
|
||||||
case "$distro" in
|
|
||||||
"OpenBSD"* | "FreeBSD"*)
|
|
||||||
# Get cpu name
|
# Get cpu name
|
||||||
cpu="$(sysctl -n hw.model)"
|
cpu="$(sysctl -n hw.model)"
|
||||||
cpu=${cpu/[0-9]\.*}
|
cpu=${cpu/[0-9]\.*}
|
||||||
cpu=${cpu/ @*}
|
cpu=${cpu/ @*}
|
||||||
|
|
||||||
# Get cpu speed
|
# Get cpu speed
|
||||||
case "$distro" in
|
speed=$(sysctl -n hw.cpuspeed hw.clockrate 2>/dev/null)
|
||||||
"OpenBSD"*) speed=$(sysctl -n hw.cpuspeed) ;;
|
|
||||||
"FreeBSD"*) speed=$(sysctl -n hw.clockrate) ;;
|
|
||||||
esac
|
|
||||||
speed=$((speed / 100))
|
speed=$((speed / 100))
|
||||||
|
|
||||||
|
# Get cpu cores
|
||||||
cores=$(sysctl -n hw.ncpu)
|
cores=$(sysctl -n hw.ncpu)
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
|
||||||
# Get cpu name
|
|
||||||
cpu="$(awk -F ': | @' '/model name/ {printf $2; exit}' /proc/cpuinfo)"
|
|
||||||
|
|
||||||
# Get cpu speed
|
|
||||||
if [ -d "/sys/devices/system/cpu/cpu0/cpufreq" ]; then
|
|
||||||
case "$speed_type" in
|
|
||||||
current) speed_type="scaling_cur_freq" ;;
|
|
||||||
min) speed_type="scaling_min_freq" ;;
|
|
||||||
max) speed_type="scaling_max_freq" ;;
|
|
||||||
bios) speed_type="bios_limit" ;;
|
|
||||||
scaling_current) speed_type="scaling_cur_freq" ;;
|
|
||||||
scaling_min) speed_type="scaling_min_freq" ;;
|
|
||||||
scaling_max) speed_type="scaling_max_freq" ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
read -t 1 -r speed < \
|
|
||||||
/sys/devices/system/cpu/cpu0/cpufreq/${speed_type}
|
|
||||||
|
|
||||||
speed=$((speed / 100000))
|
|
||||||
else
|
|
||||||
speed=$(awk -F ': |\\.' '/cpu MHz/ {printf $2; exit}' /proc/cpuinfo)
|
|
||||||
speed=$((speed / 100))
|
|
||||||
fi
|
|
||||||
|
|
||||||
cores=$(awk -F ': ' '/siblings/ {printf $2; exit}' /proc/cpuinfo)
|
|
||||||
;;
|
|
||||||
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"
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Remove uneeded patterns from cpu output
|
# Remove uneeded patterns from cpu output
|
||||||
|
@ -1324,7 +1313,7 @@ getgpu () {
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*"BSD")
|
"BSD")
|
||||||
case "$distro" in
|
case "$distro" in
|
||||||
"FreeBSD"*)
|
"FreeBSD"*)
|
||||||
gpu=$(pciconf -lv 2>/dev/null | grep -B 4 "VGA" | grep "device")
|
gpu=$(pciconf -lv 2>/dev/null | grep -B 4 "VGA" | grep "device")
|
||||||
|
@ -1401,7 +1390,7 @@ getmemory () {
|
||||||
memused=$(((${memwired//.} + ${memactive//.} + ${memcompressed//.}) * 4 / 1024))
|
memused=$(((${memwired//.} + ${memactive//.} + ${memcompressed//.}) * 4 / 1024))
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"OpenBSD" | "BSD")
|
"BSD")
|
||||||
case "$distro" in
|
case "$distro" in
|
||||||
"OpenBSD"*)
|
"OpenBSD"*)
|
||||||
mem=($(top -d 1 | awk -F ': |/| |M' '/Memory:/ {printf $4 " " $6 " " $11 "\n"}'))
|
mem=($(top -d 1 | awk -F ': |/| |M' '/Memory:/ {printf $4 " " $6 " " $11 "\n"}'))
|
||||||
|
@ -1522,7 +1511,7 @@ getsong () {
|
||||||
|
|
||||||
getresolution () {
|
getresolution () {
|
||||||
case "$os" in
|
case "$os" in
|
||||||
"Linux" | *"BSD")
|
"Linux" | "BSD")
|
||||||
if type -p xrandr >/dev/null 2>&1; then
|
if type -p xrandr >/dev/null 2>&1; then
|
||||||
case "$refresh_rate" in
|
case "$refresh_rate" in
|
||||||
"on") resolution=$(xrandr --nograb --current | awk 'match($0,/[0-9]{2,3}.[0-9]{2}\*/) {printf $1 " @ " substr($0,RSTART,RLENGTH) "Hz, "}') ;;
|
"on") resolution=$(xrandr --nograb --current | awk 'match($0,/[0-9]{2,3}.[0-9]{2}\*/) {printf $1 " @ " substr($0,RSTART,RLENGTH) "Hz, "}') ;;
|
||||||
|
@ -1747,12 +1736,11 @@ getdisk () {
|
||||||
# df flags
|
# df flags
|
||||||
case "$os" in
|
case "$os" in
|
||||||
"Linux" | "iPhone OS" | "Windows") df_flags="-h -l --total" ;;
|
"Linux" | "iPhone OS" | "Windows") df_flags="-h -l --total" ;;
|
||||||
"Mac OS X") df_flags="-H / -l" ;;
|
"Mac OS X" | "BSD")
|
||||||
|
|
||||||
*"BSD")
|
|
||||||
case "$distro" in
|
case "$distro" in
|
||||||
"FreeBSD"*) df_flags="-h -c -l" ;;
|
"OpenBSD"*) return ;;
|
||||||
*) return ;;
|
"FreeBSD"* | *"OS X"* ) df_flags="-H / -l" ;;
|
||||||
|
*) df_flags="-h -c -l" ;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -1837,7 +1825,7 @@ getbattery () {
|
||||||
|
|
||||||
"BSD")
|
"BSD")
|
||||||
case "$distro" in
|
case "$distro" in
|
||||||
"FreeBSD"*)
|
"FreeBSD"* | "DragonFly"*)
|
||||||
battery=$(acpiconf -i 0 | awk -F ':\t' '/Remaining capacity/ {print $2}')
|
battery=$(acpiconf -i 0 | awk -F ':\t' '/Remaining capacity/ {print $2}')
|
||||||
battery_state=$(acpiconf -i 0 | awk -F ':\t\t\t' '/State/ {print $2}')
|
battery_state=$(acpiconf -i 0 | awk -F ':\t\t\t' '/State/ {print $2}')
|
||||||
;;
|
;;
|
||||||
|
@ -1901,7 +1889,7 @@ getlocalip () {
|
||||||
[ -z "$localip" ] && localip="$(ipconfig getifaddr en1)"
|
[ -z "$localip" ] && localip="$(ipconfig getifaddr en1)"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*"BSD")
|
"BSD")
|
||||||
localip="$(ifconfig | awk '/broadcast/ {print $2}')"
|
localip="$(ifconfig | awk '/broadcast/ {print $2}')"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
@ -1960,7 +1948,7 @@ getbirthday () {
|
||||||
birthday_shorthand="on"
|
birthday_shorthand="on"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*"BSD")
|
"BSD")
|
||||||
case "$distro" in
|
case "$distro" in
|
||||||
"OpenBSD"*)
|
"OpenBSD"*)
|
||||||
birthday="$(ls -alctT / | awk '/lost\+found/ {printf $6 " " $7 " " $9 " " $8}')"
|
birthday="$(ls -alctT / | awk '/lost\+found/ {printf $6 " " $7 " " $9 " " $8}')"
|
||||||
|
@ -1972,7 +1960,7 @@ getbirthday () {
|
||||||
date_cmd="$(date -j -f "%b %d %Y" "$birthday" "$birthday_format")"
|
date_cmd="$(date -j -f "%b %d %Y" "$birthday" "$birthday_format")"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"NetBSD"*)
|
"NetBSD"* | "DragonFly"*)
|
||||||
birthday="$(ls -alctT /etc/defaults/rc.conf | awk '{printf $6 " " $7 " " $9 " " $8}')"
|
birthday="$(ls -alctT /etc/defaults/rc.conf | awk '{printf $6 " " $7 " " $9 " " $8}')"
|
||||||
birthday_shorthand="on"
|
birthday_shorthand="on"
|
||||||
;;
|
;;
|
||||||
|
@ -2030,7 +2018,7 @@ getcols () {
|
||||||
|
|
||||||
getwallpaper () {
|
getwallpaper () {
|
||||||
case "$os" in
|
case "$os" in
|
||||||
"Linux" | *"BSD")
|
"Linux" | "BSD")
|
||||||
if type -p feh >/dev/null 2>&1 && [ -f "$HOME/.fehbg" ]; then
|
if type -p feh >/dev/null 2>&1 && [ -f "$HOME/.fehbg" ]; then
|
||||||
img="$(awk -F\' '/feh/ {printf $2}' "$HOME/.fehbg")"
|
img="$(awk -F\' '/feh/ {printf $2}' "$HOME/.fehbg")"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue