dotfiles/_desktop/qtile/config.py

232 lines
8.2 KiB
Python
Raw Normal View History

import os
2022-08-01 01:21:30 +02:00
import psutil
2022-07-30 01:02:25 +02:00
import subprocess
2022-07-29 20:23:47 +02:00
from libqtile import bar, extension, hook, layout, widget
2022-07-29 15:49:27 +02:00
from libqtile.config import Click, Drag, DropDown, Group, Key, Match, ScratchPad, Screen
from libqtile.dgroups import simple_key_binder
2022-07-29 20:23:47 +02:00
from libqtile.lazy import lazy
2022-07-29 15:49:27 +02:00
@hook.subscribe.startup_once
def autostart():
home = os.path.expanduser('~/.config/qtile/autostart.sh')
subprocess.Popen([home])
2022-07-29 15:49:27 +02:00
groups = [
Group("1", label="\uf292"),
Group("2", label="\uf738", matches=[Match(wm_class=["firefox"])]),
Group("3", label="\uf70d", matches=[Match(wm_class=["Ferdi"])]),
2022-07-29 15:49:27 +02:00
Group("4", label="\uf7aa", matches=[Match(wm_class=["mutt"])]),
Group("5", label="\uf120"),
Group("6", label="\uf120"),
2022-09-19 18:13:24 +02:00
Group("7", label="\ufce1", matches=[Match(wm_class=["1Password"])]),
2022-07-29 15:49:27 +02:00
Group("8", label="\uf9b0", matches=[Match(wm_class=["Slack"])]),
Group("9", label="\uf296"),
Group("0", label="\uf2bb", matches=[Match(wm_class=["workfx"])]),
ScratchPad("scratchpad", [
DropDown(
"spterm", "sh -c 'BROWSER=firefox st'",
on_focus_lost_hide=False,
width=0.40,
height=0.50,
2022-07-29 15:49:27 +02:00
x=0.30,
y=0.25,
),
DropDown(
"spwork", "sh -c 'BROWSER=workfx st -n work'",
on_focus_lost_hide=False,
width=0.40,
height=0.50,
2022-07-29 15:49:27 +02:00
x=0.30,
y=0.25,
),
]),
]
mod = "mod4"
keys = [
# switch between windows
Key([mod], "h", lazy.layout.left()),
Key([mod], "l", lazy.layout.right()),
Key([mod], "j", lazy.layout.down()),
Key([mod], "k", lazy.layout.up()),
# move windows
Key([mod, "control"], "h", lazy.layout.shuffle_left()),
Key([mod, "control"], "l", lazy.layout.shuffle_right()),
Key([mod, "control"], "j", lazy.layout.shuffle_down()),
Key([mod, "control"], "k", lazy.layout.shuffle_up()),
# resize windows
Key([mod, "shift"], "h", lazy.layout.grow_left()),
Key([mod, "shift"], "l", lazy.layout.grow_right()),
Key([mod, "shift"], "j", lazy.layout.grow_down()),
Key([mod, "shift"], "k", lazy.layout.grow_up()),
2022-08-05 23:07:59 +02:00
Key([mod, "shift", "control"], "0", lazy.layout.normalize()),
2022-07-29 15:49:27 +02:00
# app binds
Key([mod], "Return", lazy.spawn("sh -c 'BROWSER=firefox st'")),
Key([mod], "space", lazy.spawncmd()),
Key([mod], "a", lazy.spawn("authenticator")),
2022-07-29 15:49:27 +02:00
Key([mod], "e", lazy.group["scratchpad"].dropdown_toggle('spterm')),
Key([mod], "i", lazy.spawn("scrot -f -s 'scrot_%Y-%m-%d_%H-%M-%S_%s.png'")),
Key([mod], "m", lazy.spawn("sh -c 'pgrep -x neomutt > /dev/null || BROWSER=firefox st -n mutt -e neomutt'")),
Key([mod, "shift"], "e", lazy.group["scratchpad"].dropdown_toggle('spwork')),
Key([mod, "shift"], "i", lazy.spawn("scrot -f 'scrot_%Y-%m-%d_%H-%M-%S_%s.png'")),
Key([mod, "shift"], "Return", lazy.spawn("sh -c 'BROWSER=workfx st -n work'")),
Key([mod, "control"], "a", lazy.spawn("dmenu-audio")),
Key([mod, "control"], "b", lazy.spawn("dmenu-bluetooth")),
Key([mod, "control"], "e", lazy.spawn("dmenu-emoji")),
Key([mod, "control"], "d", lazy.spawn("dmenu-display")),
# WM control
Key([mod], "f", lazy.window.toggle_floating()),
2022-07-29 15:49:27 +02:00
Key([mod], "q", lazy.window.kill()),
2022-10-12 17:21:51 +02:00
Key([mod, "control", "shift"], "l", lazy.spawn("physlock")),
2022-07-29 15:49:27 +02:00
Key([mod, "control", "shift"], "q", lazy.shutdown()),
Key([mod, "control", "shift"], "r", lazy.reload_config()),
# media keys
Key([], "XF86AudioMute", lazy.spawn("pactl set-sink-mute @DEFAULT_SINK@ toggle")),
2022-07-29 15:54:24 +02:00
Key([], "XF86AudioMicMute", lazy.spawn("key-micmute")),
2022-09-26 19:59:29 +02:00
Key([], "XF86AudioRaiseVolume", lazy.spawn("sb-volume inc")),
Key([], "XF86AudioLowerVolume", lazy.spawn("sb-volume dec")),
2022-07-29 15:49:27 +02:00
Key([], "XF86MonBrightnessUp", lazy.spawn("xbacklight -inc 10")),
Key([], "XF86MonBrightnessDown", lazy.spawn("xbacklight -dec 10")),
]
dgroups_key_binder = simple_key_binder(mod)
dgroups_app_rules = [] # type: list
layouts = [
layout.Columns(
border_focus='#ffffff',
2022-10-30 13:53:34 +01:00
border_normal='#0f1419',
border_on_single = False,
2022-07-29 15:49:27 +02:00
border_width=2,
insert_position=1,
margin=[5, 5, 5, 5]
),
]
widget_defaults = dict(
2022-10-30 13:53:34 +01:00
background='#0f1419',
foreground='#e6e1cf',
font="RobotoMono Nerd Font Medium",
2022-10-30 13:53:34 +01:00
fontsize=14,
2022-07-29 15:49:27 +02:00
)
extension_defaults = widget_defaults.copy()
2022-11-07 13:49:33 +01:00
def yubikey_replace(text):
return text.replace('YubiKey is waiting for a touch', '\uf80a')
2022-07-29 15:49:27 +02:00
screens = [
Screen(
top=bar.Bar(
[
widget.GroupBox(
disable_drag=True,
2022-11-06 00:01:52 +01:00
highlight_method='block',
2022-07-29 15:49:27 +02:00
rounded=False,
2022-11-06 00:01:52 +01:00
this_current_screen_border='#005577',
2022-10-30 13:53:34 +01:00
urgent_alert_method='block',
2022-11-06 00:01:52 +01:00
urgent_border='#770000',
2022-07-29 15:49:27 +02:00
),
widget.Prompt(
prompt='open: ',
record_history=False,
),
widget.Spacer(),
widget.Notify(
background='#e8b923',
background_low='#0f1419',
background_urgent='#770000',
foreground='#000000',
foreground_low='#e6e1cf',
foreground_urgent='#ffffff',
font='RobotoMono Nerd Font Bold',
2022-11-07 13:49:33 +01:00
parse_text=yubikey_replace,
),
widget.GenPollCommand(
2022-11-06 00:01:52 +01:00
background='#005577',
2022-11-06 11:24:42 +01:00
foreground='#ffffff',
2022-08-23 00:19:44 +02:00
update_interval=1,
cmd="sb-mail",
2022-07-29 15:49:27 +02:00
),
widget.GenPollCommand(
2022-11-06 00:01:52 +01:00
background='#770000',
2022-11-06 11:24:42 +01:00
foreground='#ffffff',
2022-08-23 00:19:44 +02:00
update_interval=1,
cmd="sb-network",
2022-07-29 15:49:27 +02:00
),
widget.GenPollCommand(
2022-11-06 00:01:52 +01:00
background='#770000',
2022-11-06 11:24:42 +01:00
foreground='#ffffff',
update_interval=1,
cmd="sb-volume",
),
2022-12-17 00:30:08 +01:00
widget.Battery(
format='{char} {percent:2.0%}',
charge_char='\uf077',
discharge_char='\uf078',
unknown_char='\uf444',
full_char='\uf102',
2022-08-23 00:19:44 +02:00
update_interval=1,
2022-12-17 00:30:08 +01:00
low_background='#770000',
low_foreground='#ffffff',
low_percentage=0.2,
2022-07-29 15:49:27 +02:00
),
widget.Clock(
2022-11-07 13:49:33 +01:00
format='[%d] %H:%M:%S',
2022-07-29 15:49:27 +02:00
),
widget.Systray(),
2022-07-29 15:49:27 +02:00
],
24,
2022-11-06 13:32:50 +01:00
margin=[5, 5, 0, 5]
2022-07-29 15:49:27 +02:00
),
2022-11-08 17:43:49 +01:00
wallpaper='~/.local/share/wallpaper.jpg',
wallpaper_mode='fill',
2022-07-29 15:49:27 +02:00
),
]
mouse = [
Drag([mod], "Button1", lazy.window.set_position_floating(), start=lazy.window.get_position()),
Drag([mod], "Button3", lazy.window.set_size_floating(), start=lazy.window.get_size()),
Click([mod], "Button2", lazy.window.bring_to_front()),
]
floating_layout = layout.Floating(
float_rules=[
*layout.Floating.default_float_rules,
Match(wm_class='Authenticator'),
2022-07-29 15:49:27 +02:00
],
border_focus='#ffffff',
border_normal="#272822",
border_width=2,
)
2022-08-01 01:21:30 +02:00
@hook.subscribe.client_new
def _swallow(window):
pid = window.window.get_net_wm_pid()
ppid = psutil.Process(pid).ppid()
cpids = {c.window.get_net_wm_pid(): wid for wid, c in window.qtile.windows_map.items()}
for i in range(5):
if not ppid:
return
if ppid in cpids:
parent = window.qtile.windows_map.get(cpids[ppid])
if parent.window.get_wm_class()[0] != "xterm-256color":
return
parent.minimized = True
window.parent = parent
return
ppid = psutil.Process(ppid).ppid()
2022-07-29 20:23:47 +02:00
2022-08-01 01:21:30 +02:00
@hook.subscribe.client_killed
def _unswallow(window):
if hasattr(window, 'parent'):
window.parent.minimized = False
2022-07-29 20:23:47 +02:00
2022-07-29 15:49:27 +02:00
auto_fullscreen = True
auto_minimize = True
bring_front_click = False
cursor_warp = False
focus_on_window_activation = "smart"
follow_mouse_focus = True
reconfigure_screens = True
wmname = "LG3D"