move net-interface detection to qutils
This commit is contained in:
parent
1677533c1d
commit
680f6cac58
2 changed files with 32 additions and 43 deletions
|
|
@ -10,40 +10,16 @@ from libqtile import layout, bar, widget, hook
|
|||
from libqtile.lazy import lazy
|
||||
from libqtile.utils import guess_terminal
|
||||
from typing import List # noqa: F401from typing import List # noqa: F401
|
||||
from volume import Volume
|
||||
|
||||
from qtile_extras import widget
|
||||
from qtile_extras.widget.decorations import PowerLineDecoration
|
||||
|
||||
from qutils import get_num_screens
|
||||
|
||||
from qutils import get_num_screens, get_network_interface, Colors
|
||||
|
||||
mod = "mod4" # Sets mod key to SUPER/WINDOWS
|
||||
myTerm = "alacritty" # My terminal of choice
|
||||
myBrowser = "firefox" #"qutebrowser" # My browser of choice
|
||||
myBrowser = "firefox" # My browser of choice
|
||||
|
||||
class Colors:
|
||||
bg = ["#282828", "#3c3836"] #background
|
||||
bg1 = ["#3c3836", "#504945"]
|
||||
bg2 = ["#504945", "#665c54"]
|
||||
bg3 = ["#665c54", "#7c6f64"]
|
||||
|
||||
fg = ["#ebdbb2", "#fbf1c7"] #foreground
|
||||
fg1 = ["#d5c4a1", "#ebdbb2"]
|
||||
fg2 = ["#bdae93", "#d5c4a1"]
|
||||
fg3 = ["#a89984", "#bdae93"]
|
||||
|
||||
red = ["#cc241d", "#fb4934"]
|
||||
green = ["#98971a", "#b8bb26"]
|
||||
yellow = ["#d79921", "#fabd2f"]
|
||||
blue = ["#458588", "#83a598"]
|
||||
purple = ["#b16286", "#d3869b"]
|
||||
aqua = ["#689d6a", "#8ec07c"]
|
||||
orange = ["#d65d0e", "#fe8019"]
|
||||
gray = ["#928374", "#a89984"]
|
||||
grey = gray
|
||||
|
||||
def _init_(self ):
|
||||
pass
|
||||
|
||||
keys = [
|
||||
### The essentials
|
||||
|
|
@ -173,13 +149,6 @@ widget_defaults = dict(
|
|||
extension_defaults = widget_defaults.copy()
|
||||
|
||||
def init_widgets_list():
|
||||
|
||||
def get_network_interface():
|
||||
proc_ip = subprocess.Popen(['ip', 'route', 'get', '8.8.8.8'], stdout=subprocess.PIPE)
|
||||
proc_awk = subprocess.check_output(['awk', '--', "{printf $5}"], stdin=proc_ip.stdout)
|
||||
proc_ip.stdout.close()
|
||||
return proc_awk.decode('utf-8')
|
||||
|
||||
powerline = {
|
||||
"decorations": [
|
||||
PowerLineDecoration(path='back_slash')
|
||||
|
|
@ -325,7 +294,7 @@ def init_widgets_list():
|
|||
foreground = Colors.bg,
|
||||
background = Colors.green,
|
||||
format = "%Y-%m-%d %a %H:%M ",
|
||||
padding = 5,
|
||||
padding = 5
|
||||
),
|
||||
]
|
||||
return widgets_list
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import subprocess
|
||||
|
||||
def get_num_screens():
|
||||
from Xlib import display as xdisplay
|
||||
|
||||
|
|
@ -21,21 +23,39 @@ def get_num_screens():
|
|||
return 1
|
||||
else:
|
||||
return num_monitors
|
||||
|
||||
|
||||
def get_network_interface():
|
||||
proc_ip = subprocess.Popen(['ip', 'route', 'get', '8.8.8.8'], stdout=subprocess.PIPE)
|
||||
proc_awk = subprocess.check_output(['awk', '--', "{printf $5}"], stdin=proc_ip.stdout)
|
||||
proc_ip.stdout.close()
|
||||
return proc_awk.decode('utf-8')
|
||||
|
||||
|
||||
class Colors:
|
||||
bg = ["#282828", "#3c3836"] #background
|
||||
bg1 = ["#3c3836", "#504945"]
|
||||
bg2 = ["#504945", "#665c54"]
|
||||
bg3 = ["#665c54", "#7c6f64"]
|
||||
|
||||
fg = ["#ebdbb2", "#fbf1c7"] #foreground
|
||||
red = ["#cc241d", "#fb4934"]
|
||||
green = ["#98971a", "#b8bb26"]
|
||||
yellow = ["#d79921", "#fabd2f"]
|
||||
blue = ["#458588", "#83a598"]
|
||||
purple = ["#b16286", "#d3869b"]
|
||||
aqua = ["#689d6a", "#8ec07c"]
|
||||
orange = ["#d65d0e", "#fe8019"]
|
||||
fg1 = ["#d5c4a1", "#ebdbb2"]
|
||||
fg2 = ["#bdae93", "#d5c4a1"]
|
||||
fg3 = ["#a89984", "#bdae93"]
|
||||
|
||||
red = ["#cc241d", "#fb4934"]
|
||||
green = ["#98971a", "#b8bb26"]
|
||||
yellow = ["#d79921", "#fabd2f"]
|
||||
blue = ["#458588", "#83a598"]
|
||||
purple = ["#b16286", "#d3869b"]
|
||||
aqua = ["#689d6a", "#8ec07c"]
|
||||
orange = ["#d65d0e", "#fe8019"]
|
||||
gray = ["#928374", "#a89984"]
|
||||
grey = gray
|
||||
|
||||
def _init_(self ):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("Number of Screens: {}".format(get_num_screens()))
|
||||
Loading…
Add table
Reference in a new issue