Add free memory to FreeBSD's waybar.
This commit is contained in:
parent
b2ea65faab
commit
4ec4ca0e63
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#
|
#
|
||||||
# Delete temporary files on entire disk
|
# Delete temporary files on entire disk
|
||||||
find / -type f -name '*.orig' -delete -or -name '*~' -delete
|
find / -type f -name '*.orig' -delete -or -name '*~' -delete -print
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
#battery,
|
#battery,
|
||||||
#clock,
|
#clock,
|
||||||
#cpu,
|
#cpu,
|
||||||
|
#custom-available_memory,
|
||||||
#custom-battery,
|
#custom-battery,
|
||||||
#custom-clock,
|
#custom-clock,
|
||||||
#idle_inhibitor,
|
#idle_inhibitor,
|
||||||
|
32
ansible/roles/sway/files/waybar_available_memory_freebsd
Normal file
32
ansible/roles/sway/files/waybar_available_memory_freebsd
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Read memory usage in FreeBSD
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
SLEEP_INTERVAL=${SLEEP_INTERVAL:-30}
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
page_size=$(sysctl -n hw.pagesize)
|
||||||
|
free_pages=$(sysctl -n vm.stats.vm.v_free_count)
|
||||||
|
free_bytes=$((page_size * free_pages))
|
||||||
|
total_pages=$(sysctl -n vm.stats.vm.v_page_count)
|
||||||
|
free_percent=$((100 * free_pages / total_pages))
|
||||||
|
text=""
|
||||||
|
|
||||||
|
if [ $free_bytes > $((1024 * 1024 * 1024)) ]; then
|
||||||
|
text="$((free_bytes / 1024 / 1024 / 1024)) GiB"
|
||||||
|
fi
|
||||||
|
|
||||||
|
tooltip="${free_percent}%"
|
||||||
|
|
||||||
|
jq --unbuffered --compact-output <<EOF
|
||||||
|
{
|
||||||
|
"text":"${text}",
|
||||||
|
"tooltip":"${tooltip}",
|
||||||
|
"percentage":${free_percent}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
sleep $SLEEP_INTERVAL
|
||||||
|
done
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
// "height": 10, // Waybar height (to be removed for auto height)
|
// "height": 10, // Waybar height (to be removed for auto height)
|
||||||
"modules-left": ["sway/workspaces", "sway/mode"],
|
"modules-left": ["sway/workspaces", "sway/mode"],
|
||||||
"modules-right": ["custom/battery", "idle_inhibitor", "custom/clock", "tray"],
|
"modules-right": ["custom/available_memory", "custom/battery", "idle_inhibitor", "custom/clock", "tray"],
|
||||||
"sway/workspaces": {
|
"sway/workspaces": {
|
||||||
"disable-scroll": true
|
"disable-scroll": true
|
||||||
},
|
},
|
||||||
@ -28,5 +28,11 @@
|
|||||||
"exec": "waybar_custom_battery",
|
"exec": "waybar_custom_battery",
|
||||||
"return-type": "json",
|
"return-type": "json",
|
||||||
"restart-interval": 30
|
"restart-interval": 30
|
||||||
|
},
|
||||||
|
"custom/available_memory": {
|
||||||
|
"exec": "waybar_custom_available_memory",
|
||||||
|
"return-type": "json",
|
||||||
|
"restart-interval": 30
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -49,3 +49,5 @@
|
|||||||
dest: /usr/local/bin/launch_sway
|
dest: /usr/local/bin/launch_sway
|
||||||
- src: waybar_battery_freebsd
|
- src: waybar_battery_freebsd
|
||||||
dest: /usr/local/bin/waybar_custom_battery
|
dest: /usr/local/bin/waybar_custom_battery
|
||||||
|
- src: waybar_available_memory_freebsd
|
||||||
|
dest: /usr/local/bin/waybar_custom_available_memory
|
||||||
|
Loading…
Reference in New Issue
Block a user