-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubtle.rb
541 lines (492 loc) · 16.3 KB
/
subtle.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
# = Subtle configuration
# == Options
#
# Window move/resize steps in pixel per keypress
set :increase_step, 5
# Window screen border snapping
set :border_snap, 10
# Default starting gravity for windows. Comment out to use gravity of
# currently active client
set :default_gravity, :center
# Make dialog windows urgent and draw focus
set :urgent_dialogs, false
# Honor resize size hints globally
set :honor_size_hints, false
# Enable gravity tiling for all gravities
set :gravity_tiling, false
# Enable click-to-focus focus model
set :click_to_focus, false
# == Ideas
#
# WindowNext, so I can cycle all windows on screen
# WindowNext+, so I can cycle all windows in WM
# ViewNextPopulated, go to next view *that isn't empty*
# and in general, hide views with no entries.
#
# Some way of changing bar contents based on context e.g no clock sublet on 'term' view
#
# == Screen
#
# Generally subtle comes with two panels per screen, one on the top and one at
# the bottom. Each panel can be configured with different panel items and
# sublets screen wise. The default config uses top panel on the first screen
# only, it's up to the user to enable the bottom panel or disable either one
# or both.
# Following items are available for the panels:
# [*:views*] List of views with buttons
# [*:title*] Title of the current active window
# [*:tray*] Systray icons (Can be used only once)
# [*:keychain*] Display current chain (Can be used only once)
# [*:sublets*] Catch-all for installed sublets
# [*:sublet*] Name of a sublet for direct placement
# [*:spacer*] Variable spacer (free width / count of spacers)
# [*:center*] Enclose items with :center to center them on the panel
# [*:separator*] Insert separator
screen 1 do
top [ :title, :spacer, :views, :clock2 ]
end
#screen 2 do
# top [ :title, :spacer, :views ]
#end
sublet :clock2 do
interval 60
time_format "%l:%M %P "
date_format "%a %d %b "
end
#sublet :netchart do
# interval 10
# device usb0
#end
# == Styles
# Styles define various properties of styleable items in a CSS-like syntax.
#
# If no background color is given no color will be set. This will ensure a
# custom background pixmap won't be overwritten.
# Style for all style elements
style :all do
# background "#202020"
# icon "#757575"
# border "#303030", 0
# padding 0, 3
#font "-*-*-*-*-*-*-14-*-*-*-*-*-*-*"
font "xft:sans-14"
end
# Style for the all views
style :views do
padding 10, 5, 5, 5
foreground "#757575"
style :focus do
foreground "#fecf35"
end
style :urgent do
foreground "#ff9800"
end
style :occupied do
foreground "#b8b8b8"
end
# style :unoccupied do
# foreground "#757575"
# end
end
# Style for sublets
style :sublets do
padding 10, 5, 5, 20
foreground "#fecf35"
end
# Style for separator
style :separator do
foreground "#757575"
separator "|"
end
# Style for focus window title
style :title do
padding 10, 5, 5, 20
foreground "#fecf35"
end
# Style for active/inactive windows
style :clients do
active "#303030", 4
inactive "#202020", 4
margin 2,6,4,6
width 100
end
# Style for subtle
style :subtle do
margin 0, 0, 0, 0
# panel "#202020"
# background "#3d3d3d"
# stipple "#757575"
end
# == Gravities
#
# Gravities are predefined sizes a window can be set to. There are several ways
# to set a certain gravity, most convenient is to define a gravity via a tag or
# change them during runtime via grab. Subtler and subtlext can also modify
# gravities.
#
# A gravity consists of four values which are a percentage value of the screen
# size. The first two values are x and y starting at the center of the screen
# and he last two values are the width and height.
#
# === Example
#
# Following defines a gravity for a window with 100% width and height:
#
# gravity :example, [ 0, 0, 100, 100 ]
#
# === Link
#
# http://subforge.org/projects/subtle/wiki/Gravity
#
# Top left
gravity :top_left, [ 0, 0, 50, 50 ]
gravity :top_left66, [ 0, 0, 50, 66 ]
gravity :top_left33, [ 0, 0, 50, 34 ]
# Top
gravity :top, [ 0, 0, 100, 50 ]
gravity :top66, [ 0, 0, 100, 66 ]
gravity :top33, [ 0, 0, 100, 34 ]
# Top right
gravity :top_right, [ 50, 0, 50, 50 ]
gravity :top_right66, [ 50, 0, 50, 66 ]
gravity :top_right33, [ 50, 0, 50, 33 ]
# Left
gravity :left, [ 0, 0, 50, 100 ]
gravity :left66, [ 0, 0, 66, 100 ]
gravity :left33, [ 0, 0, 33, 100 ]
# Center
gravity :center, [ 0, 0, 100, 100 ]
gravity :center66, [ 17, 17, 66, 66 ]
gravity :center33, [ 33, 33, 33, 33 ]
# Right
gravity :right, [ 50, 0, 50, 100 ]
gravity :right66, [ 34, 0, 66, 100 ]
gravity :right33, [ 67, 50, 33, 100 ]
# Bottom left
gravity :bottom_left, [ 0, 50, 50, 50 ]
gravity :bottom_left66, [ 0, 34, 50, 66 ]
gravity :bottom_left33, [ 0, 67, 50, 33 ]
# Bottom
gravity :bottom, [ 0, 50, 100, 50 ]
gravity :bottom66, [ 0, 34, 100, 66 ]
gravity :bottom33, [ 0, 67, 100, 33 ]
# Bottom right
gravity :bottom_right, [ 50, 50, 50, 50 ]
gravity :bottom_right66, [ 50, 34, 50, 66 ]
gravity :bottom_right33, [ 50, 67, 50, 33 ]
# Gimp
gravity :gimp_image, [ 10, 0, 80, 100 ]
gravity :gimp_toolbox, [ 0, 0, 10, 100 ]
gravity :gimp_dock, [ 90, 0, 10, 100 ]
# == Grabs
#
# * Numbers and letters keep their names, so *a* is *a* and *0* is *0*
# * Keypad keys need *KP_* as prefix, so *KP_1* is *1* on the keypad
# * Strip the *XK_* from the key names if looked up in
# /usr/include/X11/keysymdef.h
# * Keys usually have meaningful english names
# * Modifier keys have special meaning (Alt (A), Control (C), Meta (M),
# Shift (S), Super (W))
#
# [*A*] = Alt key
# [*C*] = Control key
# [*M*] = Meta key
# [*S*] = Shift key
# [*W*] = Super (Windows) key
begin
require "/usr/share/subtle-contrib-hg/launcher.rb"
require "/usr/share/subtle-contrib-hg/selector.rb"
rescue LoadError => error
puts error
end
grab "W-a" do
if Subtlext::Screen.list.length > 2
Subtle::Contrib::Selector.run
else
current = Subtlext::Screen.current
if current == Subtlext::Screen[0]
Subtlext::Screen[1].jump
else
Subtlext::Screen[0].jump
end
end
end
grab "W-space" do
Subtle::Contrib::Launcher.run
end
grab "W-q", :SubtleReload
grab "W-C-q", :SubtleQuit
grab "W-C-S-r", :SubtleRestart
grab "W-Return", "xterm -e scr-ssh"
grab "W-S-Return", "xterm -T pazuzu -e stmux"
grab "W-v", "gvim"
grab "W-f", "firefox &"
grab "W-c", "chromium &"
grab "W-e", "subl &"
grab "W-i", "inkscape &"
grab "W-z", "xlock"
grab "W-p", "zathura"
grab "W-m", "conkeror"
grab "W-w", :WindowKill
grab "W-B1", :WindowMove
grab "W-B3", :WindowResize
grab "W-F", :WindowFloat
grab "W-space", :WindowFull
grab "W-s", :WindowStick
# zaphod mode?
#grab "W-r", :WindowRaise
#grab "W-l", :WindowLower
grab "W-Left", :WindowLeft
grab "W-Down", :WindowDown
grab "W-Up", :WindowUp
grab "W-Right", :WindowRight
grab "W-KP_7", [ :top_left, :top_left66, :top_left33 ]
grab "W-KP_8", [ :top, :top66, :top33 ]
grab "W-KP_9", [ :top_right, :top_right66, :top_right33 ]
grab "W-KP_4", [ :left, :left66, :left33 ]
grab "W-KP_5", [ :center, :center66, :center33 ]
grab "W-KP_6", [ :right, :right66, :right33 ]
grab "W-KP_1", [ :bottom_left, :bottom_left66, :bottom_left33 ]
grab "W-KP_2", [ :bottom, :bottom66, :bottom33 ]
grab "W-KP_3", [ :bottom_right, :bottom_right66, :bottom_right33 ]
# Run Ruby lambdas
grab "S-F2" do |c|
puts c.name
end
grab "S-F3" do
puts Subtlext::VERSION
end
grab "W-h", :ViewPrev
grab "W-l", :ViewNext
grab "W-j" do
clients = Subtlext::Screen.current.view.clients
clients.last.instance_eval do
focus
raise
end
end
grab "W-k" do
clients = Subtlext::Screen.current.view.clients
clients.first.instance_eval do
lower
end
clients.first.instance_eval do
focus
end
end
#
# == Tags
#
# Tags are generally used in subtle for placement of windows. This placement is
# strict, that means that - aside from other tiling window managers - windows
# must have a matching tag to be on a certain view. This also includes that
# windows that are started on a certain view will not automatically be placed
# there.
#
# There are to ways to define a tag:
#
# === Simple
#
# The simple way just needs a name and a regular expression to just handle the
# placement:
#
# Example:
#
# tag "terms", "terms"
#
# === Extended
#
# Additionally tags can do a lot more then just control the placement - they
# also have properties than can define and control some aspects of a window
# like the default gravity or the default screen per view.
#
# Example:
#
# tag "terms" do
# match "xterm|[u]?rxvt"
# gravity :center
# end
#
# === Default
#
# Whenever a window has no tag it will get the default tag and be placed on the
# default view. The default view can either be set by the user with adding the
# default tag to a view by choice or otherwise the first defined view will be
# chosen automatically.
#
# === Properties
#
# [*borderless*] This property enables the borderless mode for tagged clients.
#
# Example: borderless true
# Links: http://subforge.org/projects/subtle/wiki/Tagging#Borderless
# http://subforge.org/projects/subtle/wiki/Clients#Borderless
#
# [*fixed*] This property enables the fixed mode for tagged clients.
#
# Example: fixed true
# Links: http://subforge.org/projects/subtle/wiki/Tagging#Fixed
# http://subforge.org/projects/subtle/wiki/Clients#Fixed
#
# [*float*] This property enables the float mode for tagged clients.
#
# Example: float true
# Links: http://subforge.org/projects/subtle/wiki/Tagging#Float
# http://subforge.org/projects/subtle/wiki/Clients#Float
#
# [*full*] This property enables the fullscreen mode for tagged clients.
#
# Example: full true
# Links: http://subforge.org/projects/subtle/wiki/Tagging#Fullscreen
# http://subforge.org/projects/subtle/wiki/Clients#Fullscreen
#
# [*geometry*] This property sets a certain geometry as well as floating mode
# to the tagged client, but only on views that have this tag too.
# It expects an array with x, y, width and height values whereas
# width and height must be >0.
#
# Example: geometry [100, 100, 50, 50]
# Link: http://subforge.org/projects/subtle/wiki/Tagging#Geometry
#
# [*gravity*] This property sets a certain to gravity to the tagged client,
# but only on views that have this tag too.
#
# Example: gravity :center
# Link: http://subforge.org/projects/subtle/wiki/Tagging#Gravity
#
# [*match*] This property adds matching patterns to a tag, a tag can have
# more than one. Matching works either via plaintext, regex
# (see man regex(7)) or window id. Per default tags will only
# match the WM_NAME and the WM_CLASS portion of a client, this
# can be changed with following possible values:
#
# [*:name*] Match the WM_NAME
# [*:instance*] Match the first (instance) part from WM_CLASS
# [*:class*] Match the second (class) part from WM_CLASS
# [*:role*] Match the window role
# [*:type*] Match the window type
#
# Examples: match instance: "urxvt"
# match [:role, :class] => "test"
# match "[xa]+term"
# Link: http://subforge.org/projects/subtle/wiki/Tagging#Match
#
# [*position*] Similar to the geometry property, this property just sets the
# x/y coordinates of the tagged client, but only on views that
# have this tag, too. It expects an array with x and y values.
#
# Example: position [ 10, 10 ]
# Link: http://subforge.org/projects/subtle/wiki/Tagging#Position
#
# [*resize*] This property enables the float mode for tagged clients.
#
# Example: resize true
# Links: http://subforge.org/projects/subtle/wiki/Tagging#Resize
# http://subforge.org/projects/subtle/wiki/Clients#Resize
#
# [*stick*] This property enables the float mode for tagged clients.
#
# Example: stick true
# Links: http://subforge.org/projects/subtle/wiki/Tagging#Stick
# http://subforge.org/projects/subtle/wiki/Clients#Stick
#
# [*type*] This property sets the tagged client to be treated as a specific
# window type though as the window sets the type itself. Following
# types are possible:
#
# [*:desktop*] Treat as desktop window (_NET_WM_WINDOW_TYPE_DESKTOP)
# Link: http://subforge.org/projects/subtle/wiki/Clients#Desktop
# [*:dock*] Treat as dock window (_NET_WM_WINDOW_TYPE_DOCK)
# Link: http://subforge.org/projects/subtle/wiki/Clients#Dock
# [*:toolbar*] Treat as toolbar windows (_NET_WM_WINDOW_TYPE_TOOLBAR)
# Link: http://subforge.org/projects/subtle/wiki/Clients#Toolbar
# [*:splash*] Treat as splash window (_NET_WM_WINDOW_TYPE_SPLASH)
# Link: http://subforge.org/projects/subtle/wiki/Clients#Splash
# [*:dialog*] Treat as dialog window (_NET_WM_WINDOW_TYPE_DIALOG)
# Link: http://subforge.org/projects/subtle/wiki/Clients#Dialog
#
# Example: type :desktop
# Link: http://subforge.org/projects/subtle/wiki/Tagging#Type
#
# [*urgent*] This property enables the urgent mode for tagged clients.
#
# Example: stick true
# Links: http://subforge.org/projects/subtle/wiki/Tagging#Stick
# http://subforge.org/projects/subtle/wiki/Clients#Urgent
#
# [*zaphod*] This property enables the zaphod mode for tagged clients.
#
# Example: zaphod true
# Links: http://subforge.org/projects/subtle/wiki/Tagging#Zaphod
# http://subforge.org/projects/subtle/wiki/Clients#Zaphod
#
#
# === Link
#
# http://subforge.org/projects/subtle/wiki/Tagging
#
# Simple tags
tag "terms" do
match class: "xterm", name: "(?!^pazuzu)"
end
tag "web" do
match class: "firefox"
match class: "chromium"
match class: "mplayer"
end
tag "local" do
match instance: "xterm", name: "^pazuzu"
match class: "subl"
end
tag "fixed" do
geometry [ 10, 10, 100, 100 ]
stick true
end
# Gimp
tag "gimp_image" do
match :role => "gimp-image-window"
gravity :gimp_image
end
tag "gimp_toolbox" do
match :role => "gimp-toolbox$"
gravity :gimp_toolbox
end
tag "gimp_dock" do
match :role => "gimp-dock"
gravity :gimp_dock
end
# == Views
view "local", "local"
view "terms", "terms"
view "misc", "default"
view "web", "web"
# == Hooks
#
# Following hooks exist so far:
# [*:client_create*] Called whenever a window is created
# [*:client_configure*] Called whenever a window is configured
# [*:client_focus*] Called whenever a window gets focus
# [*:client_kill*] Called whenever a window is killed
# [*:tag_create*] Called whenever a tag is created
# [*:tag_kill*] Called whenever a tag is killed
# [*:view_create*] Called whenever a view is created
# [*:view_configure*] Called whenever a view is configured
# [*:view_jump*] Called whenever the view is switched
# [*:view_kill*] Called whenever a view is killed
# [*:tile*] Called on whenever tiling would be needed
# [*:reload*] Called on reload
# [*:start*] Called on start
# [*:exit*] Called on exit
# === Example
#
# This hook will print the name of the window that gets the focus:
#
# on :client_focus do |c|
# puts c.name
# end
#
# === Link
#
# http://subforge.org/projects/subtle/wiki/Hooks
#
# vim:ts=2:bs=2:sw=2:et:fdm=marker