Commits

Dimitris Leventeas committed 3272744

Init.

Comments (0)

Files changed (1)

+from libqtile.manager import Key, Screen, Group, Click, Drag
+from libqtile.command import lazy
+from libqtile import layout, bar, widget, hook
+
+import os
+import re
+import subprocess
+
+
+modkey = "mod4"
+altkey = "mod1"
+
+keys = [
+    # windows style alt-tab/alt-shift-tab
+    Key([altkey], "Tab", lazy.layout.down()),
+    Key([altkey, "shift"], "Tab", lazy.layout.up()),
+    Key([modkey], "k", lazy.group.next_window()),
+    Key([modkey], "j", lazy.group.prev_window()),
+    # kill current window
+    Key([altkey], "F4", lazy.window.kill()),
+    Key([modkey, "control"], "k", lazy.layout.shuffle_down()),
+    Key([modkey, "control"], "j", lazy.layout.shuffle_up()),
+    # change layout
+    Key([modkey], "space", lazy.nextlayout()),
+    # toggle floating
+    Key([modkey], "f", lazy.window.toggle_floating()),
+    # fullscreen
+    Key([modkey], "F12", lazy.window.toggle_fullscreen()),
+    # switch master window
+    Key([modkey, "shift"], "space", lazy.layout.rotate()),
+    Key([modkey, "shift"], "Return", lazy.layout.toggle_split()),
+    # cycle to previous group
+    Key([modkey], "Left", lazy.group.prevgroup()),
+    # cycle to next group
+    Key([modkey], "Right", lazy.group.nextgroup()),
+
+    Key([modkey, "shift"], "q", lazy.shutdown()),
+    Key([modkey, "shift"], "r", lazy.restart()),
+
+
+    # custom apps
+    Key([modkey], "Return", lazy.spawn("terminator")),
+    Key([modkey], "e", lazy.spawn("terminator -e ranger")),
+    Key([modkey], "b", lazy.spawn("firefox")),
+    Key([altkey], "F1", lazy.spawn("dmenu_run")),
+    Key([modkey], "r", lazy.spawncmd(prompt='')),
+    Key([altkey], "F2", lazy.spawncmd(prompt='')),
+    Key([], "Print", lazy.spawn("scrto -e 'mv $f ~/screenshots/ 2>/dev/null'")),
+    # Sound
+    Key([], "XF86AudioMute", lazy.spawn("amixer -q set Master toggle")),
+    Key([], "XF86AudioLowerVolume", lazy.spawn("amixer -c 0 sset Master 1- unmute")),
+    Key([], "XF86AudioRaiseVolume", lazy.spawn("amixer -c 0 sset Master 1+ unmute")),
+]
+
+groups = [
+    Group("main", layout='max'),
+    Group("extra", layout='tile'),
+    Group("term", layout='tile'),
+    Group("nav"),
+    Group("web", layout='max')
+]
+
+for i, g in enumerate(groups):
+    keys.append(
+        Key([modkey], str(i + 1), lazy.group[g.name].toscreen())
+    )
+    keys.append(
+        Key([modkey, "shift"], str(i + 1), lazy.window.togroup(g.name))
+    )
+
+layouts = [
+    layout.Max(),
+    layout.Stack(stacks=2),
+    layout.Tile(ratio=0.5)
+]
+
+screens = [
+    Screen(
+        top = bar.Bar(
+                    [
+                        widget.GroupBox(fontsize=12, margin_y=-2, margin_x=1),
+                        widget.Prompt(cursorblink=0),
+                        widget.WindowName(fontsize=12),
+                        #widget.TextBox("default", "default config"),
+                        widget.Systray(),
+                        widget.Volume(),
+                        widget.Battery(battery_name="BAT1", update_delay=60),
+                        #widget.BatteryIcon(),
+                        widget.Clock('%a %d.%m %I:%M %p'),
+                        widget.CurrentLayout(fontsize=10),
+                    ],
+                    18,
+                ),
+    ),
+]
+
+main = None
+follow_mouse_focus = True
+cursor_warp = False
+floating_layout = layout.Floating()
+
+mouse = [
+    Drag([modkey], "Button1", lazy.window.set_position_floating(),
+        start=lazy.window.get_position()),
+    Drag([modkey], "Button3", lazy.window.set_size_floating(),
+        start=lazy.window.get_size()),
+    Click([modkey], "Button2", lazy.window.bring_to_front())
+]
+#mouse = ()
+
+
+def mail():
+    output = "N/A"
+    try:
+        output = subprocess.check_output(["/home/myle/scripts/unread.py"])
+    except subprocess.CalledProcessError:
+        pass
+
+    return output
+
+
+@hook.subscribe.client_new
+def dialogs(window):
+    if(window.window.get_wm_type() == 'dialog'
+        or window.window.get_wm_transient_for()):
+        window.floating = True
+
+
+@hook.subscribe.startup
+def keyboard():
+    os.system('setxkbmap -option "grp:switch,grp:alt_shift_toggle,grp_led:scroll" -layout "us,gr"')
+
+
+def is_running(process):
+    s = subprocess.Popen(["ps", "axw"], stdout=subprocess.PIPE)
+    for x in s.stdout:
+        if re.search(process, x):
+            return True
+    return False
+
+
+def execute_once(process):
+    if not is_running(process):
+        return subprocess.Popen([process])
+
+
+@hook.subscribe.startup
+def startup():
+    execute_once("parcellite")
+    execute_once("nm-applet")
+    execute_once("dropboxd")
+
+
+def show_shortcuts():
+    key_map = {"mod1": "alt", "mod4": "super"}
+    shortcuts_path = "{0}/{1}".format(os.environ["HOME"], "qtile_shortcuts")
+    shortcuts = open("{0}".format(shortcuts_path), 'w')
+    shortcuts.write("{0:30}| {1:50}\n".format("KEYS COMBINATION", "COMMAND"))
+    shortcuts.write("{0:80}\n".format("=" * 80))
+    for key in keys:
+        key_comb = ""
+        for modifier in key.modifiers:
+            key_comb += key_map.get(modifier, modifier) + "+"
+        key_comb += key.key
+        shortcuts.write("{0:30}| ".format(key_comb))
+        cmd_str = ""
+        for command in key.commands:
+            cmd_str += command.name + " "
+            for arg in command.args:
+                cmd_str += "{0} ".format(repr(arg))
+        shortcuts.write("{0:50}\n".format(cmd_str))
+        shortcuts.write("{0:80}\n".format("-" * 80))
+    shortcuts.close()
+    return lazy.spawn("xterm -wf -e less {0}".format(shortcuts_path))
+
+keys.append(Key([modkey], "F1", show_shortcuts()))