mirror of
https://github.com/eoli3n/dotfiles
synced 2024-11-22 23:12:32 +01:00
tooltip for storage module waybar
This commit is contained in:
parent
a173ffc4ca
commit
ee9bbf6a02
@ -1,5 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Functions
|
||||
escape() { while read l; do printf '%s\\n' "$l"; done }
|
||||
|
||||
# Vars
|
||||
warning=85
|
||||
critical=95
|
||||
target="$1"
|
||||
@ -13,13 +17,15 @@ then
|
||||
exit
|
||||
elif [[ "$fstype" == zfs ]]
|
||||
then
|
||||
zfsroot=$(echo $target | sed 's:/.*::')
|
||||
pcent=$(zpool list -o cap -H $zfsroot | tr -d '%')
|
||||
zfsroot=$(findmnt -nT "$target" -o SOURCE | sed 's:/.*::')
|
||||
pcent=$(zpool list -o cap -H "$zfsroot" | tr -d '%')
|
||||
tooltip=$(escape <<< "$(zfs list -o name,used,compressratio,logicalused,avail)")
|
||||
else
|
||||
pcent=$(df "$target" --output="pcent" 2>/dev/null | sed 1d | tr -d ' ' | tr -d '%')
|
||||
tooltip="$pcent"
|
||||
fi
|
||||
|
||||
json_fmt='{"text": "%s" , "class": "%s" }\n'
|
||||
json_fmt='{"text": "%s" , "class": "%s", "tooltip": "%s"}\n'
|
||||
|
||||
if [[ -z $pcent ]]
|
||||
then
|
||||
@ -27,12 +33,12 @@ then
|
||||
else
|
||||
if [[ $pcent -lt $warning ]]
|
||||
then
|
||||
printf "$json_fmt" "$pcent" "normal"
|
||||
printf "$json_fmt" "$pcent" "normal" "$tooltip"
|
||||
elif [[ $pcent -ge $warning ]] && [[ $pcent -lt $critical ]]
|
||||
then
|
||||
printf "$json_fmt" "$pcent" "warning"
|
||||
printf "$json_fmt" "$pcent" "warning" "$tooltip"
|
||||
elif [[ $pcent -ge $critical ]]
|
||||
then
|
||||
printf "$json_fmt" "$pcent" "critical"
|
||||
printf "$json_fmt" "$pcent" "critical" "$tooltip"
|
||||
fi
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user