Project

General

Profile

unexist.dev

Assorted tidbits and projects

subtle.rb

(almost default) laptop config - Tim Y, 01/11/2011 06:58 AM

 
1
#
2
# Author::  Christoph Kappel <unexist@dorfelite.net>
3
# Version:: $Id$
4
# License:: GNU GPL
5
#
6
# = Subtle default configuration
7
#
8
# This file will be installed as default and can also be used as a starter for
9
# an own custom configuration file. The system wide config usually resides in
10
# +/etc/xdg/subtle+ and the user config in +HOME/.config/subtle+, both locations
11
# are dependent on the locations specified by +XDG_CONFIG_DIRS+ and
12
# +XDG_CONFIG_HOME+.
13
#
14

    
15
#
16
# == Options
17
#
18
# Following options change behaviour and sizes of the window manager:
19
#
20
# Border size in pixel of the windows
21
set :border, 2
22

    
23
# Window move/resize steps in pixel per keypress
24
set :step, 5
25

    
26
# Window screen border snapping
27
set :snap, 10
28

    
29
# Default starting gravity for windows (0 = gravity of last client)
30
set :gravity, :center
31

    
32
# Make transient windows urgent
33
set :urgent, false
34

    
35
# Honor resize size hints globally
36
set :resize, false
37

    
38
# Screen strut for e.g. other panels (left, right, top, bottom)
39
set :strut, [ 0, 0, 0, 0 ]
40

    
41
# Font string either take from e.g. xfontsel or use xft
42
set :font, "-*-clean-medium-*-*-*-14-*-*-*-*-*-*-*"
43
#set :font, "xft:sans-8"
44

    
45
# Space around windows
46
set :gap, 0
47

    
48
# Panel size padding (left, right, top, bottom)
49
set :padding, [ 0, 0, 0, 0 ]
50

    
51
# Separator between sublets
52
set :separator, "|"
53

    
54
# Outline border size in pixel of panel items
55
set :outline, 0
56

    
57
#
58
# == Screen
59
#
60
# Generally subtle comes with two panels per screen, one on the top and one at
61
# the bottom. Each panel can be configured with different panel items and
62
# sublets # screen wise. The default config uses top panel on the first screen
63
# only, it's # up to the user to enable the bottom panel or disable either one
64
# or both.
65
#
66
# Empty panels are hidden.
67
#
68
# Following items are available:
69
#
70
# [*:views*]     List of views with buttons
71
# [*:title*]     Title of the current active window
72
# [*:tray*]      Systray icons (Can be used once)
73
# [*:sublets*]   Catch-all for installed sublets
74
# [*:sublet*]    Name of a sublet for direct placement
75
# [*:spacer*]    Variable spacer (free width / count of spacers)
76
# [*:center*]    Enclose items with :center to center them on the panel
77
# [*:separator*] Insert separator
78
#
79
# === Link
80
#
81
# http://subforge.org/wiki/subtle/Panel
82
#
83

    
84
screen 1 do
85
  # Add stipple to panels
86
  stipple false
87

    
88
  # Content of the top panel
89
  top     [ :views, :title, :spacer, :tray, :sublets ]
90

    
91
  # Content of the bottom panel
92
  bottom  [ ]
