Skip to content

Instantly share code, notes, and snippets.

@pandada8
Created January 6, 2017 16:05
Show Gist options
  • Save pandada8/e1f66993b2b5b3aa8c60ec8767156308 to your computer and use it in GitHub Desktop.
Save pandada8/e1f66993b2b5b3aa8c60ec8767156308 to your computer and use it in GitHub Desktop.
# based on the original config
from libqtile.config import Key, Screen, Group, Drag, Click
from libqtile.command import lazy
from libqtile import layout, bar, widget
from libqtile import hook
from libqtile.log_utils import logger
import os
import subprocess
mod = "mod4"
keys = [
# Switch between windows in current stack pane
Key(
[mod], "k",
lazy.layout.down()
),
Key(
[mod], "j",
lazy.layout.up()
),
# Move windows up or down in current stack
Key(
[mod, "control"], "k",
lazy.layout.shuffle_down()
),
Key(
[mod, "control"], "j",
lazy.layout.shuffle_up()
),
# Switch window focus to other pane(s) of stack
Key(
[mod], "space",
lazy.layout.next()
),
# Swap panes of split stack
Key(
[mod, "shift"], "space",
lazy.layout.rotate()
),
# 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()
),
Key([mod], "Return", lazy.spawn("termite")),
# Toggle between different layouts as defined below
Key([mod], "Tab", lazy.next_layout()),
Key([mod], "w", lazy.window.kill()),
Key([mod, "control"], "r", lazy.restart()),
Key([mod, "control"], "q", lazy.shutdown()),
Key([mod], "r", lazy.spawncmd()),
# todo: bind the volume key
Key(
[], "XF86AudioRaiseVolume",
lazy.spawn("ponymix increase 5%")
),
Key(
[], "XF86AudioLowerVolume",
lazy.spawn("ponymix decrease 5%")
),
Key(
[], "XF86AudioMute",
lazy.spawn("ponymix toggle")
),
Key([mod], "l", lazy.spawn("xscreensaver-command --lock")),
Key([mod], "s", lazy.spawn("deepin-screenshot")),
Key([mod], "t", lazy.window.toggle_floating()),
Key([mod], "f", lazy.window.toggle_fullscreen())
]
groups = [Group(i) for i in "123456789"]
for i in groups:
# mod1 + letter of group = switch to group
keys.append(
Key([mod], i.name, lazy.group[i.name].toscreen())
)
# mod1 + shift + letter of group = switch to & move focused window to group
keys.append(
Key([mod, "shift"], i.name, lazy.window.togroup(i.name))
)
layouts = [
layout.Max(),
layout.Stack(num_stacks=2, autosplit=True),
layout.xmonad.MonadTall(),
layout.tree.TreeTab(),
layout.zoomy.Zoomy()
]
widget_defaults = dict(
font='Source Code Pro',
fontsize=14,
padding=0,
)
def _format(self, down, up):
s = "{:>5}"
return s.format(down)[:5], s.format(up)[:5]
widget.Net._format = _format
def query_cpufreq():
result = os.popen("sudo cat /sys/devices/system/cpu/cpu*/cpufreq/cpuinfo_cur_freq").read().split()
speed = sum([int(i)/len(result) for i in result]) / 1024
return "Freq: {:.0f}M".format(speed)
def gen_screen(tray=False):
bars = [
widget.GroupBox(),
widget.Sep(),
widget.Prompt(),
widget.TaskList(rounded=False, max_title_width=100),
widget.Sep(),
widget.Net(interface="wlp1s0", interval=1),
widget.CurrentLayout(),
widget.Backlight(backlight_name="intel_backlight", interval=1),
widget.Battery(battery="BAT0"),
#widget.YahooWeather(location="Chengdu"),
widget.GenPollText(func=query_cpufreq, interval=1),
widget.CPUGraph(border_width=0, samples=50, width=50, type="line"),
widget.MemoryGraph(border_width=0, samples=50, width=50, type="line"),
widget.NetGraph(interface="wlp1s0", border_width=0, samples=50, width=50, type="line"),
widget.HDDBusyGraph(border_width=0, samples=30, type="line", width=50),
#widget.Notify(),
widget.Clock(format='%m/%d(%w) %H:%M:%S'),
]
if tray:
bars.append(widget.Systray())
return Screen( top=bar.Bar(bars, 24) )
# 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 = []
follow_mouse_focus = True
bring_front_click = False
cursor_warp = False
floating_layout = layout.Floating()
auto_fullscreen = True
# XXX: Gasp! We're lying here. In fact, nobody really uses or cares about this
# string besides java UI toolkits; you can see several discussions on the
# mailing lists, github issues, and other WM documentation that suggest setting
# this string if your java app doesn't work correctly. We may as well just lie
# and say that we're a working one by default.
#
# We choose LG3D to maximize irony: it is a 3D non-reparenting WM written in
# java that happens to be on java's whitelist.
wmname = "LG3D"
@hook.subscribe.startup_once
def autostart():
home = os.path.expanduser('~')
subprocess.call([home + '/.config/qtile/autostart.sh'])
@hook.subscribe.screen_change
def restart_on_randr(qtile, ev):
qtile.cmd_restart()
@hook.subscribe.client_new
def vue_tools(window):
if((window.window.get_wm_class() == ('sun-awt-X11-XWindowPeer',
'tufts-vue-VUE')
and window.window.get_wm_hints()['window_group'] != 0)
or (window.window.get_wm_class() == ('sun-awt-X11-XDialogPeer',
'tufts-vue-VUE'))):
window.floating = True
window.x = (1920 - window.width) /2
window.y = (1080 - window.height) / 2
@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
screens = []
def main(qtile):
for n, i in enumerate(qtile.conn.pseudoscreens):
screens.append(gen_screen(n == 0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment