From fd46b9bc1c73bd6abfdcac3796355c1322b08c6c Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Thu, 10 May 2018 16:06:20 +0100 Subject: [PATCH] Re-write disk free blocks --- i3/blocks/freeSpace | 25 +++++++++++++++++++++++++ i3/i3blocks.conf | 12 ++++++------ 2 files changed, 31 insertions(+), 6 deletions(-) create mode 100755 i3/blocks/freeSpace diff --git a/i3/blocks/freeSpace b/i3/blocks/freeSpace new file mode 100755 index 00000000..6cf08dfb --- /dev/null +++ b/i3/blocks/freeSpace @@ -0,0 +1,25 @@ +#!/usr/bin/sh + +partition=$1 + +if [ ! -n "$partition" ]; then + partition="/" +fi + + +line=$(/usr/bin/df -h $partition | sed -n 2p) + +used=$(echo $line | awk -F ' ' '{print $3}') +total=$(echo $line | awk -F ' ' '{print $2}') +percent=$(echo $line | awk -F ' ' '{print $5}' | sed 's/[^0-9]//') + + + +echo "$used/$total $percent%" +echo "$used/$total" + +if [ "$percent" -gt 80 ]; then + echo "#FF8000" +elif [ "$percent" -gt 90 ]; then + echo "#FF0000" +fi diff --git a/i3/i3blocks.conf b/i3/i3blocks.conf index 88d63f02..5c48b431 100644 --- a/i3/i3blocks.conf +++ b/i3/i3blocks.conf @@ -90,7 +90,6 @@ interval=once # The type defaults to "mem" if the instance is not specified. [memory] label=MEM -separator=false interval=30 # Disk usage @@ -99,14 +98,15 @@ interval=30 # The script may be called with a optional argument to set the alert # (defaults to 10 for 10%). [disk] -label=HOME -#instance=/mnt/data +command=~/.dotfiles/i3/blocks/freeSpace +label=/ +instance=/ interval=30 -separator=false [disk] -label=ROOT -instance=/ +command=~/.dotfiles/i3/blocks/freeSpace /home +label=/home +#instance=/mnt/data interval=30 # Network interface monitoring