93
end
94

    
95
#
96
# == Colors
97
#
98
# Colors directly define the look of subtle, valid values are:
99
#
100
# [*hexadecimal*] #0000ff
101
# [*decimal*]     (0, 0, 255)
102
# [*names*]       blue
103
#
104
# Whenever there is no valid value for a color set - subtle will use a default
105
# one. There is only one exception to this: If no background color is given no
106
# color will be set. This will ensure a custom background pixmap won't be
107
# overwritten.
108
#
109
# === Link
110
#
111
# http://subforge.org/wiki/subtle/Themes
112

    
113
# Colors of focus window title
114
color :title_fg,        "#fecf35"
115
color :title_bg,        "#202020"
116
color :title_border,    "#303030"
117

    
118
# Colors of the active views
119
color :focus_fg,        "#fecf35"
120
color :focus_bg,        "#202020"
121
color :focus_border,    "#303030"
122

    
123
# Colors of urgent window titles and views
124
color :urgent_fg,       "#ff9800"
125
color :urgent_bg,       "#202020"
126
color :urgent_border,   "#303030"
127

    
128
# Colors of occupied views (views with clients)
129
color :occupied_fg,     "#b8b8b8"
130
color :occupied_bg,     "#202020"
131
color :occupied_border, "#303030"
132

    
133
# Color of view buttons
134
color :views_fg,        "#757575"
135
color :views_bg,        "#202020"
136
color :views_border,    "#303030"
137

    
138
# Colors of sublets
139
color :sublets_fg,      "#757575"
140
color :sublets_bg,      "#202020"
141
color :sublets_border,  "#303030"
142

    
143
# Border colors of active/inactive windows
144
color :client_active,   "#303030"
145
color :client_inactive, "#202020"
146

    
147
# Background colors of panels
148
color :panel,           "#202020"
149

    
150
# Background color of root background
151
color :background,      "#3d3d3d"
152

    
153
# Color of the stipple (if enabled)
154
color :stipple,         "#757575"
155

    
156
# Color of the separator
157
color :separator,       "#757575"
158

    
159
#
160
# == Gravities
161
#
162
# Gravities are predefined sizes a window can be set to. There are several ways
163
# to set a certain gravity, most convenient is to define a gravity via a tag or
164
# change them during runtime via grab. Subtler and subtlext can also modify
165
# gravities.
166
#
167
# A gravity consists of four values which are a percentage value of the screen
168
# size. The first two values are x and y starting at the center of the screen
169
# and he last two values are the width and height.
170
#
171
# === Example
172
#
173
# Following defines a gravity for a window with 100% width and height:
174
#
175
#   gravity :example, [ 0, 0, 100, 100 ]
176
#
177
# === Link
178
#
179
# http://subforge.org/wiki/subtle/Gravity
180
#
181

    
182
  # Top left
183
gravity :top_left,       [   0,   0,  50,  50 ]
184
gravity :top_left66,     [   0,   0,  50,  66 ]
185
gravity :top_left33,     [   0,   0,  50,  34 ]
186

    
187
  # Top
188
gravity :top,            [   0,   0, 100,  50 ]
189
gravity :top66,          [   0,   0, 100,  66 ]
190
gravity :top33,          [   0,   0, 100,  34 ]
191

    
192
  # Top right
193
gravity :top_right,      [ 100,   0,  50,  50 ]
194
gravity :top_right66,    [ 100,   0,  50,  66 ]
195
gravity :top_right33,    [ 100,   0,  50,  34 ]
196

    
197
  # Left
198
gravity :left,           [   0,   0,  50, 100 ]
199
gravity :left66,         [   0,  50,  50,  34 ]
200
gravity :left33,         [   0,  50,  25,  34 ]
201

    
202
  # Center
203
gravity :center,         [   0,   0, 100, 100 ]
204
gravity :center66,       [   0,  50, 100,  34 ]
205
gravity :center33,       [  50,  50,  50,  34 ]
206

    
207
  # Right
208
gravity :right,          [ 100,   0,  50, 100 ]
209
gravity :right66,        [ 100,  50,  50,  34 ]
210
gravity :right33,        [ 100,  50,  25,  34 ]
211

    
212
  # Bottom left
213
gravity :bottom_left,    [   0, 100,  50,  50 ]
214
gravity :bottom_left66,  [   0, 100,  50,  66 ]
215
gravity :bottom_left33,  [   0, 100,  50,  34 ]
216

    
217
  # Bottom
218
gravity :bottom,         [   0, 100, 100,  50 ]
219
gravity :bottom66,       [   0, 100, 100,  66 ]
220
gravity :bottom33,       [   0, 100, 100,  34 ]
221

    
222
  # Bottom right
223
gravity :bottom_right,   [ 100, 100,  50,  50 ]
224
gravity :bottom_right66, [ 100, 100,  50,  66 ]
225
gravity :bottom_right33, [ 100, 100,  50,  34 ]
226

    
227
  # Gimp
