qtile_config/config.py

216 lines
6.7 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"
TERM = "st"
keys = [
# 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"], "j", lazy.layout.shuffle_down()),
Key([MOD, "shift"], "k", lazy.layout.shuffle_up()),
# Move between screens
Key([MOD], "l", lazy.to_screen(1)),
Key([MOD], "h", lazy.to_screen(0)),
#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")),
2020-04-22 07:10:02 +00:00
# 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")
),
2020-04-22 05:13:09 +00:00
]
groups = [
Group("", spawn="firefox", layout="Tall", persist=True),
Group("", spawn="thunderbird", layout="verticaltile", persist=True),
Group("", spawn="st tmuxp load enseignement", layout="max", persist=True),
Group("", layout="Wide", persist=True),
Group("", layout="TallLeft", persist=True),
Group("", 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()),
])
2020-04-22 07:24:41 +00:00
groups.append(
ScratchPad("scratchpad", [
DropDown("music", "st 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")),
])
2020-04-22 05:13:09 +00:00
layouts = [
layout.Max(),
layout.VerticalTile(),
layout.MonadTall(name="Tall",
align=1,
ratio=0.5,
),
layout.MonadTall(name="TallLeft",
align=1,
ratio=0.7,
),
layout.MonadWide(name="Wide",
ratio=0.8,
),
]
widget_defaults = dict(
font='DroidSans',
fontsize=12,
padding=3,
)
extension_defaults = widget_defaults.copy()
screens = [
Screen(),
Screen(
bottom=bar.Bar(
[
widget.GroupBox(),
widget.Prompt(),
2020-04-22 07:24:41 +00:00
# widget.WindowName(),
2020-04-22 05:13:09 +00:00
widget.Clock(format='%A %d %B %Y %I:%M %p'),
widget.Systray(),
#widget.CurrentLayoutIcon(scale=0.5),
],
size = 24,
#background = "#000fff",
),
),
]
# 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
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
])
auto_fullscreen = True
focus_on_window_activation = "smart"
@hook.subscribe.startup_once
def autostart():
home = expanduser('~')
call([home + '/.config/qtile/autostart.sh'])
@hook.subscribe.screen_change
def restart_on_randr(qtile, ev):
qtile.cmd_restart()