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

613 lines
24 KiB
Python
Raw Normal View History

2019-01-15 16:27:01 -05:00
# -*- coding: utf-8 -*-
# ____ _____
# | _ \_ _| Derek Taylor (DistroTube)
# | | | || | http://www.youtube.com/c/DistroTube
# | |_| || | http://www.gitlab.com/dwt1/
# |____/ |_|
#
# A customized config.py for Qtile window manager (http://www.qtile.org)
# Modified by Derek Taylor (http://www.gitlab.com/dwt1/ )
#
2019-02-12 13:05:25 -05:00
# The following comments are the copyright and licensing information from the default
# qtile config. Copyright (c) 2010 Aldo Cortesi, 2010, 2014 dequis, 2012 Randall Ma,
# 2012-2014 Tycho Andersen, 2012 Craig Barnes, 2013 horsik, 2013 Tao Sauvage
2019-01-15 16:27:01 -05:00
#
2019-02-12 13:05:25 -05:00
# 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:
2019-01-15 16:27:01 -05:00
#
2019-02-12 13:05:25 -05:00
# The above copyright notice and this permission notice shall be included in all copies
# or substantial portions of the Software.
2019-01-15 16:27:01 -05:00
##### IMPORTS #####
import os
import re
import socket
import subprocess
from libqtile.config import Key, Screen, Group, Drag, Click
from libqtile.command import lazy
from libqtile import layout, bar, widget, hook
from libqtile.widget import Spacer
##### DEFINING SOME WINDOW FUNCTIONS #####
@lazy.function
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)
@lazy.function
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)
##### LAUNCH APPS IN SPECIFIED GROUPS #####
def app_or_group(group, app):
def f(qtile):
if qtile.groupMap[group].windows:
qtile.groupMap[group].cmd_toscreen()
else:
qtile.groupMap[group].cmd_toscreen()
qtile.cmd_spawn(app)
return f
##### KEYBINDINGS #####
def init_keys():
keys = [
Key(
2019-02-10 15:18:26 -05:00
[mod], "Return",
2019-01-15 16:27:01 -05:00
lazy.spawn(myTerm) # Open terminal
),
Key(
2019-02-10 15:18:26 -05:00
[mod], "Tab",
2019-01-15 16:27:01 -05:00
lazy.next_layout() # Toggle through layouts
),
Key(
2019-02-10 15:18:26 -05:00
[mod, "shift"], "c",
2019-01-15 16:27:01 -05:00
lazy.window.kill() # Kill active window
),
Key(
2019-02-10 15:18:26 -05:00
[mod, "shift"], "r",
2019-01-15 16:27:01 -05:00
lazy.restart() # Restart Qtile
),
Key(
2019-02-10 15:18:26 -05:00
[mod, "shift"], "q",
2019-01-15 16:27:01 -05:00
lazy.shutdown() # Shutdown Qtile
),
Key([mod], "i",
lazy.to_screen(2) # Keyboard focus screen(0)
),
Key([mod], "o",
lazy.to_screen(0) # Keyboard focus screen(1)
),
Key([mod], "p",
lazy.to_screen(1) # Keyboard focus screen(2)
),
Key([mod, "control"], "k",
lazy.layout.section_up() # Move up a section in treetab
),
Key([mod, "control"], "j",
lazy.layout.section_down() # Move down a section in treetab
),
# Window controls
Key(
2019-02-10 15:18:26 -05:00
[mod], "k",
2019-01-15 16:27:01 -05:00
lazy.layout.down() # Switch between windows in current stack pane
),
Key(
2019-02-10 15:18:26 -05:00
[mod], "j",
2019-01-15 16:27:01 -05:00
lazy.layout.up() # Switch between windows in current stack pane
),
Key(
2019-02-10 15:18:26 -05:00
[mod, "shift"], "k",
2019-01-15 16:27:01 -05:00
lazy.layout.shuffle_down() # Move windows down in current stack
),
Key(
2019-02-10 15:18:26 -05:00
[mod, "shift"], "j",
2019-01-15 16:27:01 -05:00
lazy.layout.shuffle_up() # Move windows up in current stack
),
Key(
2019-02-10 15:18:26 -05:00
[mod, "shift"], "l",
2019-01-15 16:27:01 -05:00
lazy.layout.grow(), # Grow size of current window (XmonadTall)
lazy.layout.increase_nmaster(), # Increase number in master pane (Tile)
),
Key(
2019-02-10 15:18:26 -05:00
[mod, "shift"], "h",
2019-01-15 16:27:01 -05:00
lazy.layout.shrink(), # Shrink size of current window (XmonadTall)
lazy.layout.decrease_nmaster(), # Decrease number in master pane (Tile)
),
Key(
[mod, "shift"], "Left", # Move window to workspace to the left
window_to_prev_group
),
Key(
[mod, "shift"], "Right", # Move window to workspace to the right
window_to_next_group
),
Key(
2019-02-10 15:18:26 -05:00
[mod], "n",
2019-01-15 16:27:01 -05:00
lazy.layout.normalize() # Restore all windows to default size ratios
),
Key(
2019-02-10 15:18:26 -05:00
[mod], "m",
2019-01-15 16:27:01 -05:00
lazy.layout.maximize() # Toggle a window between minimum and maximum sizes
),
Key(
2019-02-10 15:18:26 -05:00
[mod, "shift"], "KP_Enter",
2019-01-15 16:27:01 -05:00
lazy.window.toggle_floating() # Toggle floating
),
Key(
2019-02-10 15:18:26 -05:00
[mod, "shift"], "space",
2019-01-15 16:27:01 -05:00
lazy.layout.rotate(), # Swap panes of split stack (Stack)
lazy.layout.flip() # Switch which side main pane occupies (XmonadTall)
),
# Stack controls
Key(
2019-02-10 15:18:26 -05:00
[mod], "space",
2019-01-15 16:27:01 -05:00
lazy.layout.next() # Switch window focus to other pane(s) of stack
),
Key(
2019-02-10 15:18:26 -05:00
[mod, "control"], "Return",
2019-01-15 16:27:01 -05:00
lazy.layout.toggle_split() # Toggle between split and unsplit sides of stack
),
# GUI Apps
Key(
2019-02-10 15:18:26 -05:00
[mod], "w",
2019-01-15 16:27:01 -05:00
lazy.function(app_or_group("WWW", "firefox"))
),
Key(
2019-02-10 15:18:26 -05:00
[mod], "f",
2019-01-15 16:27:01 -05:00
lazy.spawn("pcmanfm")
),
Key(
2019-02-10 15:18:26 -05:00
[mod], "g",
2019-01-15 16:27:01 -05:00
lazy.spawn("geany")
),
# Apps Launched with <SUPER> + <KEYPAD 0-9>
Key(
[mod], "KP_Insert", # Keypad 0
# lazy.spawncmd() # Qtile Run Dialog
lazy.spawn("rofi -show run")
),
Key(
[mod], "KP_End", # Keypad 1
lazy.spawn(myTerm+" -e lynx -cfg=~/.lynx.cfg -lss=~/.lynx.lss http://www.distrowatch.com")
# lazy.spawn(myTerm+" -e lynx -cfg=~/.lynx.cfg -lss=~/.lynx.lss http://www.distrowatch.com")
),
Key(
[mod], "KP_Down", # Keypad 2
lazy.spawn(myTerm+" -e sh ./scripts/googler-script.sh")
),
Key(
[mod], "KP_Page_Down", # Keypad 3
2019-02-10 15:18:26 -05:00
lazy.spawn(myTerm+" -e newsboat")
),
2019-01-15 16:27:01 -05:00
Key(
[mod], "KP_Left", # Keypad 4
lazy.spawn(myTerm+" -e rtv")
),
Key(
[mod], "KP_Begin", # Keypad 5
lazy.spawn(myTerm+" -e neomutt")
2019-02-10 15:18:26 -05:00
),
2019-01-15 16:27:01 -05:00
Key(
[mod], "KP_Right", # Keypad 6
lazy.spawn(myTerm+" -e twitch-curses")
),
Key(
[mod], "KP_Home", # Keypad 7
lazy.spawn(myTerm+" -e sh ./scripts/haxor-news.sh")
),
Key(
[mod], "KP_Up", # Keypad 8
lazy.spawn(myTerm+" -e sh ./scripts/toot.sh")
),
Key(
[mod], "KP_Page_Up", # Keypad 9
lazy.spawn(myTerm+" -e sh ./scripts/tig-script.sh")
),
# Apps Launched with <SUPER> + <SHIFT> + <KEYPAD 0-9>
Key(
[mod, "shift"], "KP_End", # Keypad 1
2019-03-09 18:52:05 -05:00
lazy.spawn(myTerm+" -e sh ./.config/vifm/scripts/vifmrun")
2019-01-15 16:27:01 -05:00
),
Key(
[mod, "shift"], "KP_Down", # Keypad 2
lazy.spawn(myTerm+" -e htop")
),
Key(
[mod, "shift"], "KP_Page_Down", # Keypad 3
2019-02-10 15:18:26 -05:00
lazy.spawn(myTerm+" -e cmus")
2019-01-15 16:27:01 -05:00
),
Key(
[mod, "shift"], "KP_Left", # Keypad 4
lazy.spawn(myTerm+" -e irssi")
),
Key(
[mod, "shift"], "KP_Begin", # Keypad 5
lazy.spawn(myTerm+" -e rtorrent")
2019-02-10 15:18:26 -05:00
),
2019-01-15 16:27:01 -05:00
Key(
[mod, "shift"], "KP_Right", # Keypad 6
lazy.spawn(myTerm+" -e youtube-viewer")
),
Key(
[mod, "shift"], "KP_Home", # Keypad 7
lazy.spawn(myTerm+" -e ncpamixer")
),
Key(
[mod, "shift"], "KP_Up", # Keypad 8
lazy.spawn(myTerm+" -e calcurse")
),
Key(
[mod, "shift"], "KP_Page_Up", # Keypad 9
lazy.spawn(myTerm+" -e vim /home/dt/.config/qtile/config.py")
),
# Apps Launched with <SUPER> + <CONTROL> + <KEYPAD 0-9>
Key(
[mod, "control"], "KP_End", # Keypad 1
lazy.spawn(myTerm+" -e htop")
),
Key(
[mod, "control"], "KP_Down", # Keypad 2
lazy.spawn(myTerm+" -e glances")
),
Key(
[mod, "control"], "KP_Page_Down", # Keypad 3
2019-02-10 15:18:26 -05:00
lazy.spawn(myTerm+" -e nmon")
2019-01-15 16:27:01 -05:00
),
Key(
[mod, "control"], "KP_Left", # Keypad 4
lazy.spawn(myTerm+" -e httping -KY --draw-phase localhost")
),
Key(
[mod, "control"], "KP_Begin", # Keypad 5
lazy.spawn(myTerm+" -e s-tui")
2019-02-10 15:18:26 -05:00
),
2019-01-15 16:27:01 -05:00
Key(
[mod, "control"], "KP_Right", # Keypad 6
lazy.spawn(myTerm+" -e sh ./scripts/pianobar.sh")
),
Key(
[mod, "control"], "KP_Home", # Keypad 7
lazy.spawn(myTerm+" -e cmatrix -C cyan")
),
Key(
[mod, "control"], "KP_Up", # Keypad 8
lazy.spawn("sh ./scripts/joplin.sh")
),
Key(
[mod, "control"], "KP_Page_Up", # Keypad 9
lazy.spawn(myTerm+" -e wopr report.xml")
),
]
return keys
##### BAR COLORS #####
def init_colors():
2019-03-09 18:52:05 -05:00
return [["#292D3E", "#292D3E"], # panel background
["#434758", "#434758"], # background for current screen tab
["#D0D0D0", "#D0D0D0"], # font color for group names
["#F07178", "#F07178"], # background color for layout widget
2019-01-15 16:27:01 -05:00
["#000000", "#000000"], # background for other screen tabs
["#AD69AF", "#AD69AF"], # dark green gradiant for other screen tabs
2019-03-09 18:52:05 -05:00
["#C3E88D", "#C3E88D"], # background color for network widget
["#C792EA", "#C792EA"], # background color for pacman widget
["#9CC4FF", "#9CC4FF"], # background color for cmus widget
2019-01-15 16:27:01 -05:00
["#000000", "#000000"], # background color for clock widget
2019-03-09 18:52:05 -05:00
["#434758", "#434758"]] # background color for systray widget
2019-02-10 15:18:26 -05:00
2019-01-15 16:27:01 -05:00
##### GROUPS #####
2019-02-10 15:18:26 -05:00
2019-01-15 16:27:01 -05:00
def init_group_names():
return [("DEV", {'layout': 'max'}),
("WWW", {'layout': 'max'}),
("SYS", {'layout': 'monadtall'}),
("DOC", {'layout': 'monadtall'}),
("VBOX", {'layout': 'floating'}),
("CHAT", {'layout': 'bsp'}),
("MEDIA", {'layout': 'monadtall'}),
("GFX", {'layout': 'floating'})]
2019-02-10 15:18:26 -05:00
2019-01-15 16:27:01 -05:00
def init_groups():
return [Group(name, **kwargs) for name, kwargs in group_names]
##### LAYOUTS #####
def init_floating_layout():
return layout.Floating(border_focus="#3B4022")
2019-02-10 15:18:26 -05:00
2019-01-15 16:27:01 -05:00
def init_layout_theme():
return {"border_width": 2,
"margin": 10,
"border_focus": "AD69AF",
"border_normal": "1D2330"
2019-02-10 15:18:26 -05:00
}
2019-01-15 16:27:01 -05:00
def init_border_args():
return {"border_width": 2}
def init_layouts():
return [layout.Max(**layout_theme),
layout.MonadTall(**layout_theme),
layout.MonadWide(**layout_theme),
layout.Bsp(**layout_theme),
layout.TreeTab(
font = "Ubuntu",
fontsize = 10,
sections = ["FIRST", "SECOND"],
2019-02-10 15:18:26 -05:00
section_fontsize = 11,
bg_color = "141414",
active_bg = "90C435",
active_fg = "000000",
inactive_bg = "384323",
inactive_fg = "a0a0a0",
2019-01-15 16:27:01 -05:00
padding_y = 5,
section_top = 10,
panel_width = 320,
**layout_theme
),
layout.Slice(side="left", width=192, name="gimp", role="gimp-toolbox",
fallback=layout.Slice(side="right", width=256, role="gimp-dock",
fallback=layout.Stack(num_stacks=1, **border_args))),
#layout.Stack(stacks=2, **layout_theme),
#layout.Columns(**layout_theme),
#layout.RatioTile(**layout_theme),
#layout.VerticalTile(**layout_theme),
#layout.Tile(shift_windows=True, **layout_theme),
#layout.Matrix(**layout_theme),
#layout.Zoomy(**layout_theme),
layout.Floating(**layout_theme)]
##### WIDGETS #####
def init_widgets_defaults():
return dict(font="Ubuntu Mono",
fontsize = 11,
padding = 2,
background=colors[2])
def init_widgets_list():
prompt = "{0}@{1}: ".format(os.environ["USER"], socket.gethostname())
widgets_list = [
widget.Sep(
linewidth = 0,
padding = 6,
2019-02-10 15:18:26 -05:00
foreground = colors[2],
2019-01-15 16:27:01 -05:00
background = colors[0]
),
widget.GroupBox(font="Ubuntu Bold",
fontsize = 9,
2019-02-10 15:18:26 -05:00
margin_y = 0,
margin_x = 0,
padding_y = 9,
padding_x = 5,
borderwidth = 1,
active = colors[2],
2019-01-15 16:27:01 -05:00
inactive = colors[2],
rounded = False,
highlight_method = "block",
this_current_screen_border = colors[1],
this_screen_border = colors [4],
other_current_screen_border = colors[0],
other_screen_border = colors[0],
2019-02-10 15:18:26 -05:00
foreground = colors[2],
2019-01-15 16:27:01 -05:00
background = colors[0]
2019-02-10 15:18:26 -05:00
),
2019-01-15 16:27:01 -05:00
widget.Prompt(
2019-02-10 15:18:26 -05:00
prompt=prompt,
2019-01-15 16:27:01 -05:00
font="Ubuntu Mono",
2019-02-10 15:18:26 -05:00
padding=10,
2019-01-15 16:27:01 -05:00
foreground = colors[3],
background = colors[1]
),
widget.Sep(
linewidth = 0,
padding = 10,
2019-02-10 15:18:26 -05:00
foreground = colors[2],
2019-01-15 16:27:01 -05:00
background = colors[0]
),
widget.WindowName(font="Ubuntu",
fontsize = 11,
2019-02-10 15:18:26 -05:00
foreground = colors[5],
2019-01-15 16:27:01 -05:00
background = colors[0],
padding = 6
),
widget.Image(
scale = True,
filename = "~/.config/qtile/bar06.png",
background = colors[6]
),
widget.Systray(
background=colors[10],
padding = 6
),
widget.Image(
scale = True,
filename = "~/.config/qtile/bar02-b.png",
background = colors[6]
),
widget.TextBox(
2019-02-10 15:18:26 -05:00
text="",
foreground=colors[0],
2019-01-15 16:27:01 -05:00
background=colors[6],
padding = 0,
fontsize=14
),
widget.Net(
2019-02-10 15:18:26 -05:00
interface = "enp3s0",
foreground = colors[0],
2019-01-15 16:27:01 -05:00
background = colors[6],
padding = 6
),
widget.Image(
scale = True,
filename = "~/.config/qtile/bar03.png",
background = colors[3]
),
widget.TextBox(
font="Ubuntu Bold",
2019-02-10 15:18:26 -05:00
text="",
2019-01-15 16:27:01 -05:00
padding = 6,
2019-03-09 18:52:05 -05:00
foreground=colors[0],
2019-01-15 16:27:01 -05:00
background=colors[3],
fontsize=14
2019-02-10 15:18:26 -05:00
),
2019-01-15 16:27:01 -05:00
widget.CurrentLayout(
2019-03-09 18:52:05 -05:00
foreground = colors[0],
2019-01-15 16:27:01 -05:00
background = colors[3],
padding = 6
),
widget.Image(
scale = True,
filename = "~/.config/qtile/bar04.png",
background = colors[7]
),
widget.TextBox(
font="Ubuntu Bold",
2019-02-10 15:18:26 -05:00
text="",
2019-01-15 16:27:01 -05:00
padding = 6,
2019-02-10 15:18:26 -05:00
foreground=colors[0],
2019-01-15 16:27:01 -05:00
background=colors[7],
fontsize=14
2019-02-10 15:18:26 -05:00
),
2019-01-15 16:27:01 -05:00
widget.Pacman(
execute = "urxvtc",
update_interval = 1800,
2019-02-10 15:18:26 -05:00
foreground = colors[0],
2019-01-15 16:27:01 -05:00
background = colors[7]
),
widget.TextBox(
2019-02-10 15:18:26 -05:00
text="Updates",
2019-01-15 16:27:01 -05:00
padding = 6,
2019-02-10 15:18:26 -05:00
foreground=colors[0],
2019-01-15 16:27:01 -05:00
background=colors[7]
2019-02-10 15:18:26 -05:00
),
2019-01-15 16:27:01 -05:00
widget.Image(
scale = True,
filename = "~/.config/qtile/bar05.png",
background = colors[8]
),
widget.TextBox(
font="Ubuntu Bold",
2019-02-10 15:18:26 -05:00
text="",
2019-01-15 16:27:01 -05:00
padding = 6,
2019-03-09 18:52:05 -05:00
foreground=colors[0],
2019-01-15 16:27:01 -05:00
background=colors[8],
fontsize=14
2019-02-10 15:18:26 -05:00
),
2019-01-15 16:27:01 -05:00
widget.Cmus(
max_chars = 40,
update_interval = 0.5,
2019-03-09 18:52:05 -05:00
foreground=colors[0],
2019-01-15 16:27:01 -05:00
background = colors[8]
),
widget.Image(
scale = True,
filename = "~/.config/qtile/bar07.png",
background = colors[9]
),
widget.TextBox(
font="Ubuntu Bold",
2019-02-10 15:18:26 -05:00
text=" 🕒",
2019-01-15 16:27:01 -05:00
foreground=colors[2],
2019-02-10 15:18:26 -05:00
background=colors[9],
2019-01-15 16:27:01 -05:00
padding = 6,
fontsize=14
),
widget.Clock(
2019-02-10 15:18:26 -05:00
foreground = colors[2],
2019-01-15 16:27:01 -05:00
background = colors[9],
format="%A, %B %d - %H:%M"
),
widget.Sep(
linewidth = 0,
padding = 6,
2019-02-10 15:18:26 -05:00
foreground = colors[0],
2019-01-15 16:27:01 -05:00
background = colors[9]
),
2019-02-10 15:18:26 -05:00
]
2019-01-15 16:27:01 -05:00
return widgets_list
##### SCREENS ##### (TRIPLE MONITOR SETUP)
def init_widgets_screen1():
widgets_screen1 = init_widgets_list()
return widgets_screen1 # Slicing removes unwanted widgets on Monitors 1,3
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()
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():
2019-03-14 10:46:44 -04:00
return [Screen(top=bar.Bar(widgets=init_widgets_screen1(), opacity=0.95, size=25)),
Screen(top=bar.Bar(widgets=init_widgets_screen2(), opacity=0.95, size=25)),
2019-01-15 16:27:01 -05:00
Screen(top=bar.Bar(widgets=init_widgets_screen1(), opacity=0.95, size=25))]
##### FLOATING WINDOWS #####
@hook.subscribe.client_new
def floating(window):
floating_types = ['notification', 'toolbar', 'splash', 'dialog']
transient = window.window.get_wm_transient_for()
if window.window.get_wm_type() in floating_types or transient:
window.floating = True
def init_mouse():
return [Drag([mod], "Button1", lazy.window.set_position_floating(), # Move floating windows
start=lazy.window.get_position()),
Drag([mod], "Button3", lazy.window.set_size_floating(), # Resize floating windows
start=lazy.window.get_size()),
Click([mod, "shift"], "Button1", lazy.window.bring_to_front())] # Bring floating window to front
##### DEFINING A FEW THINGS #####
if __name__ in ["config", "__main__"]:
mod = "mod4" # Sets mod key to SUPER/WINDOWS
myTerm = "st" # My terminal of choice
2019-01-15 16:27:01 -05:00
myConfig = "/home/dt/.config/qtile/config.py" # Qtile config file location
colors = init_colors()
keys = init_keys()
mouse = init_mouse()
group_names = init_group_names()
groups = init_groups()
floating_layout = init_floating_layout()
layout_theme = init_layout_theme()
border_args = init_border_args()
layouts = init_layouts()
screens = init_screens()
widget_defaults = init_widgets_defaults()
widgets_list = init_widgets_list()
widgets_screen1 = init_widgets_screen1()
widgets_screen2 = init_widgets_screen2()
##### SETS GROUPS KEYBINDINGS #####
for i, (name, kwargs) in enumerate(group_names, 1):
keys.append(Key([mod], str(i), lazy.group[name].toscreen())) # Switch to another group
keys.append(Key([mod, "shift"], str(i), lazy.window.togroup(name))) # Send current window to another group
2019-02-10 15:18:26 -05:00
2019-01-15 16:27:01 -05:00
##### STARTUP APPLICATIONS #####
@hook.subscribe.startup_once
def start_once():
home = os.path.expanduser('~')
subprocess.call([home + '/.config/qtile/autostart.sh'])
##### NEEDED FOR SOME JAVA APPS #####
#wmname = "LG3D"
wmname = "qtile"