22 lines
432 B
Python
Executable file
22 lines
432 B
Python
Executable file
#!/usr/bin/python3
|
|
|
|
"""Simple script for i3blocks for disk free space.
|
|
|
|
Author: flyingscorpio
|
|
"""
|
|
|
|
import os
|
|
|
|
|
|
def get_disk_free_space(disk: str) -> str:
|
|
"""Return available disk space in GiB."""
|
|
|
|
stat = os.statvfs(disk)
|
|
result = stat.f_bavail * stat.f_bsize / 1024 / 1024 / 1024
|
|
|
|
return "{0:0.1f}".format(result) + " GiB free"
|
|
|
|
|
|
OUTPUT = os.environ['LABEL'] + get_disk_free_space(os.environ["DISK"])
|
|
|
|
print(OUTPUT)
|