Created
October 29, 2012 12:26
-
-
Save mictee/3973255 to your computer and use it in GitHub Desktop.
qtile config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from libqtile.manager import Key, Screen, Group | |
from libqtile.command import lazy | |
from libqtile import layout, bar, widget, hook | |
import subprocess | |
import shlex | |
alt = 'mod1' | |
windowskey = 'mod4' | |
active_colour = '9bff8b' | |
inactive_colour = '6db462' | |
background_colour = '000000' | |
keys = [ | |
# Key bindings for window management | |
Key([windowskey], "Tab", lazy.layout.down()), | |
Key([windowskey, "shift"], "Tab", lazy.layout.up()), | |
Key([windowskey, "shift"], "k", lazy.layout.shuffle_down()), | |
Key([windowskey, "shift"], "j", lazy.layout.shuffle_up()), | |
Key([windowskey, alt], "Tab", lazy.nextlayout()), | |
Key([windowskey], "w", lazy.window.kill()), | |
Key([windowskey], "space", lazy.layout.next()), | |
Key([alt, "shift"], "space", lazy.layout.rotate()), | |
Key([alt, "shift"], "Return", lazy.layout.toggle_split()), | |
Key([windowskey], "z", lazy.to_screen(1)), | |
Key([windowskey], "x", lazy.to_screen(0)), | |
# Key bindings for apps | |
Key([windowskey, alt], "c", lazy.spawn("terminator")), | |
Key([windowskey, alt], "f", lazy.spawn("firefox -P default")), | |
Key([windowskey, alt], "t", lazy.spawn("thunderbird")), | |
Key([windowskey, alt], "i", lazy.spawn("wikidpad")), | |
Key([windowskey, alt], "v", lazy.spawn("vlc")), | |
Key([windowskey, alt], "m", lazy.spawn("maltego")), | |
Key([windowskey, alt], "k", lazy.spawn("krusader")), | |
Key([windowskey, alt], "g", lazy.spawn("gedit")), | |
# Keys for special events | |
Key([windowskey], "l", lazy.spawn("xscreensaver-command -lock")), | |
Key([], "XF86AudioRaiseVolume", lazy.spawn("amixer -c 0 -q set Master 2dB+")), | |
Key([], "XF86AudioLowerVolume", lazy.spawn("amixer -c 0 -q set Master 2dB-")), | |
Key([], "XF86AudioMute", lazy.spawn("amixer -c 0 -q set Master toggle")), | |
Key([windowskey], "d", lazy.spawncmd("ddg: ", "awesomeprompt", "firefox 'https://duckduckgo.com/?q=%s'", None)), | |
# Not using the globals "windowskey" or "mod" here, to prevent that this gets assigned the Windows-key. | |
# The Windows-key mapping may get lost under some circumstances. | |
Key(["mod1", "shift"], "r", lazy.restart()), | |
Key(["mod1", "shift"], "q", lazy.shutdown()), | |
] | |
groups = [ | |
Group("a"), | |
Group("b"), | |
Group("console"), | |
Group("mail"), | |
Group("vlc"), | |
Group("rdp"), | |
] | |
# Automatically assign each group some hotkey combinations with the first character of their name. Caution: watch the first character of each name. | |
for i in groups: | |
keys.append( | |
Key([windowskey], i.name[0], lazy.group[i.name].toscreen()) | |
) | |
keys.append( | |
Key([windowskey, "shift"], i.name[0], lazy.window.togroup(i.name)) | |
) | |
layouts = [ | |
layout.Max(), | |
layout.Stack(stacks=2) | |
] | |
screens = [ | |
Screen( | |
bottom = bar.Bar( | |
[ | |
widget.GroupBox(this_current_screen_border=active_colour, | |
this_screen_border=inactive_colour, | |
margin_x=2, | |
margin_y=2, | |
padding=3), | |
#widget.WindowName(), | |
widget.TextBox('shoutbox', | |
'', | |
fontsize=12, | |
foreground=inactive_colour), | |
widget.Spacer(width=bar.STRETCH), | |
widget.Prompt(fontsize=12, | |
name='awesomeprompt', | |
foreground=active_colour, | |
cursorblink=0.5), | |
widget.Systray(), | |
widget.Clock('%Y-%m-%d %a %H:%M', | |
fontsize=12, | |
foreground=inactive_colour), | |
], | |
24, | |
), | |
), | |
Screen( | |
bottom = bar.Bar( | |
[ | |
widget.GroupBox(this_current_screen_border=active_colour, | |
this_screen_border=inactive_colour, | |
margin_x=2, | |
margin_y=2, | |
padding=3), | |
#widget.WindowName(), | |
widget.CPUGraph(graph_color=inactive_colour, | |
border_color=background_colour, | |
type="line", | |
line_width=2, | |
width=bar.STRETCH) | |
], | |
24, | |
), | |
), | |
] | |
#@hook.subscribe.client_new | |
def dialogs(window): | |
try: | |
if(window.window.get_wm_type() == 'dialog' or window.window.get_wm_transient_for() | |
or window.window.get_wm_class()[0] == 'Dialog'): | |
window.floating = True # TODO: make dialogs go to the front, and stay there. I think. | |
window.bring_to_front() | |
pass | |
except: | |
pass # TODO: handle errors. LibreOffice makes qtile crash here | |
@hook.subscribe.client_new | |
def launchy_yakuake(window): | |
try: | |
if(window.window.get_wm_class()[1] == 'Launchy' | |
or window.window.get_wm_class()[1] == 'Yakuake'): | |
to_screen(0) | |
window.floating = True | |
window.togroup(currentGroup().name) | |
window.bring_to_front() | |
except: | |
pass # TODO: handle errors. LibreOffice makes qtile crash here | |
@hook.subscribe.client_new | |
def grouper(window): | |
try: | |
print('NEW WINDOW! Class: ' + str(window.window.get_wm_class())) | |
if(window.window.get_wm_class()[1] == 'Terminator'): | |
window.togroup('console') | |
elif(window.window.get_wm_class()[1] == 'WikidPad.py'): | |
window.togroup('b') | |
elif(window.window.get_wm_class()[1] == 'Firefox'): | |
window.togroup('a') | |
elif(window.window.get_wm_class()[1] == 'Thunderbird'): | |
window.togroup('mail') | |
elif(window.window.get_wm_class()[1] == 'Vlc'): | |
window.togroup('vlc') | |
elif(window.window.get_wm_class()[1] == 'xfreerdp'): | |
window.togroup('rdp') | |
except: | |
pass # TODO: handle errors. LibreOffice makes qtile crash here | |
def runone(cmdline): | |
"""Check if another instance of an app is running, otherwise start a new one.""" | |
cmd = shlex.split(cmdline) | |
try: | |
subprocess.check_call(['pgrep', cmd[0]]) | |
except: | |
run(cmdline) | |
def run(cmdline): | |
subprocess.Popen(shlex.split(cmdline)) | |
@hook.subscribe.startup | |
def startup(): | |
""" | |
Run after qtile is started | |
""" | |
run('xrandr --output DP3 --off --output DP2 --off --output DP1 --off --output HDMI3 --off --output HDMI2 --off --output HDMI1 --off --output LVDS1 --mode 1366x768 --pos 1280x144 --rotate normal --output VGA1 --mode 1280x1024 --pos 0x0 --rotate normal') | |
runone('firefox -P default') | |
runone('wikidpad') | |
runone('thunderbird') | |
runone('terminator') | |
runone('launchy') | |
runone('yakuake') | |
main = None | |
follow_mouse_focus = True | |
cursor_warp = False | |
floating_layout = layout.Floating() | |
mouse = () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment