Browse Source

Add qtile config

Ian Adam Naval 5 years ago
parent
commit
f9135409a4
1 changed files with 213 additions and 0 deletions
  1. 213
    0
      qtile/qtile.configdir/config.py

+ 213
- 0
qtile/qtile.configdir/config.py View File

@@ -0,0 +1,213 @@
1
+from libqtile.config import Key, Screen, Group, Drag, Click
2
+from libqtile.command import lazy
3
+from libqtile import layout, bar, widget, hook
4
+
5
+
6
+mod = "mod4"
7
+keys = [
8
+    # Switch between windows in current stack pane
9
+    Key([mod], "h", lazy.layout.left()),
10
+    Key([mod], "l", lazy.layout.right()),
11
+    Key([mod], "j", lazy.layout.down()),
12
+    Key([mod], "k", lazy.layout.up()),
13
+    Key([mod, "shift"], "h", lazy.layout.swap_left()),
14
+    Key([mod, "shift"], "l", lazy.layout.swap_right()),
15
+    Key([mod, "shift"], "j", lazy.layout.shuffle_down()),
16
+    Key([mod, "shift"], "k", lazy.layout.shuffle_up()),
17
+    Key([mod], "i", lazy.layout.grow()),
18
+    Key([mod], "m", lazy.layout.shrink()),
19
+    Key([mod], "n", lazy.layout.normalize()),
20
+    Key([mod], "o", lazy.layout.maximize()),
21
+    Key([mod, "shift"], "space", lazy.layout.flip()),
22
+
23
+    # Toggle floating
24
+    Key([mod], "space", lazy.window.toggle_floating()),
25
+
26
+    # Toggle fullscreen
27
+    Key([mod], "f", lazy.window.toggle_fullscreen()),
28
+
29
+    # Launch programs
30
+    Key([mod], "Return", lazy.spawn("urxvt")),
31
+    Key([mod], "d", lazy.spawn("rofi -show run")),
32
+
33
+    Key([], "XF86AudioMute", lazy.spawn("pactl set-sink-mute 1 toggle")),
34
+    Key([], "XF86AudioMicMute", lazy.spawn("amixer -c 1 set Capture toggle")),
35
+    Key([], "XF86Display", lazy.spawn("arandr")),
36
+    Key([], "XF86MonBrightnessUp", lazy.spawn("xbacklight -inc 5")),
37
+    Key([], "XF86MonBrightnessDown", lazy.spawn("xbacklight -dec 5")),
38
+    Key(["shift"], "XF86MonBrightnessUp", lazy.spawn("xbacklight -inc 1")),
39
+    Key(["shift"], "XF86MonBrightnessDown", lazy.spawn("xbacklight -dec 1")),
40
+    Key([], "XF86Tools", lazy.spawn("rofi -show ssh")),
41
+    Key([], "XF86Search", lazy.spawn("rofi -show fm -switchers 'fm:fmenu-rofi'")),
42
+    Key([], "XF86LaunchA", lazy.spawn("rofi -show window")),
43
+    Key([], "XF86Explorer", lazy.spawn("rofi -show run")),
44
+    Key([], "Print", lazy.spawn("teiler")),
45
+
46
+    # Toggle between different layouts as defined below
47
+    Key([mod], "Tab", lazy.next_layout()),
48
+
49
+    # Close current window
50
+    Key([mod], "q", lazy.window.kill()),
51
+
52
+    Key([mod, "shift"], "r", lazy.restart()),
53
+    Key([mod, "control"], "q", lazy.shutdown()),
54
+    Key([mod], "r", lazy.spawncmd()),
55
+]
56
+
57
+labels = list("1234567890")
58
+groups = [Group(i) for i in labels]
59
+
60
+for group in groups:
61
+    # mod1 + letter of group = switch to group
62
+    keys.append(
63
+        Key([mod], group.name, lazy.group[group.name].toscreen())
64
+    )
65
+
66
+    # mod1 + shift + letter of group = switch to & move focused window to group
67
+    keys.append(
68
+        Key([mod, "shift"], group.name, lazy.window.togroup(group.name))
69
+    )
70
+
71
+
72
+layout_theme = {
73
+    'border_focus': "#215578",
74
+    'border_normal': "#252525",
75
+    'ratio': 0.618,
76
+    'border_width': 1,
77
+    'margin': 0,
78
+}
79
+
80
+layouts = [
81
+    layout.MonadTall(**layout_theme),
82
+    layout.Max(**layout_theme),
83
+    layout.RatioTile(**layout_theme),
84
+]
85
+
86
+widget_defaults = dict(
87
+    rounded=False,
88
+    font='Meslo LG S DZ',
89
+    fontsize=12,
90
+    padding=3,
91
+    borderwidth=2,
92
+    opacity=0.2,
93
+)
94
+
95
+
96
+class Battery(widget.Battery):
97
+
98
+    low_percentage = 0.1
99
+    not_charging_format = "{percent:2.01%}{char}"
100
+    format = not_charging_format + " @{power:.1f}W ({hour:d}:{min:02d})"
101
+    full_char = '='
102
+    charge_char = '↑'
103
+    discharge_char = '↓'
104
+
105
+    def _get_text(self):
106
+        info = self._get_info()
107
+        if info is False:
108
+            return 'Error'
109
+
110
+        percent = info['now'] / info['full']
111
+
112
+        # Set the charging character
113
+        try:
114
+            # hide the text when it's higher than threshold, but still
115
+            # display `full` when the battery is fully charged.
116
+            if self.hide_threshold and \
117
+                    info['now'] / info['full'] * 100.0 >= \
118
+                    self.hide_threshold and \
119
+                    info['stat'] != 'Full':
120
+                return ''
121
+            elif info['stat'] == 'Discharging':
122
+                char = self.discharge_char
123
+                time = info['now'] / info['power']
124
+            elif info['stat'] == 'Charging':
125
+                char = self.charge_char
126
+                time = (info['full'] - info['now']) / info['power']
127
+            else:
128
+                char = self.full_char
129
+                return self.not_charging_format.format(
130
+                    percent=percent,
131
+                    char=char)
132
+        except ZeroDivisionError:
133
+            time = -1
134
+
135
+        # Calculate the battery percentage and time left
136
+        if time >= 0:
137
+            hour = int(time)
138
+            min = int(time * 60) % 60
139
+        else:
140
+            hour = -1
141
+            min = -1
142
+        if info['stat'] == 'Discharging' and percent < self.low_percentage:
143
+            self.layout.colour = self.low_foreground
144
+        else:
145
+            self.layout.colour = self.foreground
146
+
147
+        return self.format.format(
148
+            power=info['power'] / 1000000,
149
+            char=char,
150
+            percent=percent,
151
+            hour=hour,
152
+            min=min
153
+        )
154
+
155
+
156
+sep = lambda: widget.Sep(linewidth=0, padding=8)
157
+screens = [
158
+    Screen(
159
+        top=bar.Bar(
160
+            [
161
+                widget.GroupBox(),
162
+                widget.Prompt(),
163
+                widget.TaskList(max_title_width=1920),
164
+                widget.TextBox("♪"),
165
+                widget.Volume(),
166
+                sep(),
167
+                widget.TextBox("⚡"),
168
+                Battery(battery_name="BAT0"),
169
+                sep(),
170
+                widget.TextBox("⚡"),
171
+                Battery(battery_name="BAT1"),
172
+                sep(),
173
+                widget.CPUGraph(),
174
+                widget.MemoryGraph(),
175
+                sep(),
176
+                widget.TextBox(""),
177
+                widget.Clock(format='%a %Y-%m-%d %H:%M:%S'),
178
+                sep(),
179
+                widget.Systray(),
180
+            ],
181
+            26,
182
+            background="#252525"
183
+        ),
184
+    ),
185
+]
186
+
187
+# Drag floating layouts.
188
+mouse = [
189
+    Drag([mod], "Button1", lazy.window.set_position_floating(),
190
+        start=lazy.window.get_position()),
191
+    Drag([mod], "Button3", lazy.window.set_size_floating(),
192
+        start=lazy.window.get_size()),
193
+    Click([mod], "Button2", lazy.window.bring_to_front())
194
+]
195
+
196
+dgroups_key_binder = None
197
+dgroups_app_rules = []
198
+main = None
199
+follow_mouse_focus = True
200
+bring_front_click = True
201
+cursor_warp = False
202
+floating_layout = layout.Floating(border_focus="#215578")
203
+auto_fullscreen = True
204
+
205
+# XXX: Gasp! We're lying here. In fact, nobody really uses or cares about this
206
+# string besides java UI toolkits; you can see several discussions on the
207
+# mailing lists, github issues, and other WM documentation that suggest setting
208
+# this string if your java app doesn't work correctly. We may as well just lie
209
+# and say that we're a working one by default.
210
+#
211
+# We choose LG3D to maximize irony: it is a 3D non-reparenting WM written in
212
+# java that happens to be on java's whitelist.
213
+wmname = "LG3D"

Loading…
Cancel
Save