Change i3blocks scripts
This commit is contained in:
parent
8eb17bf11d
commit
9fc8a3f06c
3 changed files with 17 additions and 13 deletions
dotfiles/i3
|
@ -59,14 +59,9 @@ LABEL=<span foreground='#a1d569'> </span>
|
||||||
DISK=/run/media/flyingscorpio/Backup
|
DISK=/run/media/flyingscorpio/Backup
|
||||||
|
|
||||||
[ccurrency]
|
[ccurrency]
|
||||||
LABEL=test
|
|
||||||
command=scripts/ccurrency -f USD
|
command=scripts/ccurrency -f USD
|
||||||
interval=1800
|
interval=1800
|
||||||
|
|
||||||
[ccurrency]
|
|
||||||
command=scripts/ccurrency -f EUR
|
|
||||||
interval=1800
|
|
||||||
|
|
||||||
[ccurrency]
|
[ccurrency]
|
||||||
command=scripts/ccurrency -c ETH -f EUR
|
command=scripts/ccurrency -c ETH -f EUR
|
||||||
interval=1800
|
interval=1800
|
||||||
|
|
|
@ -12,9 +12,13 @@ def get_disk_free_space(disk: str) -> str:
|
||||||
"""Return available disk space in GiB."""
|
"""Return available disk space in GiB."""
|
||||||
|
|
||||||
stat = os.statvfs(disk)
|
stat = os.statvfs(disk)
|
||||||
result = stat.f_bavail * stat.f_bsize / 1024 / 1024 / 1024
|
total = stat.f_blocks * stat.f_bsize / 1024 / 1024 / 1024
|
||||||
|
available = stat.f_bavail * stat.f_bsize / 1024 / 1024 / 1024
|
||||||
|
percentage = (total - available) / total
|
||||||
|
avail_format = "{0:0.1f} GiB free".format(available)
|
||||||
|
percent_format = "({:.1%} used)".format(percentage)
|
||||||
|
|
||||||
return "{0:0.1f}".format(result) + " GiB free"
|
return "{} {}".format(avail_format, percent_format)
|
||||||
|
|
||||||
|
|
||||||
OUTPUT = os.environ['LABEL'] + get_disk_free_space(os.environ["DISK"])
|
OUTPUT = os.environ['LABEL'] + get_disk_free_space(os.environ["DISK"])
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
"""Simple script for i3blocks for VPN status with ProtonVPN.
|
||||||
|
|
||||||
|
Author: flyingscorpio
|
||||||
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from protonvpn_cli import utils as pvpn_utils
|
from protonvpn_cli import utils as pvpn_utils # type: ignore
|
||||||
|
|
||||||
|
|
||||||
IP_ADDR = pvpn_utils.get_ip_info()[0]
|
IP_ADDR = pvpn_utils.get_ip_info()[0]
|
||||||
|
@ -11,11 +16,11 @@ if not pvpn_utils.is_connected():
|
||||||
OUTPUT += " {}".format(IP_ADDR)
|
OUTPUT += " {}".format(IP_ADDR)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
CONNECTED_SERVER = pvpn_utils.get_config_value("metadata", "connected_server")
|
SERVER = pvpn_utils.get_config_value("metadata", "connected_server")
|
||||||
SERVERS = pvpn_utils.get_servers()
|
ALL_SERVERS = pvpn_utils.get_servers()
|
||||||
COUNTRY_CODE = pvpn_utils.get_server_value(CONNECTED_SERVER, "ExitCountry", SERVERS)
|
CODE = pvpn_utils.get_server_value(SERVER, "ExitCountry", ALL_SERVERS)
|
||||||
COUNTRY = pvpn_utils.get_country_name(COUNTRY_CODE)
|
COUNTRY = pvpn_utils.get_country_name(CODE)
|
||||||
CITY = pvpn_utils.get_server_value(CONNECTED_SERVER, "City", SERVERS)
|
CITY = pvpn_utils.get_server_value(SERVER, "City", ALL_SERVERS)
|
||||||
OUTPUT = os.environ['LABEL_ON']
|
OUTPUT = os.environ['LABEL_ON']
|
||||||
OUTPUT += " {} - {}, {}".format(IP_ADDR, CITY, COUNTRY)
|
OUTPUT += " {} - {}, {}".format(IP_ADDR, CITY, COUNTRY)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue