1
0
Fork 0
mirror of https://gitlab.com/dwt1/dotfiles.git synced 2023-02-13 20:55:19 -05:00
dwt1--dotfiles/.config/qtile/config.py

582 lines
21 KiB
Python
Raw Normal View History

2019-01-15 16:27:01 -05:00
# -*- coding: utf-8 -*-
import os
import re
import socket
import subprocess
2021-03-11 21:19:27 -05:00
from libqtile import qtile
2021-03-12 00:12:03 -05:00
from libqtile.config import Click, Drag, Group, KeyChord, Key, Match, Screen
2019-01-15 16:27:01 -05:00
from libqtile.command import lazy
from libqtile import layout, bar, widget, hook
2020-11-15 07:16:21 -05:00
from libqtile.lazy import lazy
2021-10-08 13:38:10 -04:00
from libqtile.utils import guess_terminal
from typing import List # noqa: F401from typing import List # noqa: F401
2019-01-15 16:27:01 -05:00
2021-09-02 23:23:26 -04:00
mod = "mod4" # Sets mod key to SUPER/WINDOWS
myTerm = "alacritty" # My terminal of choice
myBrowser = "qutebrowser" # My browser of choice
2019-01-15 16:27:01 -05:00
2020-03-11 18:49:37 -04:00
keys = [
### The essentials
2020-07-11 12:37:20 -04:00
Key([mod], "Return",
2020-12-12 10:09:31 -05:00
lazy.spawn(myTerm+" -e fish"),
2020-07-11 12:37:20 -04:00
desc='Launches My Terminal'
),
2020-07-11 12:37:20 -04:00
Key([mod, "shift"], "Return",
2021-03-10 21:41:20 -05:00
lazy.spawn("dmenu_run -p 'Run: '"),
2020-12-12 10:09:31 -05:00
desc='Run Launcher'
),
2021-09-02 23:23:26 -04:00
Key([mod], "b",
lazy.spawn(myBrowser),
desc='Qutebrowser'
),
2020-07-11 12:37:20 -04:00
Key([mod], "Tab",
lazy.next_layout(),
desc='Toggle through layouts'
),
2020-07-11 12:37:20 -04:00
Key([mod, "shift"], "c",
lazy.window.kill(),
desc='Kill active window'
),
2020-07-11 12:37:20 -04:00
Key([mod, "shift"], "r",
lazy.restart(),
desc='Restart Qtile'
),
2020-07-11 12:37:20 -04:00
Key([mod, "shift"], "q",
lazy.shutdown(),
desc='Shutdown Qtile'
),
2020-07-11 12:37:20 -04:00
Key(["control", "shift"], "e",
lazy.spawn("emacsclient -c -a emacs"),
desc='Doom Emacs'
),
### Switch focus to specific monitor (out of three)
Key([mod], "w",
lazy.to_screen(0),
desc='Keyboard focus to monitor 1'
),
Key([mod], "e",
lazy.to_screen(1),
desc='Keyboard focus to monitor 2'
),
Key([mod], "r",
lazy.to_screen(2),
desc='Keyboard focus to monitor 3'
),
### 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'
),
### Treetab controls
2021-03-20 14:06:31 -04:00
Key([mod, "shift"], "h",
lazy.layout.move_left(),
desc='Move up a section in treetab'
),
2021-03-20 14:06:31 -04:00
Key([mod, "shift"], "l",
lazy.layout.move_right(),
desc='Move down a section in treetab'
),
### Window controls
2020-07-11 12:37:20 -04:00
Key([mod], "j",
2021-03-20 14:06:31 -04:00
lazy.layout.down(),
desc='Move focus down in current stack pane'
),
Key([mod], "k",
lazy.layout.up(),
desc='Move focus up in current stack pane'
),
2021-03-20 14:06:31 -04:00
Key([mod, "shift"], "j",
lazy.layout.shuffle_down(),
2021-03-20 14:06:31 -04:00
lazy.layout.section_down(),
desc='Move windows down in current stack'
),
2021-03-20 14:06:31 -04:00
Key([mod, "shift"], "k",
lazy.layout.shuffle_up(),
2021-03-20 14:06:31 -04:00
lazy.layout.section_up(),
desc='Move windows up in current stack'
),
2020-07-11 12:37:20 -04:00
Key([mod], "h",
lazy.layout.shrink(),
lazy.layout.decrease_nmaster(),
desc='Shrink window (MonadTall), decrease number in master pane (Tile)'
),
2021-03-12 17:49:30 -05:00
Key([mod], "l",
lazy.layout.grow(),
lazy.layout.increase_nmaster(),
desc='Expand window (MonadTall), increase number in master pane (Tile)'
),
2020-07-11 12:37:20 -04:00
Key([mod], "n",
lazy.layout.normalize(),
desc='normalize window size ratios'
),
2020-07-11 12:37:20 -04:00
Key([mod], "m",
lazy.layout.maximize(),
desc='toggle window between minimum and maximum sizes'
),
2020-07-11 12:37:20 -04:00
Key([mod, "shift"], "f",
lazy.window.toggle_floating(),
desc='toggle floating'
),
2021-03-20 14:06:31 -04:00
Key([mod], "f",
2020-07-11 12:37:20 -04:00
lazy.window.toggle_fullscreen(),
desc='toggle fullscreen'
),
### Stack controls
2021-03-20 14:06:31 -04:00
Key([mod, "shift"], "Tab",
lazy.layout.rotate(),
lazy.layout.flip(),
desc='Switch which side main pane occupies (XmonadTall)'
),
2021-03-20 14:06:31 -04:00
Key([mod], "space",
lazy.layout.next(),
desc='Switch window focus to other pane(s) of stack'
),
2021-03-20 14:06:31 -04:00
Key([mod, "shift"], "space",
lazy.layout.toggle_split(),
desc='Toggle between split and unsplit sides of stack'
),
2021-03-10 21:48:44 -05:00
# Emacs programs launched using the key chord CTRL+e followed by 'key'
KeyChord(["control"],"e", [
2021-03-13 16:22:16 -05:00
Key([], "e",
lazy.spawn("emacsclient -c -a 'emacs'"),
desc='Launch Emacs'
),
Key([], "b",
lazy.spawn("emacsclient -c -a 'emacs' --eval '(ibuffer)'"),
desc='Launch ibuffer inside Emacs'
),
Key([], "d",
lazy.spawn("emacsclient -c -a 'emacs' --eval '(dired nil)'"),
desc='Launch dired inside Emacs'
),
Key([], "i",
lazy.spawn("emacsclient -c -a 'emacs' --eval '(erc)'"),
desc='Launch erc inside Emacs'
),
Key([], "m",
lazy.spawn("emacsclient -c -a 'emacs' --eval '(mu4e)'"),
desc='Launch mu4e inside Emacs'
),
Key([], "n",
lazy.spawn("emacsclient -c -a 'emacs' --eval '(elfeed)'"),
desc='Launch elfeed inside Emacs'
),
Key([], "s",
lazy.spawn("emacsclient -c -a 'emacs' --eval '(eshell)'"),
desc='Launch the eshell inside Emacs'
),
Key([], "v",
lazy.spawn("emacsclient -c -a 'emacs' --eval '(+vterm/here nil)'"),
desc='Launch vterm inside Emacs'
)
2021-03-10 21:48:44 -05:00
]),
2021-03-10 21:41:20 -05:00
# Dmenu scripts launched using the key chord SUPER+p followed by 'key'
KeyChord([mod], "p", [
2021-03-13 16:22:16 -05:00
Key([], "e",
lazy.spawn("./dmscripts/dm-confedit"),
2021-03-13 16:22:16 -05:00
desc='Choose a config file to edit'
),
Key([], "i",
lazy.spawn("./dmscripts/dm-maim"),
2021-03-13 16:22:16 -05:00
desc='Take screenshots via dmenu'
),
Key([], "k",
lazy.spawn("./dmscripts/dm-kill"),
2021-03-13 16:22:16 -05:00
desc='Kill processes via dmenu'
),
Key([], "l",
lazy.spawn("./dmscripts/dm-logout"),
2021-03-13 16:22:16 -05:00
desc='A logout menu'
),
Key([], "m",
lazy.spawn("./dmscripts/dm-man"),
2021-03-13 16:22:16 -05:00
desc='Search manpages in dmenu'
),
2021-03-20 14:06:31 -04:00
Key([], "o",
lazy.spawn("./dmscripts/dm-bookman"),
2021-03-20 14:06:31 -04:00
desc='Search your qutebrowser bookmarks and quickmarks'
),
2021-03-13 16:22:16 -05:00
Key([], "r",
lazy.spawn("./dmscripts/dm-reddit"),
2021-03-13 16:22:16 -05:00
desc='Search reddit via dmenu'
),
Key([], "s",
lazy.spawn("./dmscripts/dm-websearch"),
2021-03-13 16:22:16 -05:00
desc='Search various search engines via dmenu'
),
Key([], "p",
lazy.spawn("passmenu"),
desc='Retrieve passwords with dmenu'
)
2021-03-10 21:41:20 -05:00
])
2020-03-11 18:49:37 -04:00
]
2019-02-10 15:18:26 -05:00
2021-11-04 09:40:49 -04:00
groups = [Group("DEV", layout='monadtall'),
Group("WWW", layout='monadtall'),
Group("SYS", layout='monadtall'),
Group("SYS", layout='monadtall'),
Group("DOC", layout='monadtall'),
Group("VBOX", layout='monadtall'),
Group("CHAT", layout='monadtall'),
Group("MUS", layout='monadtall'),
Group("VID", layout='monadtall'),
Group("GFX", layout='floating')]
2020-03-11 18:49:37 -04:00
2021-10-08 13:38:10 -04:00
# Allow MODKEY+[0 through 9] to bind to groups, see https://docs.qtile.org/en/stable/manual/config/groups.html
# MOD4 + index Number : Switch to Group[index]
# MOD4 + shift + index Number : Send active window to another Group
from libqtile.dgroups import simple_key_binder
dgroups_key_binder = simple_key_binder("mod4")
2020-03-11 18:49:37 -04:00
layout_theme = {"border_width": 2,
2021-03-11 10:20:59 -05:00
"margin": 8,
2020-04-10 01:17:48 -04:00
"border_focus": "e1acff",
2020-03-11 18:49:37 -04:00
"border_normal": "1D2330"
}
layouts = [
#layout.MonadWide(**layout_theme),
2020-03-11 18:49:37 -04:00
#layout.Bsp(**layout_theme),
#layout.Stack(stacks=2, **layout_theme),
#layout.Columns(**layout_theme),
#layout.RatioTile(**layout_theme),
2021-03-20 14:06:31 -04:00
#layout.Tile(shift_windows=True, **layout_theme),
2020-03-11 18:49:37 -04:00
#layout.VerticalTile(**layout_theme),
#layout.Matrix(**layout_theme),
#layout.Zoomy(**layout_theme),
layout.MonadTall(**layout_theme),
layout.Max(**layout_theme),
layout.Stack(num_stacks=2),
2021-03-20 14:06:31 -04:00
layout.RatioTile(**layout_theme),
2020-03-11 18:49:37 -04:00
layout.TreeTab(
font = "Ubuntu",
fontsize = 10,
2021-03-20 14:06:31 -04:00
sections = ["FIRST", "SECOND", "THIRD", "FOURTH"],
section_fontsize = 10,
border_width = 2,
bg_color = "1c1f24",
active_bg = "c678dd",
2020-03-11 18:49:37 -04:00
active_fg = "000000",
2021-03-20 14:06:31 -04:00
inactive_bg = "a9a1e1",
inactive_fg = "1c1f24",
padding_left = 0,
padding_x = 0,
2020-03-11 18:49:37 -04:00
padding_y = 5,
section_top = 10,
2021-03-20 14:06:31 -04:00
section_bottom = 20,
level_shift = 8,
vspace = 3,
panel_width = 200
2020-03-11 18:49:37 -04:00
),
2020-05-30 12:49:58 -04:00
layout.Floating(**layout_theme)
2020-03-11 18:49:37 -04:00
]
2022-01-06 15:59:17 -05:00
colors = [["#282c34", "#282c34"],
["#1c1f24", "#1c1f24"],
["#dfdfdf", "#dfdfdf"],
["#ff6c6b", "#ff6c6b"],
["#98be65", "#98be65"],
["#da8548", "#da8548"],
["#51afef", "#51afef"],
["#c678dd", "#c678dd"],
["#46d9ff", "#46d9ff"],
["#a9a1e1", "#a9a1e1"]]
2020-03-11 18:49:37 -04:00
prompt = "{0}@{1}: ".format(os.environ["USER"], socket.gethostname())
2020-03-11 18:49:37 -04:00
##### DEFAULT WIDGET SETTINGS #####
widget_defaults = dict(
2022-01-06 15:59:17 -05:00
font="Ubuntu Bold",
fontsize = 10,
2020-03-11 18:49:37 -04:00
padding = 2,
background=colors[2]
)
extension_defaults = widget_defaults.copy()
2019-01-15 16:27:01 -05:00
def init_widgets_list():
widgets_list = [
2020-07-11 12:37:20 -04:00
widget.Sep(
linewidth = 0,
padding = 6,
foreground = colors[2],
background = colors[0]
),
widget.Image(
2021-03-11 21:19:27 -05:00
filename = "~/.config/qtile/icons/python-white.png",
scale = "False",
2021-03-12 00:12:03 -05:00
mouse_callbacks = {'Button1': lambda: qtile.cmd_spawn(myTerm)}
2020-07-11 12:37:20 -04:00
),
widget.Sep(
2021-03-10 22:50:45 -05:00
linewidth = 0,
padding = 6,
foreground = colors[2],
background = colors[0]
),
2020-07-11 12:37:20 -04:00
widget.GroupBox(
font = "Ubuntu Bold",
fontsize = 9,
margin_y = 3,
margin_x = 0,
padding_y = 5,
padding_x = 3,
borderwidth = 3,
active = colors[2],
2021-03-20 14:06:31 -04:00
inactive = colors[7],
2020-07-11 12:37:20 -04:00
rounded = False,
highlight_color = colors[1],
highlight_method = "line",
2021-03-10 22:50:45 -05:00
this_current_screen_border = colors[6],
2020-07-11 12:37:20 -04:00
this_screen_border = colors [4],
2021-03-10 22:50:45 -05:00
other_current_screen_border = colors[6],
other_screen_border = colors[4],
2020-07-11 12:37:20 -04:00
foreground = colors[2],
background = colors[0]
),
2022-01-06 15:59:17 -05:00
widget.TextBox(
text = '|',
2020-07-11 12:37:20 -04:00
font = "Ubuntu Mono",
2022-01-06 15:59:17 -05:00
background = colors[0],
foreground = '474747',
padding = 2,
fontsize = 14
2020-07-11 12:37:20 -04:00
),
2022-01-06 15:59:17 -05:00
widget.CurrentLayoutIcon(
custom_icon_paths = [os.path.expanduser("~/.config/qtile/icons")],
2020-07-11 12:37:20 -04:00
foreground = colors[2],
2022-01-06 15:59:17 -05:00
background = colors[0],
padding = 0,
scale = 0.7
),
widget.CurrentLayout(
foreground = colors[2],
background = colors[0],
padding = 5
),
widget.TextBox(
text = '|',
font = "Ubuntu Mono",
background = colors[0],
foreground = '474747',
padding = 2,
fontsize = 14
2020-07-11 12:37:20 -04:00
),
widget.WindowName(
foreground = colors[6],
background = colors[0],
padding = 0
),
2021-03-10 22:50:45 -05:00
widget.Systray(
background = colors[0],
padding = 5
),
widget.Sep(
linewidth = 0,
padding = 6,
foreground = colors[0],
background = colors[0]
),
2020-07-11 12:37:20 -04:00
widget.TextBox(
text = '',
2022-01-06 15:59:17 -05:00
font = "Ubuntu Mono",
2020-07-11 12:37:20 -04:00
background = colors[0],
2022-01-06 15:59:17 -05:00
foreground = colors[3],
2020-07-11 12:37:20 -04:00
padding = 0,
fontsize = 37
),
2021-03-13 16:22:16 -05:00
widget.Net(
2022-01-06 15:59:17 -05:00
interface = "enp5s0",
format = 'Net: {down} ↓↑ {up}',
foreground = colors[1],
background = colors[3],
2020-07-04 12:36:50 -04:00
padding = 5
),
widget.TextBox(
2020-07-11 12:37:20 -04:00
text = '',
2022-01-06 15:59:17 -05:00
font = "Ubuntu Mono",
background = colors[3],
2021-10-08 13:38:10 -04:00
foreground = colors[4],
2020-07-11 12:37:20 -04:00
padding = 0,
fontsize = 37
2020-07-04 12:36:50 -04:00
),
2021-10-08 13:38:10 -04:00
widget.ThermalSensor(
2022-01-06 15:59:17 -05:00
foreground = colors[1],
2021-10-08 13:38:10 -04:00
background = colors[4],
threshold = 90,
2022-01-06 15:59:17 -05:00
fmt = 'Temp: {}',
2021-10-08 13:38:10 -04:00
padding = 5
),
2020-07-04 12:36:50 -04:00
widget.TextBox(
text='',
2022-01-06 15:59:17 -05:00
font = "Ubuntu Mono",
2021-10-08 13:38:10 -04:00
background = colors[4],
foreground = colors[5],
2020-07-11 12:37:20 -04:00
padding = 0,
fontsize = 37
),
2021-03-08 21:16:01 -05:00
widget.CheckUpdates(
2020-07-11 12:37:20 -04:00
update_interval = 1800,
2021-03-08 21:16:01 -05:00
distro = "Arch_checkupdates",
2022-01-06 15:59:17 -05:00
display_format = "Updates: {updates} ",
foreground = colors[1],
colour_have_updates = colors[1],
colour_no_updates = colors[1],
2021-03-11 21:19:27 -05:00
mouse_callbacks = {'Button1': lambda: qtile.cmd_spawn(myTerm + ' -e sudo pacman -Syu')},
2022-01-06 15:59:17 -05:00
padding = 5,
2021-10-08 13:38:10 -04:00
background = colors[5]
2020-07-11 12:37:20 -04:00
),
widget.TextBox(
text = '',
2022-01-06 15:59:17 -05:00
font = "Ubuntu Mono",
2021-10-08 13:38:10 -04:00
background = colors[5],
2022-01-06 15:59:17 -05:00
foreground = colors[6],
2020-07-11 12:37:20 -04:00
padding = 0,
fontsize = 37
),
widget.Memory(
2022-01-06 15:59:17 -05:00
foreground = colors[1],
background = colors[6],
2021-10-08 13:38:10 -04:00
mouse_callbacks = {'Button1': lambda: qtile.cmd_spawn(myTerm + ' -e htop')},
2022-01-06 15:59:17 -05:00
fmt = 'Mem: {}',
2020-07-11 12:37:20 -04:00
padding = 5
),
widget.TextBox(
text = '',
2022-01-06 15:59:17 -05:00
font = "Ubuntu Mono",
background = colors[6],
foreground = colors[7],
2020-07-11 12:37:20 -04:00
padding = 0,
fontsize = 37
),
widget.Volume(
2022-01-06 15:59:17 -05:00
foreground = colors[1],
background = colors[7],
fmt = 'Vol: {}',
2020-07-11 12:37:20 -04:00
padding = 5
),
widget.TextBox(
text = '',
2022-01-06 15:59:17 -05:00
font = "Ubuntu Mono",
background = colors[7],
foreground = colors[8],
2020-07-11 12:37:20 -04:00
padding = 0,
fontsize = 37
),
2022-01-06 15:59:17 -05:00
widget.KeyboardLayout(
foreground = colors[1],
background = colors[8],
fmt = 'Keyboard: {}',
2020-07-11 12:37:20 -04:00
padding = 5
),
widget.TextBox(
text = '',
2022-01-06 15:59:17 -05:00
font = "Ubuntu Mono",
background = colors[8],
foreground = colors[9],
2020-07-11 12:37:20 -04:00
padding = 0,
fontsize = 37
),
widget.Clock(
2022-01-06 15:59:17 -05:00
foreground = colors[1],
background = colors[9],
2021-03-10 22:50:45 -05:00
format = "%A, %B %d - %H:%M "
2020-07-04 12:36:50 -04:00
),
2019-02-10 15:18:26 -05:00
]
2019-01-15 16:27:01 -05:00
return widgets_list
def init_widgets_screen1():
widgets_screen1 = init_widgets_list()
2022-01-06 15:59:17 -05:00
del widgets_screen1[9:10] # Slicing removes unwanted widgets (systray) on Monitors 1,3
2021-03-12 17:49:30 -05:00
return widgets_screen1
2019-02-10 15:18:26 -05:00
2019-01-15 16:27:01 -05:00
def init_widgets_screen2():
widgets_screen2 = init_widgets_list()
2021-03-12 17:49:30 -05:00
return widgets_screen2 # Monitor 2 will display all widgets in widgets_list
2019-02-10 15:18:26 -05:00
2019-01-15 16:27:01 -05:00
def init_screens():
2020-07-11 12:37:20 -04:00
return [Screen(top=bar.Bar(widgets=init_widgets_screen1(), opacity=1.0, size=20)),
Screen(top=bar.Bar(widgets=init_widgets_screen2(), opacity=1.0, size=20)),
Screen(top=bar.Bar(widgets=init_widgets_screen1(), opacity=1.0, size=20))]
2019-01-15 16:27:01 -05:00
if __name__ in ["config", "__main__"]:
screens = init_screens()
widgets_list = init_widgets_list()
widgets_screen1 = init_widgets_screen1()
widgets_screen2 = init_widgets_screen2()
2020-11-15 07:16:21 -05:00
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)
2020-03-11 18:49:37 -04: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())
]
dgroups_app_rules = [] # type: List
follow_mouse_focus = True
bring_front_click = False
cursor_warp = False
2019-01-15 16:27:01 -05:00
2020-03-11 18:49:37 -04:00
floating_layout = layout.Floating(float_rules=[
2021-03-12 00:12:03 -05:00
# Run the utility of `xprop` to see the wm class and name of an X client.
# default_float_rules include: utility, notification, toolbar, splash, dialog,
# file_progress, confirm, download and error.
*layout.Floating.default_float_rules,
2021-04-04 11:43:40 -04:00
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
2020-03-11 18:49:37 -04:00
])
auto_fullscreen = True
focus_on_window_activation = "smart"
2021-10-08 13:38:10 -04:00
reconfigure_screens = True
# If things like steam games want to auto-minimize themselves when losing
# focus, should we respect this or not?
auto_minimize = True
2019-02-10 15:18:26 -05:00
2019-01-15 16:27:01 -05:00
@hook.subscribe.startup_once
def start_once():
home = os.path.expanduser('~')
subprocess.call([home + '/.config/qtile/autostart.sh'])
2020-03-11 18:49:37 -04:00
# 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"