dotfiles/qtile/.config/qtile/config.py

268 lines
7.8 KiB
Python

# 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.
from libqtile.config import Key, Screen, Group, Drag, Click, ScratchPad, DropDown
from libqtile.command import lazy
from libqtile import layout, bar, widget, extension, hook
from libqtile.log_utils import logger
from os.path import expanduser
from subprocess import call
from typing import List # noqa: F401
wmname = "???"
MOD = "mod4"
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",
}
keys = [
Key([MOD], "f", lazy.window.toggle_floating()),
# 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()),
# Key([MOD, "shift"], "Tab", lazy.spawncmd()), # circle inside layout
Key([MOD, "shift"], "k", lazy.layout.shuffle_up()),
Key([MOD, "shift"], "j", lazy.layout.shuffle_down()),
# Move between screens
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),
# 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()),
# Screens
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")),
# Change the volume if our keyboard has keys
Key([], "XF86AudioRaiseVolume", lazy.spawn("pamixer -i 2")),
Key([], "XF86AudioLowerVolume", lazy.spawn("pamixer -d 2")),
Key([], "XF86AudioMute", lazy.spawn("pamixer -t")),
]
groups = [
Group("t:", spawn="firefox", layout="Tall", persist=True),
Group("y:", spawn="thunderbird", layout="verticaltile", persist=True),
Group("u:", spawn=TERM+" -e sh -c 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),
]
groups_keys = ["t", "y", "u", "i", "o", "p"]
for i, g in enumerate(groups):
k = groups_keys[i]
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()),
]
)
groups.append(
ScratchPad(
"scratchpad",
[
DropDown(
"music", TERM+" -e sh -c mocp", x=0.25, y=0.25, height=0.5, width=0.5, opacity=0.8
),
],
),
)
keys.extend(
[
Key([MOD], "m", lazy.group["scratchpad"].dropdown_toggle("music")),
]
)
borders = {
"border_focus": colors[13],
"border_normal": colors["BG"],
}
layouts = [
layout.Max(),
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,
),
]
widget_defaults = dict(
font="DroidSans",
fontsize=12,
padding=3,
)
extension_defaults = widget_defaults.copy()
screens = [
Screen(),
Screen(
top=bar.Bar(
[
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],
),
# widget.WindowName(),
widget.Spacer(bar.STRETCH),
widget.Clock(
format="%a %d %B %Y %H:%M",
background=colors[13],
foreground=colors[15],
),
widget.Systray(),
# widget.CurrentLayoutIcon(scale=0.5),
],
size=24,
background=colors["BG"],
),
),
]
# Drag floating layouts.
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_key_binder = None
dgroups_app_rules = [] # type: List
main = None
follow_mouse_focus = True
bring_front_click = False
cursor_warp = False
auto_fullscreen = True
focus_on_window_activation = "smart"
@hook.subscribe.client_new
def floating_dialogs(window):
dialog = window.window.get_wm_type() == 'dialog'
transient = window.window.get_wm_transient_for()
if dialog or transient:
window.floating = True
@hook.subscribe.startup_once
def autostart():
home = expanduser("~")
call([home + "/.config/qtile/autostart.sh"])
@hook.subscribe.screen_change
def restart_on_randr(qtile):
qtile.cmd_restart()