Skip to content

Instantly share code, notes, and snippets.

@brandonwillard
Last active June 27, 2016 03:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brandonwillard/cffed6c9900515afa64a to your computer and use it in GitHub Desktop.
Save brandonwillard/cffed6c9900515afa64a to your computer and use it in GitHub Desktop.
qtile config
# -*- coding: utf-8 -*-
#
# Check out org.mate.panel in dconf. It has a `.toplevels`
# section with `bottom` and `top` entries that provide the
# mate-panel dimensions and screen id.
# Seems like those could be read and used by qtile.
#
#
import subprocess
import os
from libqtile.command import lazy
from libqtile import layout, bar, widget, hook
from libqtile.config import Key, Group
from libqtile.manager import Click, Drag, Screen
#mod = "mod4"
# <alt> key
mod = "mod1"
term = "mate-terminal"
def move_window_to_screen(screen):
def cmd(qtile):
w = qtile.currentWindow
# XXX: strange behaviour - w.focus() doesn't work
# if toScreen is called after togroup...
qtile.toScreen(screen)
if w is not None:
w.togroup(qtile.screens[screen].group.name)
return cmd
def init_groups():
def _inner(number):
keys.append(Key([mod], number, lazy.group[number].toscreen()))
keys.append(Key([mod, "shift"], number, lazy.window.togroup(number)))
return Group(number)
return [_inner(str(i)) for i in range(1, 10)]
def init_floating_layout():
floating_layout = layout.floating.Floating(
float_rules=[{'wmclass': x} for x in (
'Download', 'dropbox', 'file_progress', "notification", "toolbar", "splash", "dialog"
)])
return floating_layout
def init_layouts():
return [
# , layout.Tile(ratio=0.5, border_focus=colors[1])
layout.MonadTall(), layout.Max(), floating_layout
]
def init_mouse():
return [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())]
def init_colors():
return [["7cfcff", "#00afff"], # cyan gradiant
["#323335", "#525355"], # grey gradiant
["#040404", "#111113"]] # darker grey gradiant
def init_keys():
keys = [
# Switch between windows in current stack pane
# , Key( [mod, "shift"], "Return", lazy.layout.toggle_split())
# Toggle between different layouts as defined below
Key([mod], "k", lazy.layout.down()), Key(
[mod], "j", lazy.layout.up()) # from
# http://git.upsilon.cc/?p=gnome-awesome-applet.git;a=blob_plain;f=lua/gnome-applet.lua;hb=HEAD
# , Key([mod], "p", lazy.spawn("trigger-panel-run-dialog"))
# , Key([mod], "p", lazy.spawncmd())
, Key([mod], "Return", lazy.spawn(term)), Key([mod], "Tab",
lazy.next_layout()),
Key([mod, 'shift'], "c", lazy.window.kill()), Key([mod,
"control"],
"r",
lazy.restart())
, Key([mod, "control"], "q", lazy.shutdown()) # xmonad setup
, Key([mod], "p", lazy.spawn("dmenu_run")), Key([mod, 'control'], 'l',
lazy.spawn('mate-screensaver-command')),
Key([mod, 'control'], 'q', lazy.spawn('mate-session-save --kill')),
Key([mod, "shift"], "k", lazy.layout.shuffle_down()), Key([mod,
"shift"],
"j",
lazy.layout.shuffle_up()),
Key([mod], "i", lazy.layout.grow()), Key([mod], "m",
lazy.layout.shrink()),
Key([mod], "h", lazy.layout.grow_main()), Key([mod], "l",
lazy.layout.shrink_main()),
Key([mod], "n", lazy.layout.normalize()), Key([mod], "o",
lazy.layout.maximize()),
Key([mod, "shift"], "space", lazy.layout.flip()), Key([mod], "v",
lazy.window.toggle_floating()),
Key([mod], "F12", lazy.window.toggle_fullscreen()), Key([mod], "w",
lazy.to_screen(0)),
Key([mod, "shift"], "w", lazy.function(move_window_to_screen(0))),
Key([mod], "e", lazy.to_screen(1)), Key([mod, "shift"], "e",
lazy.function(move_window_to_screen(1)))
# layout-conditional keys
#, Key([mod, "shift"], "h", lazy.layout.client_to_previous().when('stack')
]
return keys
keys = init_keys()
@hook.subscribe.startup
def dbus_register():
x = os.environ.get('DESKTOP_AUTOSTART_ID', '0')
subprocess.call(['dbus-send',
'--session',
'--print-reply=literal',
'--dest=org.gnome.SessionManager',
'/org/gnome/SessionManager',
'org.gnome.SessionManager.RegisterClient',
'string:qtile',
'string:' + x])
# @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 or
# window.window.get_name() == "Execute program feat. completion" or
# window.window.get_wm_class() == "InputOutput" :
# window.floating = True
@hook.subscribe.screen_change
def restart_on_randr(qtile, ev):
#qtile.log.debug('screen change event: %s' % ev)
# restrict pen to laptop monitor dimensions
# xrandr_state = subprocess.check_output(['xrandr'])
subprocess.call(['xsetwacom', 'set', 'Wacom ISDv4 EC Pen stylus',
'MapToOutput', 'eDP1'])
subprocess.call(['xsetwacom', 'set', 'ELAN Touchscreen',
'MapToOutput', 'eDP1'])
#qtile.log.debug('setting wacom stylus to map to eDP1')
qtile.cmd_restart()
def init_screens():
return [
# Screen(top=bar.Gap(24), bottom=bar.Gap(24))
Screen(bottom=bar.Bar(
[widget.GroupBox(), widget.Prompt() # , widget.Spacer()
, widget.Systray() # , widget.Sep(padding=0, height_percent=100)
, widget.Spacer() # , widget.Sep(padding=0, height_percent=100)
, widget.CPUGraph()
, widget.MemoryGraph(graph_color="#1a7a1b"
, fill_color="#2bca2d")
, widget.NetGraph(graph_color="#bdb300"
, fill_color="#fff75c")
, widget.CurrentScreen(), widget.Clock(format='%Y-%m-%d %a %I:%M %p')
], 24)), Screen()
]
if __name__ in ["config", "__main__"]:
# def main(qtile):
# detect_screens(qtile)
follow_mouse_focus = False
focus_on_window_activation = "smart"
colors = init_colors()
keys = init_keys()
mouse = init_mouse()
groups = init_groups()
floating_layout = init_floating_layout()
layouts = init_layouts()
screens = init_screens()
#widget_defaults = ""
#widget_defaults = init_widgets_defaults()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment