From 8cf4f2a4770e74df88ffe850801bc8e9124489ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Fl=C3=A4mg?= Date: Mon, 11 Nov 2024 08:32:53 +0100 Subject: [PATCH 1/2] fix: freebsd compatibility --- scripts/cpu_percentage.sh | 2 +- scripts/ram_percentage.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/cpu_percentage.sh b/scripts/cpu_percentage.sh index 5e6efe0..1220e4f 100755 --- a/scripts/cpu_percentage.sh +++ b/scripts/cpu_percentage.sh @@ -17,7 +17,7 @@ print_cpu_percentage() { elif is_osx; then cached_eval iostat -c 2 disk0 | sed '/^\s*$/d' | tail -n 1 | awk -v format="$cpu_percentage_format" '{usage=100-$6} END {printf(format, usage)}' | sed 's/,/./' elif is_freebsd || is_openbsd; then - cached_eval iostat -c 2 | sed '/^\s*$/d' | tail -n 1 | awk -v format="$cpu_percentage_format" '{usage=100-$NF} END {printf(format, usage)}' | sed 's/,/./' + cached_eval iostat -c 2 | sed '/^[[:space:]]*$/d' | tail -n 1 | awk -v format="$cpu_percentage_format" '{usage=100-$NF} END {printf(format, usage)}' | sed 's/,/./' else echo "Unknown iostat version please create an issue" fi diff --git a/scripts/ram_percentage.sh b/scripts/ram_percentage.sh index 25c85cd..718cccf 100755 --- a/scripts/ram_percentage.sh +++ b/scripts/ram_percentage.sh @@ -17,6 +17,8 @@ print_ram_percentage() { if command_exists "free"; then cached_eval free | awk -v format="$ram_percentage_format" '$1 ~ /Mem/ {printf(format, 100*$3/$2)}' + elif command_exists "freecolor"; then # freebsd: install freecolor first: $ pkg install freecolor + cached_eval freecolor -m -o | awk -v format="$ram_percentage_format" '$1 ~ /Mem/ {printf(format, 100*$3/$2)}' elif command_exists "vm_stat"; then # page size of 4096 bytes stats="$(cached_eval vm_stat)" From 11950be68ba684b6802fb40d4172e1f323565172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Fl=C3=A4mig?= Date: Mon, 11 Nov 2024 09:26:35 +0100 Subject: [PATCH 2/2] Update README.md add freebsd hint for memory usage --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index db29585..d0f802b 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,8 @@ This is done by introducing 12 new format strings that can be added to - `#{cpu_bg_color}` - will change the background color based on the CPU percentage - `#{cpu_fg_color}` - will change the foreground color based on the CPU percentage - `#{ram_icon}` - will display a RAM status icon -- `#{ram_percentage}` - will show RAM percentage (averaged across cores) +- `#{ram_percentage}` - will show RAM percentage (averaged across cores)\ + (freebsd user will need to install `freecolor`: `$ pkg install freecolor`) - `#{ram_bg_color}` - will change the background color based on the RAM percentage - `#{ram_fg_color}` - will change the foreground color based on the RAM percentage - `#{cpu_temp_icon}` - will display a CPU temperature status icon