diff --git a/scripts/battery.sh b/scripts/battery.sh index 4d57ad0..4151f92 100755 --- a/scripts/battery.sh +++ b/scripts/battery.sh @@ -1,4 +1,6 @@ #!/usr/bin/env bash +# setting the locale, some users have issues with different locales, this forces the correct one +export LC_ALL=en_US.UTF-8 linux_acpi() { arg=$1 @@ -43,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 ;; @@ -57,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 ;; @@ -72,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/cpu_info.sh b/scripts/cpu_info.sh index b96c399..cc10c9d 100755 --- a/scripts/cpu_info.sh +++ b/scripts/cpu_info.sh @@ -1,4 +1,6 @@ #!/usr/bin/env bash +# setting the locale, some users have issues with different locales, this forces the correct one +export LC_ALL=en_US.UTF-8 # function for getting the refresh rate get_tmux_option() { diff --git a/scripts/dracula.sh b/scripts/dracula.sh index d25e57b..da72637 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -1,4 +1,6 @@ #!/usr/bin/env bash +# setting the locale, some users have issues with different locales, this forces the correct one +export LC_ALL=en_US.UTF-8 get_tmux_option() { local option=$1 diff --git a/scripts/gpu_usage.sh b/scripts/gpu_usage.sh index 785cf8f..d9685c8 100755 --- a/scripts/gpu_usage.sh +++ b/scripts/gpu_usage.sh @@ -1,4 +1,6 @@ #!/usr/bin/env bash +# setting the locale, some users have issues with different locales, this forces the correct one +export LC_ALL=en_US.UTF-8 # function for getting the refresh rate get_tmux_option() { diff --git a/scripts/network.sh b/scripts/network.sh index 145d142..bd7f84e 100755 --- a/scripts/network.sh +++ b/scripts/network.sh @@ -1,4 +1,6 @@ #!/usr/bin/env bash +# setting the locale, some users have issues with different locales, this forces the correct one +export LC_ALL=en_US.UTF-8 HOSTS="google.com github.com example.com" diff --git a/scripts/ram_info.sh b/scripts/ram_info.sh index 98d348d..f0f7bff 100755 --- a/scripts/ram_info.sh +++ b/scripts/ram_info.sh @@ -1,4 +1,6 @@ #!/usr/bin/env bash +# setting the locale, some users have issues with different locales, this forces the correct one +export LC_ALL=en_US.UTF-8 # function for getting the refresh rate get_tmux_option() { @@ -45,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 diff --git a/scripts/sleep_weather.sh b/scripts/sleep_weather.sh index 0270409..4ce6019 100755 --- a/scripts/sleep_weather.sh +++ b/scripts/sleep_weather.sh @@ -1,4 +1,6 @@ #!/usr/bin/env bash +# setting the locale, some users have issues with different locales, this forces the correct one +export LC_ALL=en_US.UTF-8 #wrapper script for running weather on interval diff --git a/scripts/weather.sh b/scripts/weather.sh index 7a5fd3c..e01b0fe 100755 --- a/scripts/weather.sh +++ b/scripts/weather.sh @@ -1,4 +1,6 @@ #!/usr/bin/env bash +# setting the locale, some users have issues with different locales, this forces the correct one +export LC_ALL=en_US.UTF-8 fahrenheit=$1 location=$2