qtile_config/config.py

278 lines
8.1 KiB
Python
Raw Normal View History

2020-04-22 05:13:09 +00:00
# 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.
2020-04-22 07:24:41 +00:00
from libqtile.config import Key, Screen, Group, Drag, Click, ScratchPad, DropDown
2020-04-22 05:13:09 +00:00
from libqtile.command import lazy
from libqtile import layout, bar, widget, extension, hook
from os.path import expanduser
from subprocess import call
from typing import List # noqa: F401
wmname = "???"
MOD = "mod4"
2021-06-15 08:02:44 +00:00
TERM = "urxvt"
# Base16 - hybrid (with 5 and 13 from jmbi)
colors = {
# special
"FG": "#c5c8c6",
"BG": "#1d1f21",
"C": "#c5c8c6",
# black
0: "#282a2e",
8: "#373b41",
# red
1: "#a54242",
9: "#cc6666",
# green
2: "#8c9440",
10: "#b5bd68",
# yellow
3: "#de935f",
11: "#f0c674",
# blue
4: "#5f819d",
12: "#81a2be",
# magenta
5: "#d13516",
13: "#c25431",
# cyan
6: "#5e8d87",
14: "#8abeb7",
# white
7: "#707880",
15: "#c5c8c6",
}
2020-04-22 05:13:09 +00:00
keys = [
2021-06-15 08:02:44 +00:00
Key([MOD], "f", lazy.window.toggle_floating()),
2020-04-22 05:13:09 +00:00
# Moving inside a screen
Key([MOD], "Tab", lazy.layout.next()),
Key([MOD], "j", lazy.layout.down()),
Key([MOD], "k", lazy.layout.up()),
Key([MOD, "shift"], "Tab", lazy.layout.rotate()),
2021-06-15 08:02:44 +00:00
# Key([MOD, "shift"], "Tab", lazy.spawncmd()), # circle inside layout
2020-04-22 05:13:09 +00:00
Key([MOD, "shift"], "k", lazy.layout.shuffle_up()),
2021-06-15 08:02:44 +00:00
Key([MOD, "shift"], "j", lazy.layout.shuffle_down()),
2020-04-22 05:13:09 +00:00
# Move between screens
2021-06-15 08:02:44 +00:00
Key([MOD], "l", lazy.to_screen(0)),
Key([MOD], "h", lazy.to_screen(1)),
# Key([MOD, "shift"], "l", move to screen 1),
# Key([MOD, "shift"], "h", move to screen 0),
2020-04-22 05:13:09 +00:00
# Toggle between different layouts as defined below
Key([MOD], "space", lazy.next_layout()),
# 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()),
# Swap panes of split stack
# Key([MOD, "shift"], "space", lazy.layout.rotate()),
2021-06-15 08:02:44 +00:00
# Screens
2020-04-22 05:13:09 +00:00
Key([MOD], "r", lazy.spawncmd()),
# Key([MOD], 'r', lazy.run_extension(extension.DmenuRun(
# dmenu_prompt=">",
# dmenu_font="Andika-8",
# background="#15181a",
# foreground="#00ff00",
# selected_background="#079822",
# selected_foreground="#fff",
# dmenu_height=24, # Only supported by some dmenu forks
# ))),
Key([MOD], "Return", lazy.spawn(TERM)),
Key([MOD], "q", lazy.window.kill()),
Key([MOD, "control"], "r", lazy.restart()),
Key([MOD, "control"], "q", lazy.shutdown()),
Key([MOD, "control"], "equal", lazy.spawn("systemctl suspend")),
2020-04-22 07:10:02 +00:00
# Change the volume if our keyboard has keys
2021-06-15 08:02:44 +00:00
Key([], "XF86AudioRaiseVolume", lazy.spawn("pamixer -i 2")),
Key([], "XF86AudioLowerVolume", lazy.spawn("pamixer -d 2")),
Key([], "XF86AudioMute", lazy.spawn("pamixer -t")),
2020-04-22 05:13:09 +00:00
]
groups = [
2021-06-15 08:02:44 +00:00
Group("t:", spawn="firefox", layout="Tall", persist=True),
Group("y:", spawn="thunderbird", layout="verticaltile", persist=True),
Group("u:", spawn="st tmuxp load enseignement", layout="TallRight", persist=True),
Group("i:", layout="Wide", persist=True),
Group("o:", layout="TallRight", persist=True),
Group("p:", layout="Wide", persist=True),
2020-04-22 05:13:09 +00:00
]
groups_keys = ["t", "y", "u", "i", "o", "p"]
for i, g in enumerate(groups):
k = groups_keys[i]
2021-06-15 08:02:44 +00:00
keys.extend(
[
# mod1 + letter of group = switch to group
Key([MOD], k, lazy.group[g.name].toscreen()),
# mod1 + shift + letter of group = switch to & move focused window to group
Key(
[MOD, "shift"], k, lazy.window.togroup(g.name)
), # , lazy.group[g.name].toscreen()),
]
)
2020-04-22 05:13:09 +00:00
2020-04-22 07:24:41 +00:00
groups.append(
2021-06-15 08:02:44 +00:00
ScratchPad(
"scratchpad",
[
DropDown(
"music", "st mocp", x=0.25, y=0.25, height=0.5, width=0.5, opacity=0.8
),
],
),
2020-04-22 07:24:41 +00:00
)
2021-06-15 08:02:44 +00:00
keys.extend(
[
Key([MOD], "m", lazy.group["scratchpad"].dropdown_toggle("music")),
]
)
borders = {
"border_focus": colors[13],
"border_normal": colors["BG"],
}
2020-04-22 07:24:41 +00:00
2020-04-22 05:13:09 +00:00
layouts = [
layout.Max(),
2021-06-15 08:02:44 +00:00
layout.VerticalTile(**borders),
layout.MonadTall(
name="Tall",
align=0,
ratio=0.5,
**borders,
),
layout.MonadTall(
name="TallRight",
align=0,
ratio=0.7,
**borders,
),
layout.MonadWide(
name="Wide",
ratio=0.8,
**borders,
),
2020-04-22 05:13:09 +00:00
]
widget_defaults = dict(
2021-06-15 08:02:44 +00:00
font="DroidSans",
2020-04-22 05:13:09 +00:00
fontsize=12,
padding=3,
)
extension_defaults = widget_defaults.copy()
screens = [
Screen(),
Screen(
bottom=bar.Bar(
[
2021-06-15 08:02:44 +00:00
widget.GroupBox(
active=colors["FG"],
foreground=colors[8],
highlight_color=[colors[1], colors[13]],
highlight_method="border",
this_current_screen_border=colors[13],
this_screen_border=colors[8],
other_current_screen_border=colors[13],
other_screen_border=colors[8],
),
widget.Prompt(
background=colors[13],
),
2020-04-22 07:24:41 +00:00
# widget.WindowName(),
2021-06-15 08:02:44 +00:00
widget.Spacer(bar.STRETCH),
widget.Clock(
format="%A %d %B %Y %I:%M",
background=colors[13],
foreground=colors[15],
),
2020-04-22 05:13:09 +00:00
widget.Systray(),
2021-06-15 08:02:44 +00:00
# widget.CurrentLayoutIcon(scale=0.5),
2020-04-22 05:13:09 +00:00
],
2021-06-15 08:02:44 +00:00
size=24,
background=colors["BG"],
2020-04-22 05:13:09 +00:00
),
),
]
# Drag floating layouts.
mouse = [
2021-06-15 08:02:44 +00:00
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()),
2020-04-22 05:13:09 +00:00
]
dgroups_key_binder = None
dgroups_app_rules = [] # type: List
main = None
follow_mouse_focus = True
bring_front_click = False
cursor_warp = False
2021-06-15 08:02:44 +00:00
floating_layout = layout.Floating(
float_rules=[
{"wmclass": "confirm"},
{"wmclass": "dialog"},
{"wmclass": "download"},
{"wmclass": "error"},
{"wmclass": "file_progress"},
{"wmclass": "notification"},
{"wmclass": "splash"},
{"wmclass": "toolbar"},
{"wmclass": "confirmreset"}, # gitk
{"wmclass": "makebranch"}, # gitk
{"wmclass": "maketag"}, # gitk
{"wname": "branchdialog"}, # gitk
{"wname": "pinentry"}, # GPG key password entry
{"wmclass": "ssh-askpass"}, # ssh-askpass
]
)
2020-04-22 05:13:09 +00:00
auto_fullscreen = True
focus_on_window_activation = "smart"
2021-06-15 08:02:44 +00:00
2020-04-22 05:13:09 +00:00
@hook.subscribe.startup_once
def autostart():
2021-06-15 08:02:44 +00:00
home = expanduser("~")
call([home + "/.config/qtile/autostart.sh"])
2020-04-22 05:13:09 +00:00
@hook.subscribe.screen_change
def restart_on_randr(qtile, ev):
2021-06-15 08:02:44 +00:00
qtile.cmd_restart()