dotfiles/_desktop/qtile/config.py

235 lines
8.6 KiB
Python
Raw Normal View History

import os
2022-07-30 01:02:25 +02:00
import subprocess
2023-02-09 23:16:17 +01:00
from libqtile import bar, extension, hook, layout
2023-02-21 11:52:58 +01:00
from libqtile.lazy import lazy
2023-02-09 23:16:17 +01:00
from libqtile.config import Click, Drag, DropDown, Group, Key, Match, ScratchPad, Screen
from libqtile.backend.wayland import InputConfig
from qtile_extras import widget
wl_input_rules = {
"type:pointer": InputConfig(natural_scroll=True),
"type:touchpad": InputConfig(tap=True,natural_scroll=True),
"type:keyboard": InputConfig(kb_layout="pl",kb_repeat_delay=280,kb_repeat_rate=30),
}
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])
2023-02-09 23:16:17 +01:00
mod = "mod4"
2022-07-29 15:49:27 +02:00
groups = [
Group("1", label="\uf292"),
2023-02-25 12:18:45 +01:00
Group("2", label="\uf738", matches=[Match(wm_class=["firefox"])]),
2023-02-09 23:16:17 +01:00
Group("3", label="\uf70d", matches=[Match(wm_class=["ferdium", "discord", "Signal"])]),
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"),
2023-03-01 14:53:05 +01:00
Group("7", label="\uf09c", matches=[Match(wm_class=["1Password"])]),
2023-03-01 14:26:05 +01:00
Group("8", label="\uf198", matches=[Match(wm_class=["Slack"])]),
2022-07-29 15:49:27 +02:00
Group("9", label="\uf296"),
Group("0", label="\uf2bb", matches=[Match(wm_class=["workfx"])]),
ScratchPad("scratchpad", [
DropDown(
2023-02-23 13:09:11 +01:00
"spterm", "footclient",
2022-07-29 15:49:27 +02:00
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(
2023-02-09 23:16:17 +01:00
"spwork", "sh -c 'terminal_profile=work foot -o url.launch=workfx\ \${url}'",
2022-07-29 15:49:27 +02:00
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,
),
]),
]
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()),
2023-03-05 19:38:14 +01:00
Key([mod], "Left", lazy.layout.left()),
Key([mod], "Right", lazy.layout.right()),
Key([mod], "Down", lazy.layout.down()),
Key([mod], "Up", lazy.layout.up()),
2022-07-29 15:49:27 +02:00
# 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
2023-02-23 13:09:11 +01:00
Key([mod], "Return", lazy.spawn("footclient")),
2022-07-29 15:49:27 +02:00
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')),
2023-02-09 23:16:17 +01:00
Key([mod], "i", lazy.spawn("sh -c 'grim -g \"$(slurp)\"'")),
2023-02-23 13:09:11 +01:00
Key([mod], "m", lazy.spawn("sh -c 'pgrep -x neomutt > /dev/null || footclient -a mutt -o bold-text-in-bright=yes neomutt'")),
2022-07-29 15:49:27 +02:00
Key([mod, "shift"], "e", lazy.group["scratchpad"].dropdown_toggle('spwork')),
2023-02-09 23:16:17 +01:00
Key([mod, "shift"], "i", lazy.spawn("grim")),
Key([mod, "shift"], "Return", lazy.spawn("sh -c 'terminal_profile=work foot -o url.launch=workfx\ \${url}'")),
2023-02-22 16:19:33 +01:00
Key([mod, "control"], "a", lazy.spawn("selector-audio")),
Key([mod, "control"], "b", lazy.spawn("selector-bluetooth")),
Key([mod, "control"], "e", lazy.spawn("selector-chars")),
2022-07-29 15:49:27 +02:00
# 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()),
2023-02-09 23:16:17 +01:00
Key([mod], "r", lazy.reload_config()),
2022-07-29 15:49:27 +02:00
# media keys
Key([], "XF86AudioMute", lazy.spawn("pactl set-sink-mute @DEFAULT_SINK@ toggle")),
Key([], "XF86AudioMicMute", lazy.spawn("sb-volume key")),
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")),
]
2023-02-09 23:16:17 +01:00
for i in groups[:10]:
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),
),
# Key( [mod, "shift"], i.name, lazy.window.togroup(i.name, switch_group=True),
# desc="Switch to & move focused window to group {}".format(i.name),
# ),
Key([mod, "shift"], i.name, lazy.window.togroup(i.name),
desc="move focused window to group {}".format(i.name)
),
]
)
2022-07-29 15:49:27 +02:00
layouts = [
layout.Columns(
2023-01-27 17:21:48 +01:00
border_focus='#0094d8',
2023-01-27 17:04:59 +01:00
border_normal="#272822",
border_on_single = False,
2023-01-27 17:04:59 +01:00
border_width=5,
2022-07-29 15:49:27 +02:00
insert_position=1,
margin=[5, 5, 5, 5]
),
]
widget_defaults = dict(
2023-03-01 14:11:34 +01:00
background='#272822cc',
font="RobotoMono Nerd Font Medium",
2023-03-01 15:38:06 +01:00
fontsize=14,
2023-03-09 00:09:32 +01:00
foreground='#feffff',
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):
2023-01-30 11:55:21 +01:00
return text.replace('YubiKey is waiting for a touch', 'Touch the Yubikey')
2022-11-07 13:49:33 +01:00
2022-07-29 15:49:27 +02:00
screens = [
Screen(
top=bar.Bar(
[
widget.GroupBox(
2023-02-09 01:42:43 +01:00
active='#feffff',
2022-07-29 15:49:27 +02:00
disable_drag=True,
2023-03-05 19:30:29 +01:00
fontsize=18,
2022-11-06 00:01:52 +01:00
highlight_method='block',
2022-07-29 15:49:27 +02:00
rounded=False,
2023-02-09 01:36:36 +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(
2023-02-09 23:16:17 +01:00
bell_style=None,
2022-07-29 15:49:27 +02:00
prompt='open: ',
record_history=False,
),
widget.Spacer(),
widget.Notify(
background='#e8b923',
2023-01-31 22:14:25 +01:00
background_low='#272822',
background_urgent='#770000',
foreground='#000000',
2023-02-09 01:42:43 +01:00
foreground_low='#c7c7c7',
foreground_urgent='#feffff',
font='RobotoMono Nerd Font Bold',
2022-11-07 13:49:33 +01:00
parse_text=yubikey_replace,
),
widget.GenPollCommand(
2023-02-09 01:36:36 +01:00
background='#005577',
2023-02-09 01:42:43 +01:00
foreground='#feffff',
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',
2023-02-09 01:42:43 +01:00
foreground='#feffff',
update_interval=1,
cmd="sb-volume",
),
2023-02-09 01:23:49 +01:00
widget.GenPollCommand(
background='#770000',
2023-02-09 01:42:43 +01:00
foreground='#feffff',
2023-02-09 01:23:49 +01:00
update_interval=1,
cmd="sb-network",
2022-12-17 00:47:11 +01:00
),
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',
2023-02-09 01:42:43 +01:00
low_foreground='#feffff',
2022-12-17 00:30:08 +01:00
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
),
2023-02-09 23:16:17 +01:00
widget.StatusNotifier(
icon_size=18,
),
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
),
2023-02-09 23:16:17 +01:00
wallpaper=os.environ['XDG_CONFIG_HOME'] + '/qtile/wallpaper.img',
2022-11-08 17:43:49 +01:00
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,
2023-02-09 23:16:17 +01:00
Match(wm_class='authenticator'),
2023-03-01 21:56:03 +01:00
Match(title="File Upload"),
2023-02-09 23:16:17 +01:00
Match(title="Open File"),
Match(title="Open file"),
Match(title="Open Files"),
Match(title="Firefox — Sharing Indicator"),
2022-07-29 15:49:27 +02:00
],
2023-02-09 23:16:17 +01:00
border_focus='#005577',
2022-07-29 15:49:27 +02:00
border_normal="#272822",
2023-02-09 23:16:17 +01:00
border_width=5,
2022-07-29 15:49:27 +02:00
)