228
gravity :gimp_image,     [  50,  50,  80, 100 ]
229
gravity :gimp_toolbox,   [   0,   0,  10, 100 ]
230
gravity :gimp_dock,      [ 100,   0,  10, 100 ]
231

    
232
#
233
# == Grabs
234
#
235
# Grabs are keyboard and mouse actions within subtle, every grab can be
236
# assigned either to a key and/or to a mouse button combination. A grab
237
# consists of a chain and an action.
238
#
239
# === Finding keys
240
#
241
# The best resource for getting the correct key names is
242
# */usr/include/X11/keysymdef.h*, but to make life easier here are some hints
243
# about it:
244
#
245
# * Numbers and letters keep their names, so *a* is *a* and *0* is *0*
246
# * Keypad keys need *KP_* as prefix, so *KP_1* is *1* on the keypad
247
# * Strip the *XK_* from the key names if looked up in
248
#   /usr/include/X11/keysymdef.h
249
# * Keys usually have meaningful english names
250
# * Modifier keys have special meaning (Alt (A), Control (C), Meta (M),
251
#   Shift (S), Super (W))
252
#
253
# === Chaining
254
#
255
# Chains are a combination of keys and modifiers to one key and can be used in
256
# various ways to trigger an action. In subtle there are two ways to define
257
# chains for grabs:
258
#
259
#   1. Default way*: Add modifiers to a key and use it for a grab
260
#
261
#      *Example*: grab "W-Return", "urxvt"
262
#
263
#   2. *Escape way*: Define an escape grab that needs to be pressed before
264
#      *any* other grab can be used like in screen/tmux.
265
#
266
#      *Example*: grab "C-y", :SubtleEscape
267
#                 grab "Return", "urxvt"
268
#
269
# ==== Mouse buttons
270
#
271
# [*B1*] = Button1 (Left mouse button)
272
# [*B2*] = Button2 (Middle mouse button)
273
# [*B3*] = Button3 (Right mouse button)
274
# [*B4*] = Button4 (Mouse wheel up)
275
# [*B5*] = Button5 (Mouse wheel down)
276
#
277
# ==== Modifiers
278
#
279
# [*A*] = Alt key
280
# [*C*] = Control key
281
# [*M*] = Meta key
282
# [*S*] = Shift key
283
# [*W*] = Super (Windows) key
284
#
285
# === Action
286
#
287
# An action is something that happens when a grab is activated, this can be one
288
# of the following:
289
#
290
# [*symbol*] Run a subtle action
291
# [*string*] Start a certain program
292
# [*array*]  Cycle through gravities
293
# [*lambda*] Run a Ruby proc
294
#
295
# === Example
296
#
297
# This will create a grab that starts a urxvt when Alt+Enter are pressed:
298
#
299
#   grab "A-Return", "urxvt"
300
#
301
# === Link
302
#
303
# http://subforge.org/wiki/subtle/Grabs
304
#
305

    
306
# Escape grab
307
#  grab "C-y", :SubtleEscape
308

    
309
# Jump to view1, view2, ...
310
grab "A-S-1", :ViewJump1
311
grab "A-S-2", :ViewJump2
312
grab "A-S-3", :ViewJump3
313
grab "A-S-4", :ViewJump4
314

    
315
# Switch current view
316
grab "A-1", :ViewSwitch1
317
grab "A-2", :ViewSwitch2
318
grab "A-3", :ViewSwitch3
319
grab "A-4", :ViewSwitch4
320

    
321
# Select next and prev view */
322
grab "KP_Add",      :ViewNext
323
grab "KP_Subtract", :ViewPrev
324

    
325
# Move mouse to screen1, screen2, ...
326
grab "C-A-1", :ScreenJump1
327
grab "C-A-2", :ScreenJump2
328
grab "C-A-3", :ScreenJump3
329
grab "C-A-4", :ScreenJump4
330

    
331
# Force reload of config and sublets
332
grab "A-C-r", :SubtleReload
333

    
334
# Force restart of subtle
335
grab "A-C-S-r", :SubtleRestart
336

    
337
# Quit subtle
338
grab "A-S-q", :SubtleQuit
339

    
340
# Move current window
341
grab "A-B1", :WindowMove
342

    
343
# Resize current window
344
grab "A-B3", :WindowResize
345

    
346
# Toggle floating mode of window
347
grab "A-f", :WindowFloat
348

    
349
# Toggle fullscreen mode of window
350
grab "A-space", :WindowFull
351

    
352
# Toggle sticky mode of window (will be visible on all views)
353
grab "A-v", :WindowStick
354

    
355
# Raise window
356
grab "A-u", :WindowRaise
357

    
358
# Lower window
359
grab "A-n", :WindowLower
360

    
361
# Select next windows
362
grab "A-h",  :WindowLeft
363
grab "A-j",  :WindowDown
364
grab "A-k",    :WindowUp
365
grab "A-l", :WindowRight
366

    
367
# Kill current window
368
grab "A-F4", :WindowKill
369

    
370
# Cycle between given gravities
371
# In case no numpad is available e.g. on notebooks
372
grab "A-q", [ :top_left,     :top_left66,     :top_left33     ]
373
grab "A-w", [ :top,          :top66,          :top33          ]
374
grab "A-e", [ :top_right,    :top_right66,    :top_right33    ]
375
grab "A-a", [ :left,         :left66,         :left33         ]
376
grab "A-s", [ :center,       :center66,       :center33       ]
377
grab "A-d", [ :right,        :right66,        :right33        ]
378
grab "A-y", [ :bottom_left,  :bottom_left66,  :bottom_left33  ]
379
grab "A-x", [ :bottom,       :bottom66,       :bottom33       ]
380
grab "A-c", [ :bottom_right, :bottom_right66, :bottom_right33 ]
381

    
382
# Exec programs
383
grab "A-Return", "urxvtc"
384

    
385
# Run Ruby lambdas
386
grab "S-F2" do |c|
387
  puts c.name
