update configs
This commit is contained in:
23
.config/waybar/scripts/wireguard.py
Normal file
23
.config/waybar/scripts/wireguard.py
Normal file
@ -0,0 +1,23 @@
|
||||
from argparse import ArgumentParser
|
||||
from json import dumps
|
||||
from subprocess import run
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument("interfaces", nargs="+", help="one or more names of interfaces to watch")
|
||||
args = parser.parse_args()
|
||||
|
||||
watch = set(args.interfaces)
|
||||
|
||||
ifconfig = run(["ifconfig", "-s"], capture_output=True, text=True).stdout
|
||||
|
||||
interfaces = {line.split()[0] for line in ifconfig.splitlines()[1:]}
|
||||
|
||||
active = interfaces.intersection(watch)
|
||||
|
||||
result = {
|
||||
"text": "active" if len(active) > 0 else "inactive",
|
||||
"tooltip": "\n".join(active),
|
||||
}
|
||||
|
||||
print(dumps(result))
|
||||
Reference in New Issue
Block a user