2021-04-27 23:25:21 +03:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
This module produces list of enabled network interfaces
|
|
|
|
|
|
|
|
"""
|
|
|
|
import sys
|
|
|
|
import subprocess
|
|
|
|
from subprocess import check_output
|
|
|
|
|
|
|
|
class Py3status:
|
|
|
|
format = 'NET: {status}'
|
|
|
|
|
|
|
|
def net_status(self):
|
2021-08-28 20:15:49 +03:00
|
|
|
# Retrieve active connections, Ignore bridges
|
|
|
|
command = 'nmcli --mode multiline --colors no con show --active | rg DEVICE | awk -F":" \'{ gsub(/ /, ""); print $2}\' | rg \'^[^br-]\''
|
2021-04-27 23:25:21 +03:00
|
|
|
return_value = check_output(command, shell=True)
|
|
|
|
value = return_value.decode("utf-8")
|
|
|
|
value = value.replace('\n', ', ').strip(', ')
|
|
|
|
full_text = self.py3.safe_format(self.format, { 'status': value})
|
|
|
|
|
|
|
|
return {
|
|
|
|
'full_text': full_text,
|
|
|
|
'cached_until': self.py3.time_in(15)
|
|
|
|
}
|