use qtile_etras

This commit is contained in:
Daniel Mevec 2023-01-21 10:46:16 +01:00
parent 14a62b39ce
commit d6eebd5c10

View file

@ -4,22 +4,33 @@ import re
import socket import socket
import subprocess import subprocess
from libqtile import qtile from libqtile import qtile
from libqtile.config import Click, Drag, Group, KeyChord, Key, Match, Screen from libqtile.config import Click, Drag, Group, KeyChord, Key, Match, Screen, ScratchPad, DropDown
from libqtile.command import lazy from libqtile.command import lazy
from libqtile import layout, bar, widget, hook 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 qtile_extras import widget
from qtile_extras.widget.decorations import PowerLineDecoration
from qutils import get_num_screens from qutils import get_num_screens
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 = "qutebrowser" # My browser of choice myBrowser = "firefox" # My browser of choice
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"]
@ -29,6 +40,7 @@ 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
@ -36,21 +48,12 @@ keys = [
### The essentials ### The essentials
Key([mod], "Return", lazy.spawn(myTerm), desc='Launches My Terminal'), Key([mod], "Return", lazy.spawn(myTerm), desc='Launches My Terminal'),
Key([mod, "shift"], "Return", lazy.spawn("rofi -show run"), desc='Run Launcher'), Key([mod, "shift"], "Return", lazy.spawn("rofi -show run"), desc='Run Launcher'),
# Key([mod, "shift"], "Return", lazy.spawn("ulauncher"), desc='Run Launcher'),
# Key([mod, "shift"], "Return", lazy.spawncmd(), desc="Spawn a command using a prompt widget"),
Key([mod], "b", lazy.spawn(myBrowser),desc='Qutebrowser'), Key([mod], "b", lazy.spawn(myBrowser),desc='Qutebrowser'),
Key([mod], "l", lazy.spawn("cinnamon-screensaver-command -a"), desc='Qutebrowser'), Key([mod], "l", lazy.spawn("cinnamon-screensaver-command -a"), desc='Qutebrowser'),
# Key([mod], "/", lazy.spawn("dtos-help"), desc='DTOS Help'),
Key([mod], "Tab", lazy.next_layout(), desc='Toggle through layouts'), Key([mod], "Tab", lazy.next_layout(), desc='Toggle through layouts'),
Key([mod, "shift"], "c",lazy.window.kill(), desc='Kill active window'), Key([mod, "shift"], "c",lazy.window.kill(), desc='Kill active window'),
Key([mod, "shift"], "r", lazy.restart(), desc='Restart Qtile'), Key([mod, "shift"], "r", lazy.restart(), desc='Restart Qtile'),
Key([mod, "shift"], "q", lazy.shutdown(), desc='Shutdown Qtile'), Key([mod, "shift"], "q", lazy.shutdown(), desc='Shutdown Qtile'),
# Key(["control", "shift"], "e", lazy.spawn("emacsclient -c -a emacs"),desc='Doom Emacs'),
### Switch focus to specific monitor (out of three)
Key([mod], "w", lazy.to_screen(0), desc='Keyboard focus to monitor 1' ),
Key([mod], "e", lazy.to_screen(1), desc='Keyboard focus to monitor 2' ),
Key([mod], "r", lazy.to_screen(2), desc='Keyboard focus to monitor 3' ),
### Switch focus of monitors ### Switch focus of monitors
Key([mod], "period", lazy.next_screen(), desc='Move focus to next monitor'), Key([mod], "period", lazy.next_screen(), desc='Move focus to next monitor'),
@ -90,19 +93,16 @@ keys = [
desc='Switch which side main pane occupies (XmonadTall)'), desc='Switch which side main pane occupies (XmonadTall)'),
Key([mod], "space", lazy.layout.next(), desc='Switch window focus to other pane(s) of stack'), Key([mod], "space", lazy.layout.next(), desc='Switch window focus to other pane(s) of stack'),
Key([mod, "shift"], "space", lazy.layout.toggle_split(), Key([mod, "shift"], "space", lazy.layout.toggle_split(),
desc='Toggle between split and unsplit sides of stack' ), desc='Toggle between split and unsplit sides of stack'),
] ]
groups = [Group("DEV", layout='monadtall'), groups = [Group("CHT", layout='max', matches=[Match(wm_class=('microsoft teams - preview'))]),
Group("WWW", layout='monadtall'), Group("WWW", layout='monadtall', matches=[Match(wm_class=['Firefox','firefox','firefox-bin','Chromium','Google-chrome','google-chrome'])]),
Group("DEV", layout='max'),
Group("SYS", layout='monadtall'), Group("SYS", layout='monadtall'),
Group("DOC", layout='monadtall'), Group("REF", layout='monadtall'),
Group("VBOX", layout='monadtall'), Group("DOC", layout='monadtall', matches=[Match(wm_class=['obsidian'])]),
Group("CHAT", layout='ratiotile'), Group("DMP", layout='monadtall')]
Group("MUS", layout='monadtall'),
Group("VID", layout='monadtall'),
Group("GFX", layout='monadtall')]
# Allow MODKEY+[0 through 9] to bind to groups, see https://docs.qtile.org/en/stable/manual/config/groups.html # Allow MODKEY+[0 through 9] to bind to groups, see https://docs.qtile.org/en/stable/manual/config/groups.html
# MOD4 + index Number : Switch to Group[index] # MOD4 + index Number : Switch to Group[index]
@ -110,6 +110,22 @@ groups = [Group("DEV", layout='monadtall'),
from libqtile.dgroups import simple_key_binder from libqtile.dgroups import simple_key_binder
dgroups_key_binder = simple_key_binder("mod4") dgroups_key_binder = simple_key_binder("mod4")
groups.append(ScratchPad('scratch',
[
DropDown('term', myTerm, height=0.66, width=0.66, x=0.166, y=0.166),
DropDown('qalc', myTerm+' -e qalc', height=0.66, width=0.33, x=0.33, y=0.166),
DropDown('nnn', myTerm+' -e nnn -d', height=0.66, width=0.66, x=0.166, y=0.166),
DropDown('sound', 'cinnamon-settings sound', height=0.66, width=0.50, x=0.25, y=0.166),
]),
)
keys.extend([
Key([mod], 'q', lazy.group['scratch'].dropdown_toggle('qalc')),
Key([mod], 'w', lazy.group['scratch'].dropdown_toggle('term')),
Key([mod], 'e', lazy.group['scratch'].dropdown_toggle('nnn')),
Key([mod], 's', lazy.group['scratch'].dropdown_toggle('sound')),
])
layout_theme = {"border_width": 2, layout_theme = {"border_width": 2,
"margin": 8, "margin": 8,
"border_focus": Colors.green, "border_focus": Colors.green,
@ -117,38 +133,30 @@ layout_theme = {"border_width": 2,
} }
layouts = [ layouts = [
#layout.MonadWide(**layout_theme),
#layout.Bsp(**layout_theme),
#layout.Stack(stacks=2, **layout_theme),
#layout.Columns(**layout_theme),
#layout.RatioTile(**layout_theme),
# layout.Tile(shift_windows=True, **layout_theme),
#layout.VerticalTile(**layout_theme),
layout.Matrix(**layout_theme),
#layout.Zoomy(**layout_theme),
layout.MonadTall(**layout_theme), layout.MonadTall(**layout_theme),
# layout.Max(**layout_theme), layout.MonadWide(**layout_theme),
layout.Max(**layout_theme),
layout.RatioTile(**layout_theme), layout.RatioTile(**layout_theme),
layout.TreeTab( # layout.TreeTab(
font = "Ubuntu", # font = "Ubuntu",
fontsize = 10, # fontsize = 10,
# sections = ["FIRST", "SECOND", "THIRD", "FOURTH"], # # sections = ["FIRST", "SECOND", "THIRD", "FOURTH"],
section_fontsize = 10, # section_fontsize = 10,
border_width = 2, # border_width = 2,
bg_color = Colors.bg, # bg_color = Colors.bg,
active_bg = Colors.green, # active_bg = Colors.green,
active_fg = Colors.bg, # active_fg = Colors.bg,
inactive_bg = Colors.grey, # inactive_bg = Colors.grey,
inactive_fg = Colors.bg, # inactive_fg = Colors.bg,
padding_left = 0, # padding_left = 0,
padding_x = 0, # padding_x = 0,
padding_y = 5, # padding_y = 5,
section_top = 10, # section_top = 10,
section_bottom = 20, # section_bottom = 20,
level_shift = 8, # level_shift = 8,
vspace = 3, # vspace = 3,
panel_width = 200 # panel_width = 150
), # ),
# layout.Floating(**layout_theme) # layout.Floating(**layout_theme)
] ]
@ -164,6 +172,19 @@ 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 = {
"decorations": [
PowerLineDecoration(path='back_slash')
]
}
widgets_list = [ widgets_list = [
# widget.Image( # widget.Image(
# filename = "~/.config/qtile/icons/python-white.png", # filename = "~/.config/qtile/icons/python-white.png",
@ -175,7 +196,7 @@ def init_widgets_list():
foreground = Colors.fg, foreground = Colors.fg,
fontsize = 22, fontsize = 22,
padding = 12, padding = 12,
mouse_callbacks = {'Button1': lambda: qtile.cmd_spawn(myTerm)} # mouse_callbacks = {'Button1': lambda: qtile.cmd_spawn(myTerm)}
), ),
widget.GroupBox( widget.GroupBox(
font = "Ubuntu Bold", font = "Ubuntu Bold",
@ -217,21 +238,19 @@ def init_widgets_list():
fontsize = 10, fontsize = 10,
foreground = Colors.yellow, foreground = Colors.yellow,
background = Colors.bg, background = Colors.bg,
padding = 0 padding = 0,
**powerline,
), ),
widget.Systray( widget.Systray(
background = Colors.bg, background = Colors.bg1,
padding = 5 padding = 5,
), **powerline,
widget.Spacer(length=6),
widget.TextBox(
text = u'\ue0be',
background = Colors.bg,
foreground = Colors.yellow,
padding = 0,
fontsize = 26,
width = 24
), ),
# UPowerWidget(
# background = Colors.yellow,
# foreground = Colors.fg,
# **powerline,
# ),
widget.Battery( widget.Battery(
battery = 0, battery = 0,
fmt = ' {}', fmt = ' {}',
@ -243,6 +262,7 @@ def init_widgets_list():
format = '{char} {percent:2.0%} {hour:d}:{min:02d}', format = '{char} {percent:2.0%} {hour:d}:{min:02d}',
background = Colors.yellow, background = Colors.yellow,
foreground = Colors.bg, foreground = Colors.bg,
**powerline,
), ),
# widget.Battery( # widget.Battery(
# battery = 1, # battery = 1,
@ -256,124 +276,49 @@ def init_widgets_list():
# background = Colors.yellow, # background = Colors.yellow,
# foreground = Colors.bg, # foreground = Colors.bg,
# ), # ),
# widget.Net(
# interface = "enp0s31f6",
# format = '{down} ↓↑ {up}',
# prefix='M',
# foreground = Colors.bg,
# background = Colors.yellow,
# ),
widget.TextBox(
text = u'\ue0be',
background = Colors.yellow,
foreground = Colors.orange,
padding = 0,
fontsize = 26,
width = 24
),
widget.TextBox(
text = u"\uf8c7",
foreground = Colors.bg,
background = Colors.orange,
fontsize = 14
),
widget.ThermalSensor( widget.ThermalSensor(
foreground = Colors.bg, foreground = Colors.bg,
background = Colors.orange, background = Colors.orange,
threshold = 90, threshold = 90,
fmt = ' {}', fmt = '\uf8c7 {}',
), **powerline,
widget.TextBox(
text = u'\ue0be',
background = Colors.orange,
foreground = Colors.red,
padding = 0,
fontsize = 26,
width = 24
),
widget.TextBox(
text = u"\uf546",
foreground = Colors.bg,
background = Colors.red,
fontsize = 16
), ),
widget.CheckUpdates( widget.CheckUpdates(
update_interval = 1800, update_interval = 1800,
distro = "Ubuntu", distro = "Mint",
display_format = " {updates}", custom_command = "aptitude search '~U'",
markup = False,
display_format = "\uf546 {updates}",
foreground = Colors.bg, foreground = Colors.bg,
colour_have_updates = Colors.bg, colour_have_updates = Colors.bg,
colour_no_updates = Colors.bg, colour_no_updates = Colors.bg,
# mouse_callbacks = {'Button1': lambda: qtile.cmd_spawn(myTerm + ' -e sudo apt upgrade')}, # mouse_callbacks = {'Button1': lambda: qtile.cmd_spawn(myTerm + ' -e sudo apt upgrade')},
background = Colors.red
),
widget.TextBox(
text = u'\ue0be',
background = Colors.red, background = Colors.red,
foreground = Colors.purple, **powerline,
padding = 0,
fontsize = 26,
width = 24
),
widget.TextBox(
text = u"\uf85a",
foreground = Colors.bg,
background = Colors.purple,
fontsize = 20
), ),
widget.Memory( widget.Memory(
foreground = Colors.bg, foreground = Colors.bg,
background = Colors.purple, background = Colors.purple,
mouse_callbacks = {'Button1': lambda: qtile.cmd_spawn(myTerm + ' -e htop')}, mouse_callbacks = {'Button1': lambda: qtile.cmd_spawn(myTerm + ' -e htop')},
fmt = '{}', fmt = '{}',
format = '{MemPercent:5.1f} %', format = '\uf85a{MemPercent:5.1f} %',
), **powerline,
widget.TextBox(
text = u'\ue0be',
background = Colors.purple,
foreground = Colors.blue,
padding = 0,
fontsize = 26,
width = 24
),
widget.TextBox(
text = u"\ufb19",
foreground = Colors.bg,
background = Colors.blue,
fontsize = 18
), ),
widget.CPU( widget.CPU(
foreground = Colors.bg, foreground = Colors.bg,
background = Colors.blue, background = Colors.blue,
fmt = '{}', fmt = '{}',
format = '{load_percent:5.1f}%', format = '\ufb19{load_percent:5.1f}%',
**powerline,
), ),
widget.TextBox( widget.Net(
text = u'\ue0be', # bash script to get the active network interface: ip
background = Colors.blue, interface = get_network_interface(),
foreground = Colors.aqua, format = '{down} ↓↑ {up}',
padding = 0, prefix='M',
fontsize = 26,
width = 24
),
widget.TextBox(
text = u"\uf026",
foreground = Colors.bg, foreground = Colors.bg,
background = Colors.aqua, background = Colors.aqua,
fontsize = 20 **powerline,
),
widget.Volume(
foreground = Colors.bg,
background = Colors.aqua,
fmt = '{}',
),
widget.TextBox(
text = u'\ue0be',
background = Colors.aqua,
foreground = Colors.green,
padding = 0,
fontsize = 26,
width = 24
), ),
widget.Clock( widget.Clock(
foreground = Colors.bg, foreground = Colors.bg,
@ -386,8 +331,8 @@ def init_widgets_list():
def init_widgets_screen1(): def init_widgets_screen1():
widgets_screen1 = init_widgets_list() widgets_screen1 = init_widgets_list()
del widgets_screen1[7:9] # Slicing removes unwanted widgets (systray) on Monitors 1,3 del widgets_screen1[7:8] # Slicing removes unwanted widgets (systray) on Monitors 1,3
del widgets_screen1[4:5] # Slicing removes unwanted widgets (systray) on Monitors 1,3 del widgets_screen1[4:5] # Slicing removes unwanted widgets (prompt) on Monitors 1,3
return widgets_screen1 return widgets_screen1
def init_widgets_screen2(): def init_widgets_screen2():