diff --git a/scripts/battery.sh b/scripts/battery.sh index 9d1e52a..4151f92 100755 --- a/scripts/battery.sh +++ b/scripts/battery.sh @@ -45,6 +45,10 @@ battery_percent() echo $(pmset -g batt | grep -Eo '[0-9]?[0-9]?[0-9]%') ;; + FreeBSD) + echo $(apm | sed '8,11d' | grep life | awk '{print $4}') + ;; + CYGWIN*|MINGW32*|MSYS*|MINGW*) # leaving empty - TODO - windows compatability ;; @@ -59,13 +63,17 @@ battery_status() # Check OS case $(uname -s) in Linux) - status=$(linux_acpi status) + status=$(linux_acpi status) ;; Darwin) status=$(pmset -g batt | sed -n 2p | cut -d ';' -f 2) ;; + FreeBSD) + status=$(apm | sed '8,11d' | grep Status | awk '{printf $3}') + ;; + CYGWIN*|MINGW32*|MSYS*|MINGW*) # leaving empty - TODO - windows compatability ;; @@ -74,11 +82,28 @@ battery_status() ;; esac - if [ $status = 'discharging' ] || [ $status = 'Discharging' ]; then - echo '' - else - echo 'AC' - fi + case $status in + discharging|Discharging) + echo '' + ;; + high) + echo '' + ;; + charging) + echo 'AC' + ;; + *) + echo 'AC' + ;; + esac + ### Old if statements didn't work on BSD, they're probably not POSIX compliant, not sure + # if [ $status = 'discharging' ] || [ $status = 'Discharging' ]; then + # echo '' + # # elif [ $status = 'charging' ]; then # This is needed for FreeBSD AC checking support + # # echo 'AC' + # else + # echo 'AC' + # fi } main() diff --git a/scripts/ram_info.sh b/scripts/ram_info.sh index bddedef..f0f7bff 100755 --- a/scripts/ram_info.sh +++ b/scripts/ram_info.sh @@ -47,6 +47,25 @@ get_percent() echo $memory\G\B/$total_mem fi ;; + + FreeBSD) + # Looked at the code from neofetch + hw_pagesize="$(sysctl -n hw.pagesize)" + mem_inactive="$(($(sysctl -n vm.stats.vm.v_inactive_count) * hw_pagesize))" + mem_unused="$(($(sysctl -n vm.stats.vm.v_free_count) * hw_pagesize))" + mem_cache="$(($(sysctl -n vm.stats.vm.v_cache_count) * hw_pagesize))" + + free_mem=$(((mem_inactive + mem_unused + mem_cache) / 1024 / 1024)) + total_mem=$(($(sysctl -n hw.physmem) / 1024 / 1024)) + used_mem=$((total_mem - free_mem)) + echo $used_mem + if (( $used_mem < 1024 )); then + echo $used_mem\M\B/$total_mem + else + memory=$(($used_mem/1024)) + echo $memory\G\B/$total_mem + fi + ;; CYGWIN*|MINGW32*|MSYS*|MINGW*) # TODO - windows compatability