Massive change to qtile - move own config to custom.py outside of this repository.

This commit is contained in:
Bartek Stalewski 2023-11-15 15:38:23 +01:00
parent 13137b58c1
commit 58cab7f3a0
4 changed files with 166 additions and 158 deletions

4
.gitignore vendored
View File

@ -1,6 +1,8 @@
**/autostart.sh
**/stop.sh **/stop.sh
**/bookmarks **/bookmarks
**/lazy-lock.json **/lazy-lock.json
**/.netrwhist **/.netrwhist
**/__pycache__ **/__pycache__
**/qtile/custom.py
**/qtile/autostart.sh
**/qtile/autostop.sh

View File

@ -0,0 +1,10 @@
import os
import subprocess
from libqtile import bar, extension, hook, layout, qtile
from libqtile.backend.wayland import InputConfig
from libqtile.config import Click, Drag, Group, Key, KeyChord, Match, Screen
from libqtile.lazy import lazy
from libqtile.utils import guess_terminal
from qtile_extras import widget
mod = "mod4"

View File

@ -1,46 +1,128 @@
import os from common import *
import subprocess
from libqtile import bar, extension, hook, layout, qtile
from libqtile.lazy import lazy
from libqtile.config import Click, Drag, Group, Key, Match, Screen
from libqtile.backend.wayland import InputConfig
from qtile_extras import widget
os.environ["MOZ_ENABLE_WAYLAND"] = "1" os.environ["MOZ_ENABLE_WAYLAND"] = "1"
os.environ["MOZ_DBUS_REMOTE"] = "1" os.environ["MOZ_DBUS_REMOTE"] = "1"
os.environ["XDG_CURRENT_DESKTOP"] = "qtile:wlroots" os.environ["XDG_CURRENT_DESKTOP"] = "qtile:wlroots"
wl_input_rules = { widget_defaults = dict(
"type:pointer": InputConfig(natural_scroll=True), background='#272822',
"type:touchpad": InputConfig(tap=True,natural_scroll=True), font='Roboto Mono Medium',
"type:keyboard": InputConfig(kb_layout="pl",kb_repeat_delay=280,kb_repeat_rate=30), fontsize=14,
} foreground='#feffff',
)
extension_defaults = widget_defaults.copy()
# see examples/custom.py for example custom file
custom_file=os.environ['XDG_CONFIG_HOME'] + '/qtile/custom.py'
if os.path.exists(custom_file):
from custom import groups, keys, screens, wl_input_rules
else:
terminal = guess_terminal()
keys = [
# app binds
Key([mod], "Return", lazy.spawn(terminal)),
Key([mod], "space", lazy.spawncmd()),
Key([mod], "e", lazy.spawn("selector-chars")),
Key([mod, "control"], "a", lazy.spawn("selector-audio")),
Key([mod, "control"], "b", lazy.spawn("selector-bluetooth")),
# media keys
Key([], "XF86AudioMute", lazy.spawn("pactl set-sink-mute @DEFAULT_SINK@ toggle")),
Key([], "XF86AudioMicMute", lazy.spawn("sb-volume micmute")),
Key([], "XF86AudioRaiseVolume", lazy.spawn("sb-volume inc")),
Key([], "XF86AudioLowerVolume", lazy.spawn("sb-volume dec")),
Key([], "XF86MonBrightnessUp", lazy.spawn("doas xbacklight -inc 10")),
Key([], "XF86MonBrightnessDown", lazy.spawn("doas xbacklight -dec 10")),
]
groups = [
Group("1", label="1"),
Group("2", label="2"),
Group("3", label="3"),
Group("4", label="4"),
Group("5", label="5"),
Group("6", label="6"),
Group("7", label="7"),
Group("8", label="8"),
Group("9", label="9"),
Group("0", label="10"),
]
screens = [
Screen(
top=bar.Bar(
[
widget.GroupBox(
active='#feffff',
disable_drag=True,
font="Font Awesome 6 Free",
highlight_color='#272822',
highlight_method='block',
mouse_callbacks={"Button1": lambda: None},
rounded=False,
this_current_screen_border='#005577',
urgent_alert_method='block',
urgent_border='#770000',
use_mouse_wheel=False,
),
widget.Prompt(
bell_style=None,
prompt='open: ',
record_history=False,
),
widget.Spacer(),
widget.Notify(
foreground='#000000',
background='#e8b923',
foreground_low='#c7c7c7',
background_low='#272822',
foreground_urgent='#feffff',
background_urgent='#770000',
),
widget.GenPollCommand(
foreground='#feffff',
background='#770000',
update_interval=1,
cmd="sb-volume",
),
widget.GenPollCommand(
foreground='#feffff',
background='#770000',
update_interval=1,
cmd="sb-wireguard",
),
widget.Wlan(
foreground='#feffff',
background='#770000',
format='',
disconnected_message="no wifi",
),
widget.GenPollCommand(
update_interval=1,
cmd="sb-battery",
),
widget.Clock(
format='[%d] %H:%M:%S',
),
widget.StatusNotifier(),
],
24,
margin=[5, 5, 0, 5]
),
wallpaper=os.environ['XDG_CONFIG_HOME'] + '/qtile/wallpaper.img',
wallpaper_mode='fill',
),
]
wl_input_rules = {}
@hook.subscribe.startup_once @hook.subscribe.startup_once
def autostart(): def autostart():
autostart = os.path.expanduser('~/.config/qtile/autostart.sh') autostart=os.environ['XDG_CONFIG_HOME'] + '/qtile/autostart.sh'
subprocess.run([autostart]) subprocess.run([autostart])
@hook.subscribe.shutdown @hook.subscribe.shutdown
def autostop(): def autostop():
autostop = os.path.expanduser('~/.config/qtile/stop.sh') autostop=os.environ['XDG_CONFIG_HOME'] + '/qtile/autostop.sh'
subprocess.run([autostop]) subprocess.run([autostop])
mod = "mod4" keys.extend([
groups = [
Group("1", label="\uf292"),
Group("2", label="\ue007", matches=[Match(wm_class=["Firefox"])]),
Group("3", label="\uf39f", matches=[Match(wm_class=["ferdium"])]),
Group("4", label="\uf392", matches=[Match(wm_class=["discord"])]),
Group("5", label="\uf0e0", matches=[Match(wm_class=["mutt"])]),
Group("6", label="\uf120"),
Group("7", label="\uf084", matches=[Match(wm_class=["1Password"])]),
Group("8", label="\uf198", matches=[Match(wm_class=["Slack"])]),
Group("9", label="\uf296"),
Group("0", label="\uf0b1", matches=[Match(wm_class=["workfx"])]),
]
keys = [
# switch between windows # switch between windows
Key([mod], "h", lazy.layout.left()), Key([mod], "h", lazy.layout.left()),
Key([mod], "l", lazy.layout.right()), Key([mod], "l", lazy.layout.right()),
@ -61,51 +143,26 @@ keys = [
Key([mod, "shift"], "j", lazy.layout.grow_down()), Key([mod, "shift"], "j", lazy.layout.grow_down()),
Key([mod, "shift"], "k", lazy.layout.grow_up()), Key([mod, "shift"], "k", lazy.layout.grow_up()),
Key([mod, "shift", "control"], "0", lazy.layout.normalize()), Key([mod, "shift", "control"], "0", lazy.layout.normalize()),
# app binds
Key([mod], "Return", lazy.spawn("foot")),
Key([mod], "space", lazy.spawncmd()),
Key([mod], "a", lazy.spawn("flatpak run com.yubico.yubioath")),
Key([mod], "e", lazy.spawn("selector-chars")),
Key([mod], "i", lazy.spawn("sh -c 'grim -g \"$(slurp)\"'")),
Key([mod], "m", lazy.spawn("sh -c 'pgrep -x neomutt > /dev/null || foot -a mutt -o bold-text-in-bright=yes neomutt'")),
Key([mod, "shift"], "i", lazy.spawn("grim")),
Key([mod, "shift"], "Return", lazy.spawn("sh -c 'terminal_profile=work foot -o url.launch=workfx\ \${url}'")),
Key([mod, "control"], "a", lazy.spawn("selector-audio")),
Key([mod, "control"], "b", lazy.spawn("selector-bluetooth")),
# WM control # WM control
Key([mod], "f", lazy.window.toggle_floating()), Key([mod], "f", lazy.window.toggle_floating()),
Key([mod], "q", lazy.window.kill()), Key([mod], "q", lazy.window.kill()),
Key([mod, "control", "shift"], "l", lazy.spawn("swaylock --image ~/.config/qtile/wallpaper.img")),
Key([mod, "control", "shift"], "q", lazy.shutdown()), Key([mod, "control", "shift"], "q", lazy.shutdown()),
Key([mod, "control", "shift"], "r", lazy.reload_config()), Key([mod, "control", "shift"], "r", lazy.reload_config()),
Key([mod], "r", lazy.reload_config()), Key([mod], "r", lazy.reload_config()),
# media keys ])
Key([], "XF86AudioMute", lazy.spawn("pactl set-sink-mute @DEFAULT_SINK@ toggle")),
Key([], "XF86AudioMicMute", lazy.spawn("sb-volume micmute")),
Key([], "XF86AudioRaiseVolume", lazy.spawn("sb-volume inc")),
Key([], "XF86AudioLowerVolume", lazy.spawn("sb-volume dec")),
Key([], "XF86MonBrightnessUp", lazy.spawn("doas xbacklight -inc 10")),
Key([], "XF86MonBrightnessDown", lazy.spawn("doas xbacklight -dec 10")),
]
for i in groups[:10]: for i in groups[:10]:
keys.extend( keys.extend([
[ Key(
# mod1 + letter of group = switch to group [mod], i.name, lazy.group[i.name].toscreen(),
Key( desc="Switch to group {}".format(i.name),
[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),
), desc="move focused window 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)
),
]
)
if qtile.core.name is "wayland": if qtile.core.name == "wayland":
for i in range(1,2): for i in range(1,2):
keys.extend([ keys.extend([
Key(["control", "mod1"], f"f{i}", lazy.core.change_vt(i), desc=f"Switch to VT{i}") Key(["control", "mod1"], f"f{i}", lazy.core.change_vt(i), desc=f"Switch to VT{i}")
@ -122,98 +179,6 @@ layouts = [
), ),
] ]
widget_defaults = dict(
background='#272822',
font='Roboto Mono Medium',
fontsize=14,
foreground='#feffff',
)
extension_defaults = widget_defaults.copy()
def yubikey_replace(text):
return text.replace('YubiKey is waiting for a touch', 'touch the yubikey')
screens = [
Screen(
top=bar.Bar(
[
widget.GroupBox(
active='#feffff',
disable_drag=True,
font="Font Awesome 6 Free",
highlight_color='#272822',
highlight_method='block',
mouse_callbacks={"Button1": lambda: None},
rounded=False,
this_current_screen_border='#005577',
urgent_alert_method='block',
urgent_border='#770000',
use_mouse_wheel=False,
),
widget.Prompt(
bell_style=None,
prompt='open: ',
record_history=False,
),
widget.Spacer(),
widget.Notify(
background='#e8b923',
background_low='#272822',
background_urgent='#770000',
foreground='#000000',
foreground_low='#c7c7c7',
foreground_urgent='#feffff',
parse_text=yubikey_replace,
),
widget.GenPollCommand(
background='#005577',
foreground='#feffff',
update_interval=1,
cmd="sb-mail",
),
widget.GenPollCommand(
background='#770000',
foreground='#feffff',
update_interval=1,
cmd="sb-volume",
),
widget.GenPollCommand(
background='#770000',
foreground='#feffff',
update_interval=1,
cmd="sb-wireguard",
),
widget.Wlan(
background='#770000',
foreground='#feffff',
format='',
disconnected_message="no wifi",
),
widget.GenPollCommand(
update_interval=1,
cmd="sb-battery",
),
widget.Clock(
format='[%d] %H:%M:%S',
),
widget.StatusNotifier(
icon_size=18,
),
],
24,
margin=[5, 5, 0, 5]
),
wallpaper=os.environ['XDG_CONFIG_HOME'] + '/qtile/wallpaper.img',
wallpaper_mode='fill',
),
]
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( floating_layout = layout.Floating(
float_rules=[ float_rules=[
*layout.Floating.default_float_rules, *layout.Floating.default_float_rules,
@ -230,5 +195,11 @@ floating_layout = layout.Floating(
border_width=5, border_width=5,
) )
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()),
]
focus_on_window_activation = "urgent" focus_on_window_activation = "urgent"
wmname = "qtile" wmname = "qtile"

View File

@ -0,0 +1,25 @@
from common import *
groups = [
# use icon as group's label - for more icons visit https://fontawesome.com/icons
Group("1", label="\uf292"),
# match window class to a group
Group("2", label="\ue007", matches=[Match(wm_class=["Firefox"])]),
]
keys = [
# example key binding for running a command
Key([mod], "f", lazy.spawn("firefox")),
# example keychord
KeyChord([mod], "Comma", [
Key([], "f", lazy.spawn("firefox")),
])
]
# example input rules for Wayland
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),
}