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.lazy import lazy
|
||||||
from libqtile.utils import guess_terminal
|
from libqtile.utils import guess_terminal
|
||||||
from typing import List # noqa: F401from typing import List # noqa: F401
|
from typing import List # noqa: F401from typing import List # noqa: F401
|
||||||
from volume import Volume
|
|
||||||
|
|
||||||
from qtile_extras import widget
|
from qtile_extras import widget
|
||||||
from qtile_extras.widget.decorations import PowerLineDecoration
|
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
|
mod = "mod4" # Sets mod key to SUPER/WINDOWS
|
||||||
myTerm = "alacritty" # My terminal of choice
|
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 = [
|
keys = [
|
||||||
### The essentials
|
### The essentials
|
||||||
|
|
@ -173,13 +149,6 @@ widget_defaults = dict(
|
||||||
extension_defaults = widget_defaults.copy()
|
extension_defaults = widget_defaults.copy()
|
||||||
|
|
||||||
def init_widgets_list():
|
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 = {
|
powerline = {
|
||||||
"decorations": [
|
"decorations": [
|
||||||
PowerLineDecoration(path='back_slash')
|
PowerLineDecoration(path='back_slash')
|
||||||
|
|
@ -325,7 +294,7 @@ def init_widgets_list():
|
||||||
foreground = Colors.bg,
|
foreground = Colors.bg,
|
||||||
background = Colors.green,
|
background = Colors.green,
|
||||||
format = "%Y-%m-%d %a %H:%M ",
|
format = "%Y-%m-%d %a %H:%M ",
|
||||||
padding = 5,
|
padding = 5
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
return widgets_list
|
return widgets_list
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import subprocess
|
||||||
|
|
||||||
def get_num_screens():
|
def get_num_screens():
|
||||||
from Xlib import display as xdisplay
|
from Xlib import display as xdisplay
|
||||||
|
|
||||||
|
|
@ -22,9 +24,25 @@ def get_num_screens():
|
||||||
else:
|
else:
|
||||||
return num_monitors
|
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:
|
class Colors:
|
||||||
bg = ["#282828", "#3c3836"] #background
|
bg = ["#282828", "#3c3836"] #background
|
||||||
|
bg1 = ["#3c3836", "#504945"]
|
||||||
|
bg2 = ["#504945", "#665c54"]
|
||||||
|
bg3 = ["#665c54", "#7c6f64"]
|
||||||
|
|
||||||
fg = ["#ebdbb2", "#fbf1c7"] #foreground
|
fg = ["#ebdbb2", "#fbf1c7"] #foreground
|
||||||
|
fg1 = ["#d5c4a1", "#ebdbb2"]
|
||||||
|
fg2 = ["#bdae93", "#d5c4a1"]
|
||||||
|
fg3 = ["#a89984", "#bdae93"]
|
||||||
|
|
||||||
red = ["#cc241d", "#fb4934"]
|
red = ["#cc241d", "#fb4934"]
|
||||||
green = ["#98971a", "#b8bb26"]
|
green = ["#98971a", "#b8bb26"]
|
||||||
yellow = ["#d79921", "#fabd2f"]
|
yellow = ["#d79921", "#fabd2f"]
|
||||||
|
|
@ -34,8 +52,10 @@ class Colors:
|
||||||
orange = ["#d65d0e", "#fe8019"]
|
orange = ["#d65d0e", "#fe8019"]
|
||||||
gray = ["#928374", "#a89984"]
|
gray = ["#928374", "#a89984"]
|
||||||
grey = gray
|
grey = gray
|
||||||
|
|
||||||
def _init_(self ):
|
def _init_(self ):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print("Number of Screens: {}".format(get_num_screens()))
|
print("Number of Screens: {}".format(get_num_screens()))
|
||||||
Loading…
Add table
Reference in a new issue