switch to upowr widget
This commit is contained in:
parent
3a9c08f07b
commit
7ababa5e3d
1 changed files with 147 additions and 120 deletions
|
|
@ -11,6 +11,7 @@ from libqtile.lazy import lazy
|
|||
from libqtile.utils import guess_terminal
|
||||
from typing import List # noqa: F401from typing import List # noqa: F401
|
||||
from qtile_extras import widget
|
||||
from qtile_extras.widget import UPowerWidget
|
||||
from qtile_extras.widget.decorations import PowerLineDecoration
|
||||
|
||||
|
||||
|
|
@ -19,11 +20,11 @@ from qutils import get_num_screens, get_network_interface, Colors
|
|||
mod = "mod4" # Sets mod key to SUPER/WINDOWS
|
||||
myTerm = "alacritty"
|
||||
myBrowser = "firefox"
|
||||
sound_ctrl = "cinnamon-settings sound"
|
||||
update_distro_key = "Ubuntu"
|
||||
sound_ctrl = "pavucontrol"
|
||||
update_distro_key = "Arch"
|
||||
|
||||
keys = [
|
||||
### The essentials
|
||||
# ## The essentials
|
||||
Key([mod], "Return", lazy.spawn(myTerm), desc='Launches My Terminal'),
|
||||
Key([mod, "shift"], "Return", lazy.spawn("rofi -show run"), desc='Run Launcher'),
|
||||
Key([mod], "b", lazy.spawn(myBrowser),desc='Qutebrowser'),
|
||||
|
|
@ -33,22 +34,22 @@ keys = [
|
|||
Key([mod, "shift"], "r", lazy.restart(), desc='Restart Qtile'),
|
||||
Key([mod, "shift"], "q", lazy.shutdown(), desc='Shutdown Qtile'),
|
||||
|
||||
### Switch focus of monitors
|
||||
# ## Switch focus of monitors
|
||||
Key([mod], "period", lazy.next_screen(), desc='Move focus to next monitor'),
|
||||
Key([mod], "comma", lazy.prev_screen(), desc='Move focus to prev monitor'),
|
||||
### Window controls
|
||||
# ## Window controls
|
||||
Key([mod], "Up", lazy.layout.up(), desc='Move focus up' ),
|
||||
Key([mod], "Down", lazy.layout.down(), desc='Move focus down' ),
|
||||
Key([mod], "Left", lazy.layout.left(), desc='Move focus left' ),
|
||||
Key([mod], "Right", lazy.layout.right(), desc='Move focus right' ),
|
||||
|
||||
|
||||
Key([mod, "shift"], "Up", lazy.layout.shuffle_up(), lazy.layout.section_up(),
|
||||
desc='Move windows up in current stack'),
|
||||
Key([mod, "shift"], "Down", lazy.layout.shuffle_down(), lazy.layout.section_down(),
|
||||
desc='Move windows down in current stack' ),
|
||||
Key([mod, "shift"], "Left", lazy.layout.shuffle_left(), desc='Move windows left' ),
|
||||
Key([mod, "shift"], "Right", lazy.layout.shuffle_right(), desc='Move windows right' ),
|
||||
|
||||
|
||||
Key([mod], "minus", lazy.layout.shrink(), lazy.layout.decrease_nmaster(),
|
||||
desc='Shrink window (MonadTall), decrease number in master pane (Tile)'),
|
||||
Key([mod], "equal", lazy.layout.grow(), lazy.layout.increase_nmaster(),
|
||||
|
|
@ -59,10 +60,10 @@ keys = [
|
|||
Key([mod, "control"], "Down", lazy.layout.grow_down(), desc="Grow window down"),
|
||||
Key([mod, "control"], "Left", lazy.layout.grow_left(), desc="Grow window to the left"),
|
||||
Key([mod, "control"], "Right", lazy.layout.grow_right(), desc="Grow window to the right"),
|
||||
|
||||
|
||||
Key([mod], "n", lazy.layout.normalize(), desc='normalize window size ratios'),
|
||||
Key([mod], "m", lazy.layout.maximize(), desc='toggle window between minimum and maximum sizes'),
|
||||
|
||||
|
||||
Key([mod, "shift"], "f", lazy.window.toggle_floating(), desc='toggle floating'),
|
||||
Key([mod], "f", lazy.window.toggle_fullscreen(), desc='toggle fullscreen' ),
|
||||
|
||||
|
|
@ -140,173 +141,190 @@ layouts = [
|
|||
|
||||
prompt = "{0}@{1}: ".format(os.environ["USER"], socket.gethostname())
|
||||
|
||||
##### DEFAULT WIDGET SETTINGS #####
|
||||
# #### DEFAULT WIDGET SETTINGS #####
|
||||
widget_defaults = dict(
|
||||
font="FiraCode Nerd Font Bold",
|
||||
fontsize = 11,
|
||||
padding = 0,
|
||||
fontsize=11,
|
||||
padding=0,
|
||||
background=Colors.bg
|
||||
)
|
||||
extension_defaults = widget_defaults.copy()
|
||||
|
||||
|
||||
def init_widgets_list():
|
||||
powerline = {
|
||||
"decorations": [
|
||||
PowerLineDecoration(path='back_slash')
|
||||
]
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
widgets_list = [
|
||||
# widget.Image(
|
||||
# filename = "~/.config/qtile/icons/python-white.png",
|
||||
# scale = "False",
|
||||
# mouse_callbacks = {'Button1': lambda: qtile.cmd_spawn(myTerm)}
|
||||
# ),
|
||||
# widget.Image(
|
||||
# filename = "~/.config/qtile/icons/python-white.png",
|
||||
# scale = "False",
|
||||
# mouse_callbacks = {'Button1': lambda: qtile.cmd_spawn(myTerm)}
|
||||
# ),
|
||||
widget.TextBox(
|
||||
text = u'\ue73c',
|
||||
foreground = Colors.fg,
|
||||
fontsize = 22,
|
||||
padding = 12,
|
||||
# mouse_callbacks = {'Button1': lambda: qtile.cmd_spawn(myTerm)}
|
||||
text=u'\ue73c',
|
||||
foreground=Colors.fg,
|
||||
fontsize=22,
|
||||
padding=12,
|
||||
# mouse_callbacks={'Button1': lambda: qtile.cmd_spawn(myTerm)}
|
||||
),
|
||||
widget.GroupBox(
|
||||
font = "Ubuntu Bold",
|
||||
fontsize = 9,
|
||||
margin_y = 3,
|
||||
margin_x = 0,
|
||||
padding_y = 5,
|
||||
padding_x = 3,
|
||||
borderwidth = 3,
|
||||
active = Colors.fg,
|
||||
inactive = Colors.grey,
|
||||
# rounded = False,
|
||||
highlight_color = Colors.orange,
|
||||
highlight_method = "line",
|
||||
this_current_screen_border = Colors.blue,
|
||||
other_screen_border = Colors.grey,
|
||||
this_screen_border = Colors.blue,
|
||||
other_current_screen_border = Colors.grey,
|
||||
foreground = Colors.fg,
|
||||
background = Colors.bg
|
||||
font="Ubuntu Bold",
|
||||
fontsize=9,
|
||||
margin_y=3,
|
||||
margin_x=0,
|
||||
padding_y=5,
|
||||
padding_x=3,
|
||||
borderwidth=3,
|
||||
active=Colors.fg,
|
||||
inactive=Colors.grey,
|
||||
# rounded=False,
|
||||
highlight_color=Colors.orange,
|
||||
highlight_method="line",
|
||||
this_current_screen_border=Colors.blue,
|
||||
other_screen_border=Colors.grey,
|
||||
this_screen_border=Colors.blue,
|
||||
other_current_screen_border=Colors.grey,
|
||||
foreground=Colors.fg,
|
||||
background=Colors.bg
|
||||
),
|
||||
widget.Sep(
|
||||
foreground = Colors.red,
|
||||
padding = 8
|
||||
foreground=Colors.red,
|
||||
padding=8
|
||||
),
|
||||
widget.CurrentLayoutIcon(
|
||||
# custom_icon_paths = [os.path.expanduser("~/.config/qtile/icons")],
|
||||
foreground = Colors.red,
|
||||
background = Colors.bg,
|
||||
padding = 0,
|
||||
scale = 0.7
|
||||
# custom_icon_paths=[os.path.expanduser("~/.config/qtile/icons")],
|
||||
foreground=Colors.red,
|
||||
background=Colors.bg,
|
||||
padding=0,
|
||||
scale=0.7
|
||||
),
|
||||
widget.Prompt(),
|
||||
widget.Sep(
|
||||
foreground = Colors.red,
|
||||
padding = 8
|
||||
foreground=Colors.red,
|
||||
padding=8
|
||||
),
|
||||
widget.WindowName(
|
||||
fontsize = 10,
|
||||
foreground = Colors.yellow,
|
||||
background = Colors.bg,
|
||||
padding = 0,
|
||||
fontsize=10,
|
||||
foreground=Colors.yellow,
|
||||
background=Colors.bg,
|
||||
padding=0,
|
||||
**powerline,
|
||||
),
|
||||
widget.Systray(
|
||||
background = Colors.bg1,
|
||||
padding = 5,
|
||||
background=Colors.bg1,
|
||||
padding=5,
|
||||
**powerline,
|
||||
),
|
||||
# UPowerWidget(
|
||||
# background = Colors.yellow,
|
||||
# foreground = Colors.fg,
|
||||
# **powerline,
|
||||
# ),
|
||||
widget.Battery(
|
||||
battery = 0,
|
||||
fmt = ' {}',
|
||||
charge_char = u'\uf583',
|
||||
discharge_char = u'\uf57d',
|
||||
empty_char = u'\uf582',
|
||||
full_char = u'\uf578',
|
||||
unknown_char = u'\uf590',
|
||||
format = '{char} {percent:2.0%} {hour:d}:{min:02d}',
|
||||
background = Colors.yellow,
|
||||
foreground = Colors.bg,
|
||||
UPowerWidget(
|
||||
background=Colors.yellow,
|
||||
foreground=Colors.bg,
|
||||
border_colour=Colors.bg,
|
||||
border_critical_colour=Colors.red,
|
||||
border_charge_colour=Colors.blue,
|
||||
|
||||
fill_critical=Colors.red,
|
||||
fill_low=Colors.red,
|
||||
fill_normal=Colors.bg2,
|
||||
text_charging='({percentage:.0f}%) {ttf}',
|
||||
text_discharging='({percentage:.0f}%) {tte}',
|
||||
|
||||
spacing=10,
|
||||
|
||||
**powerline,
|
||||
),
|
||||
# widget.Battery(
|
||||
# battery = 1,
|
||||
# fmt = ' {}',
|
||||
# charge_char = u'\uf583',
|
||||
# discharge_char = u'\uf57d',
|
||||
# empty_char = u'\uf582',
|
||||
# full_char = u'\uf578',
|
||||
# unknown_char = u'\uf590',
|
||||
# format = '{char} {percent:2.0%} {hour:d}:{min:02d}',
|
||||
# background = Colors.yellow,
|
||||
# foreground = Colors.bg,
|
||||
# battery=0,
|
||||
# fmt=' {}',
|
||||
# charge_char=u'\uf583',
|
||||
# discharge_char=u'\uf57d',
|
||||
# empty_char=u'\uf582',
|
||||
# full_char=u'\uf578',
|
||||
# unknown_char=u'\uf590',
|
||||
# format='{char} {percent:2.0%} {hour:d}:{min:02d}',
|
||||
# background=Colors.yellow,
|
||||
# foreground=Colors.bg,
|
||||
# **powerline,
|
||||
# ),
|
||||
# widget.Battery(
|
||||
# battery=1,
|
||||
# fmt=' {}',
|
||||
# charge_char=u'\uf583',
|
||||
# discharge_char=u'\uf57d',
|
||||
# empty_char=u'\uf582',
|
||||
# full_char=u'\uf578',
|
||||
# unknown_char=u'\uf590',
|
||||
# format='{char} {percent:2.0%} {hour:d}:{min:02d}',
|
||||
# background=Colors.yellow,
|
||||
# foreground=Colors.bg,
|
||||
# **powerline,
|
||||
# ),
|
||||
widget.ThermalSensor(
|
||||
foreground = Colors.bg,
|
||||
background = Colors.orange,
|
||||
threshold = 90,
|
||||
fmt = '\uf8c7 {}',
|
||||
foreground=Colors.bg,
|
||||
background=Colors.orange,
|
||||
threshold=90,
|
||||
fmt='\uf8c7 {}',
|
||||
**powerline,
|
||||
),
|
||||
widget.CheckUpdates(
|
||||
update_interval = 1800,
|
||||
distro = update_distro_key,
|
||||
markup = False,
|
||||
display_format = "\uf546 {updates}",
|
||||
foreground = Colors.bg,
|
||||
colour_have_updates = Colors.bg,
|
||||
colour_no_updates = Colors.bg,
|
||||
background = Colors.red,
|
||||
update_interval=1800,
|
||||
distro=update_distro_key,
|
||||
markup=False,
|
||||
display_format="\uf546 {updates}",
|
||||
foreground=Colors.bg,
|
||||
colour_have_updates=Colors.bg,
|
||||
colour_no_updates=Colors.bg,
|
||||
background=Colors.red,
|
||||
**powerline,
|
||||
),
|
||||
widget.Memory(
|
||||
foreground = Colors.bg,
|
||||
background = Colors.purple,
|
||||
mouse_callbacks = {'Button1': lambda: qtile.cmd_spawn(myTerm + ' -e htop')},
|
||||
fmt = '{}',
|
||||
format = '\uf85a{MemPercent:5.1f} %',
|
||||
foreground=Colors.bg,
|
||||
background=Colors.purple,
|
||||
mouse_callbacks={'Button1': lambda: qtile.cmd_spawn(myTerm + ' -e htop')},
|
||||
fmt='{}',
|
||||
format='\uf85a{MemPercent:5.1f} %',
|
||||
**powerline,
|
||||
),
|
||||
widget.CPU(
|
||||
foreground = Colors.bg,
|
||||
background = Colors.blue,
|
||||
fmt = '{}',
|
||||
format = '\ufb19{load_percent:5.1f}%',
|
||||
foreground=Colors.bg,
|
||||
background=Colors.blue,
|
||||
fmt='{}',
|
||||
format='\ufb19{load_percent:5.1f}%',
|
||||
**powerline,
|
||||
),
|
||||
widget.Net(
|
||||
# bash script to get the active network interface: ip
|
||||
interface = get_network_interface(),
|
||||
format = '{down} ↓↑ {up}',
|
||||
interface=get_network_interface(),
|
||||
format='{down} ↓↑ {up}',
|
||||
prefix='M',
|
||||
foreground = Colors.bg,
|
||||
background = Colors.aqua,
|
||||
foreground=Colors.bg,
|
||||
background=Colors.aqua,
|
||||
**powerline,
|
||||
),
|
||||
widget.Clock(
|
||||
foreground = Colors.bg,
|
||||
background = Colors.green,
|
||||
format = "%Y-%m-%d %a %H:%M ",
|
||||
padding = 5
|
||||
foreground=Colors.bg,
|
||||
background=Colors.green,
|
||||
format="%Y-%m-%d %a %H:%M ",
|
||||
padding=5
|
||||
),
|
||||
]
|
||||
return widgets_list
|
||||
|
||||
|
||||
def init_widgets_screen1():
|
||||
widgets_screen1 = init_widgets_list()
|
||||
del widgets_screen1[7:8] # Slicing removes unwanted widgets (systray) on Monitors 1,3
|
||||
del widgets_screen1[4:5] # Slicing removes unwanted widgets (prompt) on Monitors 1,3
|
||||
del widgets_screen1[7:8] # Slicing removes (systray) on Monitors 1,3
|
||||
del widgets_screen1[4:5] # Slicing removes (prompt) on Monitors 1,3
|
||||
return widgets_screen1
|
||||
|
||||
|
||||
def init_widgets_screen2():
|
||||
widgets_screen2 = init_widgets_list()
|
||||
return widgets_screen2 # Monitor 2 will display all widgets in widgets_list
|
||||
return widgets_screen2 # display all widgets in widgets_list
|
||||
|
||||
|
||||
def init_screens():
|
||||
num_screens = get_num_screens()
|
||||
|
|
@ -324,39 +342,46 @@ def init_screens():
|
|||
Screen(top=bar.Bar(widgets=init_widgets_screen1(), opacity=1.0, size=20)),
|
||||
]
|
||||
|
||||
|
||||
if __name__ in ["config", "__main__"]:
|
||||
screens = init_screens()
|
||||
widgets_list = init_widgets_list()
|
||||
widgets_screen1 = init_widgets_screen1()
|
||||
widgets_screen2 = init_widgets_screen2()
|
||||
|
||||
|
||||
def window_to_prev_group(qtile):
|
||||
if qtile.currentWindow is not None:
|
||||
i = qtile.groups.index(qtile.currentGroup)
|
||||
qtile.currentWindow.togroup(qtile.groups[i - 1].name)
|
||||
|
||||
|
||||
def window_to_next_group(qtile):
|
||||
if qtile.currentWindow is not None:
|
||||
i = qtile.groups.index(qtile.currentGroup)
|
||||
qtile.currentWindow.togroup(qtile.groups[i + 1].name)
|
||||
|
||||
|
||||
def window_to_previous_screen(qtile):
|
||||
i = qtile.screens.index(qtile.current_screen)
|
||||
if i != 0:
|
||||
group = qtile.screens[i - 1].group.name
|
||||
qtile.current_window.togroup(group)
|
||||
|
||||
|
||||
def window_to_next_screen(qtile):
|
||||
i = qtile.screens.index(qtile.current_screen)
|
||||
if i + 1 != len(qtile.screens):
|
||||
group = qtile.screens[i + 1].group.name
|
||||
qtile.current_window.togroup(group)
|
||||
|
||||
|
||||
def switch_screens(qtile):
|
||||
i = qtile.screens.index(qtile.current_screen)
|
||||
group = qtile.screens[i - 1].group
|
||||
qtile.current_screen.set_group(group)
|
||||
|
||||
|
||||
mouse = [
|
||||
Drag([mod], "Button1", lazy.window.set_position_floating(),
|
||||
start=lazy.window.get_position()),
|
||||
|
|
@ -375,10 +400,10 @@ floating_layout = layout.Floating(float_rules=[
|
|||
# default_float_rules include: utility, notification, toolbar, splash, dialog,
|
||||
# file_progress, confirm, download and error.
|
||||
*layout.Floating.default_float_rules,
|
||||
Match(title='Confirmation'), # tastyworks exit box
|
||||
Match(title='Qalculate!'), # qalculate-gtk
|
||||
Match(wm_class='kdenlive'), # kdenlive
|
||||
Match(wm_class='pinentry-gtk-2'), # GPG key password entry
|
||||
Match(title='Confirmation'), # tastyworks exit box
|
||||
Match(title='Qalculate!'), # qalculate-gtk
|
||||
Match(wm_class='kdenlive'), # kdenlive
|
||||
Match(wm_class='pinentry-gtk-2'), # GPG key password entry
|
||||
])
|
||||
auto_fullscreen = True
|
||||
focus_on_window_activation = "smart"
|
||||
|
|
@ -388,11 +413,14 @@ reconfigure_screens = True
|
|||
# focus, should we respect this or not?
|
||||
auto_minimize = True
|
||||
|
||||
|
||||
@hook.subscribe.startup_once
|
||||
def start_once():
|
||||
home = os.path.expanduser('~')
|
||||
subprocess.call([home + '/.config/qtile/up.sh'])
|
||||
|
||||
|
||||
wmname = "LG3D"
|
||||
# XXX: Gasp! We're lying here. In fact, nobody really uses or cares about this
|
||||
# string besides java UI toolkits; you can see several discussions on the
|
||||
# mailing lists, GitHub issues, and other WM documentation that suggest setting
|
||||
|
|
@ -401,4 +429,3 @@ def start_once():
|
|||
#
|
||||
# We choose LG3D to maximize irony: it is a 3D non-reparenting WM written in
|
||||
# java that happens to be on java's whitelist.
|
||||
wmname = "LG3D"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue