Clean up qtile config

main
felixm 2023-06-13 09:50:56 -04:00
parent 5c0a89f7a2
commit 7dd7de3b27
6 changed files with 225 additions and 231 deletions

View File

@ -1,8 +0,0 @@
#!/bin/bash
# Starting compton compositor on startup for transparency
# If transparency is not working, try with vsync
picom &
feh --bg-center /home/felixm/.config/awesome/wallpaper.png &

30
config/qtile/colors.py Normal file
View File

@ -0,0 +1,30 @@
ROSEWATER = "#f2d5cf"
FLAMINGO = "#eebebe"
PINK = "#f4b8e4"
MAUVE = "#ca9ee6"
RED = "#e78284"
MAROON = "#ea999c"
PEACH = "#ef9f76"
YELLOW = "#e5c890"
GREEN = "#a6d189"
TEAL = "#81c8be"
SKY = "#99d1db"
SAPPHIRE = "#85c1dc"
BLUE = "#8caaee"
LAVENDER = "#babbf1"
TEXT = "#c6d0f5"
SUBTEXT1 = "#b5bfe2"
SUBTEXT0 = "#a5adce"
OVERLAY2 = "#949cbb"
OVERLAY1 = "#838ba7"
OVERLAY0 = "#737994"
SURFACE2 = "#626880"
SURFACE1 = "#51576d"
SURFACE0 = "#414559"
BASE = "#303446"
MANTLE = "#292c3c"
CRUST = "#232634"
MINESHAFT = "#222222"
INDOCHINE = "#c57804"
JUDGEGRAY = "#544735"
OLDCOPPER = "#6f572d"

View File

@ -1,31 +1,3 @@
# Copyright (c) 2010 Aldo Cortesi
# Copyright (c) 2010, 2014 dequis
# Copyright (c) 2012 Randall Ma
# Copyright (c) 2012-2014 Tycho Andersen
# Copyright (c) 2012 Craig Barnes
# Copyright (c) 2013 horsik
# Copyright (c) 2013 Tao Sauvage
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import subprocess
import re
from pathlib import Path
from libqtile import bar, layout
from libqtile.config import Click, Drag, Group, Key, Match, Screen, EzKey, KeyChord
@ -34,7 +6,9 @@ from libqtile.utils import guess_terminal
from libqtile.log_utils import logger
from libqtile import qtile
from qtile_extras import widget
from qtile_extras.widget.decorations import RectDecoration
from colors import *
import utils
import widgets
mod = "mod4"
@ -42,97 +16,50 @@ terminal = "kitty"
this_file = str(Path(__file__).resolve())
ROSEWATER = "#f2d5cf"
FLAMINGO = "#eebebe"
PINK = "#f4b8e4"
MAUVE = "#ca9ee6"
RED = "#e78284"
MAROON = "#ea999c"
PEACH = "#ef9f76"
YELLOW = "#e5c890"
GREEN = "#a6d189"
TEAL = "#81c8be"
SKY = "#99d1db"
SAPPHIRE = "#85c1dc"
BLUE = "#8caaee"
LAVENDER = "#babbf1"
TEXT = "#c6d0f5"
SUBTEXT1 = "#b5bfe2"
SUBTEXT0 = "#a5adce"
OVERLAY2 = "#949cbb"
OVERLAY1 = "#838ba7"
OVERLAY0 = "#737994"
SURFACE2 = "#626880"
SURFACE1 = "#51576d"
SURFACE0 = "#414559"
BASE = "#303446"
MANTLE = "#292c3c"
CRUST = "#232634"
MINESHAFT = "#222222"
INDOCHINE = "#c57804"
JUDGEGRAY = "#544735"
OLDCOPPER = "#6f572d"
@lazy.function
def my_left(qtile):
layout = qtile.current_layout.info()
if layout['name'] == 'columns' and layout['current'] != 0:
qtile.current_layout.cmd_left()
else:
qtile.current_screen.cmd_prev_group(skip_managed=True)
@lazy.function
def my_right(qtile):
layout = qtile.current_layout.info()
if layout['name'] == 'columns' and len(layout['columns']) - 1 != layout['current']:
qtile.current_layout.cmd_right()
else:
qtile.current_screen.cmd_next_group(skip_managed=True)
keys = [
# Switch between screens.
Key([mod], "u", lazy.prev_screen(), desc="Move focus to prev screen"),
Key([mod], "i", lazy.next_screen(), desc="Move focus to next screen"),
# Switch between windows
Key([mod], "h", my_left(), desc="Move focus to left"),
Key([mod], "l", my_right(), desc="Move focus to right"),
# Switch between windows.
Key([mod], "h", utils.layout_left(), desc="Move focus to left"),
Key([mod], "l", utils.layout_right(), desc="Move focus to right"),
Key([mod], "j", lazy.layout.down(), desc="Move focus down"),
Key([mod], "k", lazy.layout.up(), desc="Move focus up"),
Key([mod], "space", lazy.layout.next(), desc="Move window focus to other window"),
# Move windows between left/right columns or move up/down in current stack.
Key([mod, "shift"], "h", lazy.layout.shuffle_left(), desc="Move window to the left"),
Key([mod, "shift"], "l", lazy.layout.shuffle_right(), desc="Move window to the right"),
Key([mod, "shift"], "j", lazy.layout.shuffle_down(), desc="Move window down"),
Key([mod, "shift"], "k", lazy.layout.shuffle_up(), desc="Move window up"),
# Grow windows. If current window is on the edge of screen and direction
# will be to screen edge - window would shrink.
# Grow windows.
Key([mod, "control"], "h", lazy.layout.grow_left(), desc="Grow window to the left"),
Key([mod, "control"], "l", lazy.layout.grow_right(), desc="Grow window to the right"),
Key([mod, "control"], "j", lazy.layout.grow_down(), desc="Grow window down"),
Key([mod, "control"], "k", lazy.layout.grow_up(), desc="Grow window up"),
Key([mod], "f", lazy.window.toggle_floating(), desc="Toggle window floating"),
Key([mod], "m", lazy.window.toggle_minimize(), desc="Toggle window minimize"),
# Toggle between split and unsplit sides of stack.
# Split = all windows displayed
# Unsplit = 1 window displayed, like Max layout, but still with
# multiple stack panes
Key(
[mod, "shift"],
"Return",
lazy.layout.toggle_split(),
desc="Toggle between split and unsplit sides of stack",
),
# Misc commands
Key([mod], "semicolon", lazy.spawn(terminal), desc="Launch terminal"),
# Toggle between different layouts as defined below
Key([mod], "Tab", lazy.next_layout(), desc="Toggle between layouts"),
Key([mod], "w", lazy.window.kill(), desc="Kill focused window"),
Key([mod], "p", lazy.spawn("rofi -show combi"), desc="Launch rofi prompt"),
Key([], "Print", lazy.spawn("flameshot gui"), desc="Launch screenshot app"),
]
# Use Key
# Chord for different high level commands
qtile_chord = '(e)dit, (k)ill, (l)ock, (n)orm, (q)uit, (r)elaod, (s)pawn, (u)npause'
escape_chord_keys = [EzKey(key, lazy.ungrab_chord()) for key in ['C-c', '<BackSpace>']]
keys.append(
@ -149,51 +76,20 @@ keys.append(
], name=qtile_chord)
)
groups = [Group(i) for i in "123456789"]
for i in groups:
keys.extend(
[
# mod1 + letter of group = switch to group
Key(
[mod],
i.name,
lazy.group[i.name].toscreen(),
desc="Switch to group {}".format(i.name),
),
# mod1 + shift + letter of group = switch to & move focused window to group
# Key(
# [mod, "shift"],
# i.name,
# lazy.window.togroup(i.name, switch_group=True),
# desc="Switch to & move focused window to group {}".format(i.name),
# ),
# Or, use below if you prefer not to switch to that group.
# # mod1 + shift + letter of group = move focused window to group
Key([mod, "shift"], i.name, lazy.window.togroup(i.name),
desc="move focused window to group {}".format(i.name)),
]
)
# mod1 + letter of group = switch to group
k = Key([mod], i.name, lazy.group[i.name].toscreen(), desc=f"Switch to group {i.name}")
keys.append(k)
layouts = [
layout.Columns(border_focus=TEXT,
border_normal=BASE,
border_normal_stacked=BASE,
border_focus_stack=[SAPPHIRE, SKY],
border_normal_stack=BASE,
border_width=1, margin=3),
layout.Max(),
# Try more layouts by unleashing below layouts.
# layout.Stack(num_stacks=2),
# layout.Bsp(),
# layout.Matrix(),
# layout.MonadTall(),
# layout.MonadWide(),
# layout.RatioTile(),
# layout.Tile(),
# layout.TreeTab(),
# layout.VerticalTile(),
# layout.Zoomy(),
]
# mod1 + shift + letter of group = move focused window to group
k = Key([mod, "shift"], i.name, lazy.window.togroup(i.name), desc=f"Move focused window to group {i.name}")
keys.append(k)
# Use `lazy.window.togroup(i.name, switch_group=True)` to switch with move.
layouts = utils.get_layouts()
widget_defaults = dict(
font="sans",
@ -201,109 +97,37 @@ widget_defaults = dict(
padding=1,
)
extension_defaults = widget_defaults.copy()
decor = {
"decorations": [
RectDecoration(colour=BASE, radius=4, filled=True, group=True)
],
"padding": 4,
}
decor2 = {
"decorations": [
RectDecoration(colour=SURFACE0, radius=4, filled=True, group=True)
],
"padding": 4,
}
def antidrift_status():
try:
result = subprocess.check_output(['antidrift', '--status'], universal_newlines=True)
return result.strip()
except subprocess.CalledProcessError as e:
print(f"Error executing command: {e}")
return None
def parse_text(text: str) -> str:
SEPARATOR = '**YQZ**'
SELECTED = '**JKL**'
PANGO_MARKUP_PATTERN = r'<(/?[^>]+)>'
titles = text.split(SEPARATOR)
selected_index = -1
for (i, t) in enumerate(titles):
if t.startswith(SELECTED) and t.endswith(SELECTED):
selected_index = i
titles[i] = titles[i].replace(SELECTED, '')
titles[i] = re.sub(PANGO_MARKUP_PATTERN, '', titles[i])
SEPARATOR = ' | '
length_per_title = 90 // len(titles)
for i in range(len(titles)):
titles[i] = titles[i].replace("— Mozilla Firefox", "")
titles[i] = titles[i][:length_per_title]
if selected_index != -1:
titles[selected_index] = f'<span foreground="{TEXT}">{titles[selected_index]}</span>'
text = ' | '.join(titles)
return text
screens = [
Screen(
top=bar.Bar(
[
# widget.CurrentLayout(),
widget.CurrentLayoutIcon(scale=0.55, **decor),
widget.GroupBox(
rounded=True,
active = TEXT, # Active group font colour
background = None, # Widget background color
block_highlight_text_color = SURFACE1, # Selected group font colour
borderwidth = 0, # Current group border width
disable_drag = True, # Disable dragging and dropping of group names on widget
highlight_method = 'block', # Method of highlighting ('border', 'block', 'text', or 'line')
inactive = SURFACE1, # Inactive group font colour
this_screen_border = SURFACE0,
this_current_screen_border = TEXT, # Border or line colour for group on this screen when focused
other_current_screen_border = TEXT,
other_screen_border = SURFACE0,
urgent_border = RED, # Urgent border or line color
urgent_text = TEXT, # Urgent group font color
use_mouse_wheel = False, # Whether to use mouse wheel events
**decor,
),
widget.Prompt(**decor),
widget.CurrentLayoutIcon(scale=0.55, **widgets.decor),
widgets.group_box(),
widget.Prompt(**widgets.decor),
widget.Spacer(length=4),
widget.Chord(foreground=TEXT, **decor),
widget.Chord(foreground=TEXT, **widgets.decor),
widget.Spacer(length=bar.STRETCH),
widget.WindowTabs(markup=True,
separator='**YQZ**',
foreground=SURFACE1,
selected = ('**JKL**', '**JKL**'),
parse_text=parse_text,
**decor2
),
widgets.window_tabs(),
widget.Spacer(length=bar.STRETCH),
widget.GenPollText(func=antidrift_status,
update_interval=20,
foreground=TEXT,
**decor),
widget.Spacer(length=4),
widget.Clock(format="%a %m/%d %H:%M", foreground=TEXT, **decor),
widgets.antidrift_status(),
widget.Clock(format="%a %m/%d %H:%M", foreground=TEXT, **widgets.decor),
widget.Spacer(length=4),
widget.Battery(format='{char} {percent:2.0%} {hour:d}:{min:02d}',
low_foreground=RED,
foreground=TEXT,
**decor),
**widgets.decor),
widget.Backlight(backlight_name='intel_backlight',
change_command='brightnessctl s {0}',
foreground=TEXT,
**decor),
**widgets.decor),
widget.CheckUpdates(distro='Arch_checkupdates',
colour_have_updates=RED,
colour_now_updates=TEXT,
**decor),
**widgets.decor),
widget.Spacer(length=4),
widget.Systray()
],
@ -311,8 +135,20 @@ screens = [
border_width=2,
background="#00000000",
border_color="#00000000",
# border_width=[2, 0, 2, 0], # Draw top and bottom borders
# border_color=["ff00ff", "000000", "ff00ff", "000000"] # Borders are magenta
),
),
Screen(
top=bar.Bar(
[
widget.Spacer(length=550),
widget.CurrentLayoutIcon(scale=0.55, **decor2),
widgets.window_tabs(),
widget.Spacer(),
],
24,
border_width=2,
background="#00000000",
border_color="#00000000",
),
),
]
@ -324,6 +160,7 @@ mouse = [
Click([mod], "Button2", lazy.window.bring_to_front()),
]
dgroups_key_binder = None
dgroups_app_rules = [] # type: list
follow_mouse_focus = True
@ -352,12 +189,4 @@ auto_minimize = True
# When using the Wayland backend, this can be used to configure input devices.
wl_input_rules = None
# 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
# this string if your java app doesn't work correctly. We may as well just lie
# and say that we're a working one by default.
#
# 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"

47
config/qtile/utils.py Normal file
View File

@ -0,0 +1,47 @@
from libqtile import layout
from libqtile.lazy import lazy
from colors import *
@lazy.function
def layout_left(qtile):
layout = qtile.current_layout.info()
if layout["name"] == "columns" and layout["current"] != 0:
qtile.current_layout.cmd_left()
else:
qtile.current_screen.cmd_prev_group(skip_managed=True)
@lazy.function
def layout_right(qtile):
layout = qtile.current_layout.info()
if layout["name"] == "columns" and len(layout["columns"]) - 1 != layout["current"]:
qtile.current_layout.cmd_right()
else:
qtile.current_screen.cmd_next_group(skip_managed=True)
def get_layouts():
return [
layout.Columns(
border_focus=TEXT,
border_normal=BASE,
border_normal_stacked=BASE,
border_focus_stack=[SAPPHIRE, SKY],
border_normal_stack=BASE,
border_width=1,
margin=3,
),
layout.Max(),
# Try more layouts by unleashing below layouts.
# layout.Stack(num_stacks=2),
# layout.Bsp(),
# layout.Matrix(),
# layout.MonadTall(),
# layout.MonadWide(),
# layout.RatioTile(),
# layout.Tile(),
# layout.TreeTab(),
# layout.VerticalTile(),
# layout.Zoomy(),
]