388
end
389

    
390
grab "S-F3" do
391
  puts Subtlext::VERSION
392
end
393

    
394
#
395
# == Tags
396
#
397
# Tags are generally used in subtle for placement of windows. This placement is
398
# strict, that means that - aside from other tiling window managers - windows
399
# must have a matching tag to be on a certain view. This also includes that
400
# windows that are started on a certain view will not automatically be placed
401
# there.
402
#
403
# There are to ways to define a tag:
404
#
405
# === Simple
406
#
407
# The simple way just needs a name and a regular expression to just handle the
408
# placement:
409
#
410
# Example:
411
#
412
#  tag "terms", "terms"
413
#
414
# === Extended
415
#
416
# Additionally tags can do a lot more then just control the placement - they
417
# also have properties than can define and control some aspects of a window
418
# like the default gravity or the default screen per view.
419
#
420
# Example:
421
#
422
#  tag "terms" do
423
#    match   "xterm|[u]?rxvt"
424
#    gravity :center
425
#  end
426
#
427
# === Default
428
#
429
# Whenever a window has no tag it will get the default tag and be placed on the
430
# default view. The default view can either be set by the user with adding the
431
# default tag to a view by choice or otherwise the first defined view will be
432
# chosen automatically.
433
#
434
# === Properties
435
#
436
# [*float*]     This property either sets the tagged client floating or prevents
437
#               it from being floating depending on the value.
438
#
439
#               Example: float true
440
#
441
# [*full*]      This property either sets the tagged client to fullscreen or
442
#               prevents it from being set to fullscreen depending on the value.
443
#
444
#               Example: full true
445
#
446
# [*geometry*]  This property sets a certain geometry as well as floating mode
447
#               to the tagged client, but only on views that have this tag too.
448
#               It expects an array with x, y, width and height values whereas
449
#               width and height must be >0.
450
#
451
#               Example: geometry [100, 100, 50, 50]
452
#
453
# [*gravity*]   This property sets a certain to gravity to the tagged client,
454
#               but only on views that have this tag too.
455
#
456
#              Example: gravity :center
457
#
458
# [*match*]    This property adds matching patterns to a tag, a tag can have
459
#              more than one. Matching works either via plaintext, regex
460
#              (see man regex(7)) or window id. Per default tags will only
461
#              match the WM_NAME and the WM_CLASS portion of a client, this
462
#              can be changed with following possible values:
463
#
464
#              [*:name*]      Match the WM_NAME
465
#              [*:instance*]  Match the first (instance) part from WM_CLASS
466
#              [*:class*]     Match the second (class) part from WM_CLASS
467
#              [*:role*]      Match the window role
468
#
469
#              Example: match :instance => "urxvt"
470
#                       match [:role, :class] => "test"
471
#                       match "[xa]+term"
472
#
473
# [*exclude*]  This property works exactly the same way as *match*, but it
474
#              excludes clients that match from this tag. That can be helpful
475
#              with catch-all tags e.g. for console apps.
476
#
477
#              Example: exclude :instance => "irssi"
478
#
479
# [*resize*]   This property either enables or disables honoring of client
480
#              resize hints and is independent of the global option.
481
#
482
#              Example: resize true
483
#
484
# [*stick*]    This property either sets the tagged client to stick or prevents
485
#              it from being set to stick depending on the value. Stick clients
486
#              are visible on every view.
487
#
488
#              Example: stick true
489
#
490
# [*type*]     This property sets the [[Tagging|tagged]] client to be treated
491
#              as a specific window type though as the window sets the type
492
#              itself. Following types are possible:
493
#
494
#              [*:desktop*]  Treat as desktop window (_NET_WM_WINDOW_TYPE_DESKTOP)
495
#              [*:dock*]     Treat as dock window (_NET_WM_WINDOW_TYPE_DOCK)
496
#              [*:toolbar*]  Treat as toolbar windows (_NET_WM_WINDOW_TYPE_TOOLBAR)
497
#              [*:splash*]   Treat as splash window (_NET_WM_WINDOW_TYPE_SPLASH)
498
#              [*:dialog*]   Treat as dialog window (_NET_WM_WINDOW_TYPE_DIALOG)
499
#
500
#              Example: type :desktop
501
#
502
# [*urgent*]   This property either sets the tagged client to be urgent or
503
#              prevents it from being urgent depending on the value. Urgent
504
#              clients will get keyboard and mouse focus automatically.
505
#
506
#              Example: urgent true
507
#
508
# === Link
509
#
510
# http://subforge.org/wiki/subtle/Tagging
511
#
512

    
513
# Simple tags
514
tag "terms",   "xterm|[u]?rxvt"
515
tag "browser", "uzbl|opera|firefox|navigator"
516

    
517
# Placement
518
tag "editor" do
519
  match  "[g]?vim"