View File

Before

Width:  |  Height:  |  Size: 354 KiB

After

Width:  |  Height:  |  Size: 354 KiB

96
config/qtile/widgets.py Normal file
View File

@ -0,0 +1,96 @@
import re
import subprocess
from colors import *
from qtile_extras import widget
from qtile_extras.widget.decorations import RectDecoration
decor = {
"decorations": [RectDecoration(colour=BASE, radius=4, filled=True, group=True)],
"padding": 4,
}
def window_tabs():
SEPARATOR = "**YQZ**"
SELECTED = "**JKL**"
def parse_text(text: str) -> str:
PANGO_MARKUP_PATTERN = r"<(/?[^>]+)>"
titles = text.split(SEPARATOR)
selected_index = -1
for i, t in enumerate(titles):
# Find selected title and store index
if t.startswith(SELECTED) and t.endswith(SELECTED):
selected_index = i
titles[i] = titles[i].replace(SELECTED, "")
# Remove HTML to avoid issue with Pango markup rendering
titles[i] = re.sub(PANGO_MARKUP_PATTERN, "", titles[i])
# Trim length of titles
length_per_title = 90 // len(titles)
for i in range(len(titles)):
titles[i] = titles[i].replace("— Mozilla Firefox", "")
titles[i] = titles[i][:length_per_title]
# Show selected text with color 'colors.TEXT'
if selected_index != -1:
titles[
selected_index
] = f'<span foreground="{TEXT}">{titles[selected_index]}</span>'
text = " | ".join(titles)
return text
decor = {
"decorations": [
RectDecoration(colour=SURFACE0, radius=4, filled=True, group=True)
],
"padding": 4,
}
return widget.WindowTabs(
markup=True,
separator=SEPARATOR,
foreground=SURFACE1,
selected=(SELECTED, SELECTED),
parse_text=parse_text,
**decor,
)
def group_box():
return widget.GroupBox(
rounded=True,
active=TEXT, # Active group font colour
background=None, # Widget background color
block_highlight_text_color=SURFACE1, # Selected group font colour
borderwidth=0, # Current group border width
disable_drag=True, # Disable dragging and dropping of group names on widget
highlight_method="block", # Method of highlighting ('border', 'block', 'text', or 'line')
inactive=SURFACE1, # Inactive group font colour
this_screen_border=SURFACE0,
this_current_screen_border=TEXT, # Border or line colour for group on this screen when focused
other_current_screen_border=TEXT,
other_screen_border=SURFACE0,
urgent_border=RED, # Urgent border or line color
urgent_text=TEXT, # Urgent group font color
use_mouse_wheel=False, # Whether to use mouse wheel events
**decor,
)
def antidrift_status():
def status():
try:
result = subprocess.check_output(
["antidrift", "--status"], universal_newlines=True
)
return result.strip()
except subprocess.CalledProcessError as e:
print(f"Error executing command: {e}")
return None
return widget.GenPollText(func=status, update_interval=20, foreground=TEXT, **decor)