520
  resize true
521
end
522

    
523
tag "fixed" do
524
  geometry [ 10, 10, 100, 100 ]
525
  stick    true
526
end
527

    
528
tag "resize" do
529
  match  "sakura|gvim"
530
  resize true
531
end
532

    
533
tag "gravity" do
534
  gravity :center
535
end
536

    
537
# Modes
538
tag "stick" do
539
  match "mplayer"
540
  float true
541
  stick true
542
end
543

    
544
tag "float" do
545
  match "display"
546
  float true
547
end
548

    
549
# Gimp
550
tag "gimp_image" do
551
  match   :role => "gimp-image-window"
552
  gravity :gimp_image
553
end
554

    
555
tag "gimp_toolbox" do
556
  match   :role => "gimp-toolbox$"
557
  gravity :gimp_toolbox
558
end
559

    
560
tag "gimp_dock" do
561
  match   :role => "gimp-dock"
562
  gravity :gimp_dock
563
end
564

    
565
#
566
# == Views
567
#
568
# Views are the virtual desktops in subtle, they show all windows that share a
569
# tag with them. Windows that have no tag will be visible on the default view
570
# which is the view with the default tag or the first defined view when this
571
# tag isn't set.
572
#
573
# Like tags views can be defined in two ways:
574
#
575
# === Simple
576
#
577
# The simple way is exactly the same as for tags:
578
#
579
# Example:
580
#
581
#   view "terms", "terms"
582
#
583
# === Extended
584
#
585
# The extended way for views is also similar to the tags, but with fewer
586
# properties.
587
#
588
# Example:
589
#
590
#  view "terms" do
591
#    match "terms"
592
#    icon  "/usr/share/icons/icon.xbm"
593
#  end
594
#
595
# === Properties
596
#
597
# [*match*]      This property adds a matching pattern to a view. Matching
598
#                works either via plaintext or regex (see man regex(7)) and
599
#                applies to names of tags.
600
#
601
#                Example: match "terms"
602
#
603
# [*dynamic*]    This property hides unoccupied views, views that display no
604
#                windows.
605
#
606
#                Example: dynamic true
607
#
608
# [*icon*]       This property adds an icon in front of the view name. The
609
#                icon can either be path to an icon or an instance of
610
#                Subtlext::Icon.
611
#
612
#                Example: icon "/usr/share/icons/icon.xbm"
613
#                         icon Subtlext::Icon.new("/usr/share/icons/icon.xbm")
614
#
615
# [*icon_only*]  This property hides the view name from the view buttons, just
616
#                the icon will be visible.
617
#
618
#                Example: icon_only true
619
#
620
#
621
# === Link
622
#
623
# http://subforge.org/wiki/subtle/Tagging
624
#
625

    
626
view "terms", "terms|default"
627
view "www",   "browser"
628
view "gimp",  "gimp_.*"
629
view "dev",   "editor"
630

    
631
#
632
# == Sublets
633
#
634
# Sublets are Ruby scripts that provide data for the panel and can be managed
635
# with the sur script that comes with subtle.
636
#
637
# === Example
638
#
639
#  sur install clock
640
#  sur uninstall clock
641
#  sur list
642
#
643
# === Configuration
644
#
645
# All sublets have a set of configuration values that can be changed directly
646
# from the config of subtle.
647
#
648
# There are three default properties, that can be be changed for every sublet:
649
#
650
# [*interval*]    Update interval of the sublet
651
# [*foreground*]  Default foreground color
652
# [*background*]  Default background color
653
#
654
# sur can also give a brief overview about properties:
655
#
656
# === Example
657
#
658
#   sur config clock
659
#
660
# The syntax of the sublet configuration is similar to other configuration
661
# options in subtle:
662
#
663
# === Example
664
#
665
#  sublet :clock do
666
#    interval      30
667
#    foreground    "#eeeeee"
668
#    background    "#000000"
669
#    format_string "%H:%M:%S"
670
#  end
671
#
672
#  === Link
673
#
674
# http://subforge.org/wiki/subtle/Sublets
675
#
676

    
677
#
678
# == Hooks
679
#
680
# And finally hooks are a way to bind Ruby scripts to a certain event.
681
#
682
# Following hooks exist so far:
683
#
684
# [*:client_create*]    Called whenever a window is created
685
# [*:client_configure*] Called whenever a window is configured
686
# [*:client_focus*]     Called whenever a window gets focus
687
# [*:client_kill*]      Called whenever a window is killed
688
#
689
# [*:tag_create*]       Called whenever a tag is created
690
# [*:tag_kill*]         Called whenever a tag is killed
691
#
692
# [*:view_create*]      Called whenever a view is created
693
# [*:view_configure*]   Called whenever a view is configured
694
# [*:view_jump*]        Called whenever the view is switched
695
# [*:view_kill*]        Called whenever a view is killed
696
#
697
# [*:tile*]             Called on whenever tiling would be needed
698
# [*:reload*]           Called on reload
699
# [*:start*]            Called on start
700
# [*:exit*]             Called on exit
701
#
702
# === Example
703
#
704
# This hook will print the name of the window that gets the focus:
705
#
706
#   on :client_focus do |c|
707
#     puts c.name
708
#   end
709
#
710
# === Link
711
#
712
# http://subforge.org/wiki/subtle/Hooks
713
#
714

    
715
on :start do
716
  Subtlext::Subtle.spawn "nitrogen --restore"
717
  Subtlext::Subtle.spawn "xsetroot -cursor_name left_ptr"
718
end
719

    
720
begin
721
  require "#{ENV["HOME"]}/bin/launcher/launcher.rb"
722

    
723
  # Set fonts
724
  Subtle::Contrib::Launcher.fonts = [
725
    "xft:Envy Code R:pixelsize=80:antialias=true",
726
    "xft:Envy Code R:pixelsize=12:antialias=true"
727
  ]
728
rescue LoadError => err
729
  p err
730
end
731
grab "A-grave" do
732
  Subtle::Contrib::Launcher.run
733
end
734

    
735
# vim:ts=2:bs=2:sw=2:et:fdm=marker