Project

General

Profile

unexist.dev

/

subtle

Assorted tidbits and projects

subtle.rb

subtle.rb - still hackish, did not get around to clean it up yet. - Christian Brassat, 05/09/2011 05:37 PM

 
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
begin
15
  require "#{ENV["HOME"]}/bin/subtle-contrib/ruby/launcher.rb"
16
rescue LoadError => error
17
  puts error
18
end
19

    
20

    
21
# == Options
22
#
23
# Border size in pixel of the windows
24

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

    
28
# Window screen border snapping
29
set :snap, 0
30

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

    
34
# Make transient windows urgent
35
set :urgent, false
36

    
37
# Honor resize size hints globally
38
set :resize, false
39

    
40
# Screen strut for e.g. other panels (left, right, top, bottom)
41

    
42
# Font string either take from e.g. xfontsel or use xft
43
#set :font, "-*-*-medium-*-*-*-14-*-*-*-*-*-*-*"
44
set :font, "xft:Pragmata:pixelsize=9"
45

    
46
# Space around windows
47

    
48
# Panel size padding (left, right, top, bottom)
49

    
50
# Separator between sublets
51
set :separator, " «» "
52

    
53
# Outline border size in pixel of panel items #}}}
54

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

    
80
screen 1 do
81
  # Add stipple to panels
82
  stipple false
83

    
84
  # Content of the bottom panel
85
  bottom     [ :views, :separator, :keychain, :spacer, :smpd, :separator, :jdownloader, :separator, :maildir_mod, :separator, :pacman, :separator, :fuzzytime, :separator ]
86

    
87
  # Content of the top panel
88
  top  [ ]
89
end # }}}
90

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

    
108
# Colors of focus window title
109
style :title do
110
  padding     2, 0, 0
111
#  border_bottom "#303030", 2
112
  foreground  "#909090"
113
  background  "#151515"
114
end
115

    
116
style :focus do
117
  padding     2, 4, 0, 4
118
  border_bottom "#606060", 2
119
  foreground  "#b0b0b0"
120
  background  "#151515"
121
end
122

    
123
style :urgent do
124
  padding     2, 4, 0, 4
125
  border      "#303030", 0
126
  foreground  "#ffffff"
127
  background  "#519f50"
128
end
129

    
130
style :occupied do
131
  padding     2, 4, 0, 4
132
  border_bottom "#2a2a2a", 2
133
  foreground  "#606060"
134
  background  "#151515"
135
end
136

    
137
style :views do
138
  padding     2, 4, 0, 4
139
#  border_bottom "#090909", 2
140
  foreground  "#303030"
141
  background  "#151515"
142
end
143

    
144
style :sublets do
145
  margin      0
146
  padding     2, 0, 0
147
#  border_bottom "#303030", 2
148
  foreground  "#b0b0b0"
149
  background  "#151515"
150
end
151

    
152
style :separator do
153
  margin      0
154
  padding     1, 0, 0
155
#  border_bottom "#090909", 2
156
  background  "#151515"
157
  foreground  "#505050"
158
end
159

    
160
style :clients do
161
  active      "#d0d0ff", 2
162
  inactive    "#202020", 2
163
  margin      2
164
end
165

    
166
style :subtle do
167
  padding     2
168
  panel       "#151515"
169
  stipple     "#757575"
170
end
171

    
172

    
173
# Colors of the active views
174

    
175
# Colors of urgent window titles and views
176

    
177
# Colors of occupied views (views with clients)
178

    
179
# Color of view buttons
180

    
181
# Colors of sublets
182

    
183
# Border colors of active/inactive windows
184

    
185
# Background colors of panels
186

    
187
# Background color of root background
188
# color :background,      "#3d3d3d"
189

    
190
# Color of the stipple (if enabled)
191

    
192
# Color of the separator #}}}
193

    
194
# == Gravities# {{{
195
#
196
# Gravities are predefined sizes a window can be set to. There are several ways
197
# to set a certain gravity, most convenient is to define a gravity via a tag or
198
# change them during runtime via grab. Subtler and subtlext can also modify
199
# gravities.
200
#
201
# A gravity consists of four values which are a percentage value of the screen
202
# size. The first two values are x and y starting at the center of the screen
203
# and he last two values are the width and height.
204
#
205
# === Example
206
#
207
# Following defines a gravity for a window with 100% width and height:
208
#
209
#   gravity :example, [ 0, 0, 100, 100 ]
210
#
211
# === Link
212
#
213
# http://subforge.org/wiki/subtle/Gravity
214

    
215
# set :tiling, true
216

    
217
  # Center
218
gravity :center,         [   0,   0, 100, 100 ]
219

    
220
  # Top left
221
gravity :top_left66,     [   0,   0,  66,  67 ]
222
gravity :top_left50,     [   0,   0,  50,  67 ]
223

    
224
  # Top
225
gravity :top,            [   0,   0, 100,  67 ]
226

    
227
  # Top right
228
gravity :top_right,      [ 100,   0,  34,  67 ]
229
gravity :top_right33,    [ 100,   0,  34,  33 ]
230
gravity :top_right50,    [ 100,   0,  50,  67 ]
231

    
232
  # Left
233
gravity :left,           [   0,   0,  50, 100 ]
234
gravity :left66,         [   0,   0,  66, 100 ]
235

    
236
  # Right
237
gravity :right,          [ 100,  50,  34,  34 ]
238
gravity :right33,        [ 100,  50,  34, 100 ]
239
gravity :right66,        [ 100,  50,  50, 100 ]
240

    
241
  # Bottom left
242
gravity :bottom_left,    [   0, 100,  50,  33 ]
243
gravity :bottom_left33,  [   0, 100,  33,  33 ]
244

    
245
  # Bottom
246
gravity :bottom,         [   0, 100, 100,  33 ]
247
gravity :bottom33,       [  49, 100,  33,  33 ]
248

    
249
  # Bottom right
250
gravity :bottom_right,   [ 100, 100,  50,  33 ]
251
gravity :bottom_right33, [ 100, 100,  34,  33 ]
252

    
253
  # Gimp
254
gravity :gimp_image,     [   0,   0,  83, 100 ]
255
gravity :gimp_toolbox,   [ 100,   0,  17,  30 ]
256
gravity :gimp_dock,      [ 100, 100,  17,  70 ]
257

    
258
# }}}
259

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

    
332
# Escape grab
333
# grab "C-y", :SubtleEscape
334

    
335
# Switch current view
336
grab "W-1", :ViewSwitch1
337
grab "W-2", :ViewSwitch2
338
grab "W-3", :ViewSwitch3
339
grab "W-4", :ViewSwitch4
340
grab "W-5", :ViewSwitch5
341
grab "W-6", :ViewSwitch6
342

    
343
(1..6).each do |i|
344
  grab "W-S-%d" % [ i ] do |c|
345
    views = Subtlext::View.all
346
    names = views.map { |v| v.name }
347
 
348
    # Sanity check
349
    if(i <= views.size)
350
      # Tag client
351
      tags = c.tags.reject { |t| names.include?(t.name) or "default" == t.name }
352
      tags << names[i - 1]
353
 
354
      c.tags = tags
355
 
356
      # Tag view
357
      views[i - 1].tag(names[i - 1])
358
    end
359
  end
360
end
361

    
362
# Select next and prev view */
363
grab "KP_Add",      :ViewNext
364
grab "KP_Subtract", :ViewPrev
365

    
366
# Move mouse to screen1, screen2, ...
367
grab "W-A-1", :ScreenJump1
368
grab "W-A-2", :ScreenJump2
369
grab "W-A-3", :ScreenJump3
370
grab "W-A-4", :ScreenJump4
371

    
372
# Force reload of config and sublets
373
grab "W-C-r", :SubtleReload
374

    
375
# Force restart of subtle
376
grab "W-C-S-r", :SubtleRestart
377

    
378
# Quit subtle
379
grab "W-C-q", :SubtleQuit
380

    
381
# Move current window
382
grab "W-B1", :WindowMove
383

    
384
# Resize current window
385
grab "W-B3", :WindowResize
386

    
387
# Toggle floating mode of window
388
grab "W-f", :WindowFloat
389

    
390
# Launcher
391
grab "W-space" do Subtle::Contrib::Launcher.run; end
392

    
393
# Toggle sticky mode of window (will be visible on all views)
394
#grab "W-C-s", :WindowStick
395
grab "W-C-s" do |c| c.toggle_stick; c.tags = [ Subtlext::View.current.name ]; end
396

    
397
# Raise window
398
grab "W-r", :WindowRaise
399

    
400
# Lower window
401
grab "W-m", :WindowLower
402

    
403
# Select next windows
404
grab "W-h",  :WindowLeft
405
grab "W-j",  :WindowDown
406
grab "W-k",    :WindowUp
407
grab "W-l", :WindowRight
408

    
409
# Kill current window
410
grab "W-S-k", :WindowKill
411

    
412
# Cycle between given gravities
413
#grab "W-KP_7", [ :top_left,     :top_left66,     :top_left33     ]
414
#grab "W-KP_8", [ :top,          :top66,          :top33          ]
415
#grab "W-KP_9", [ :top_right,    :top_right66,    :top_right33    ]
416
#grab "W-KP_4", [ :left,         :left66,         :left33         ]
417
#grab "W-KP_5", [ :center,       :center66,       :center33       ]
418
#grab "W-KP_6", [ :right,        :right66,        :right33        ]
419
#grab "W-KP_1", [ :bottom_left,  :bottom_left66,  :bottom_left33  ]
420
#grab "W-KP_2", [ :bottom,       :bottom66,       :bottom33       ]
421
#grab "W-KP_3", [ :bottom_right, :bottom_right66, :bottom_right33 ]
422

    
423
# In case no numpad is available e.g. on notebooks
424
grab "W-q", [ :top_left66,   :top_left50,                     ]
425
grab "W-w", [ :top,                                           ]
426
grab "W-e", [ :top_right,    :top_right33,    :top_right50    ]
427
grab "W-a", [ :left,         :left66,                         ]
428
grab "W-d", [ :right,        :right33,        :right66        ]
429
grab "W-y", [ :bottom_left,  :bottom_left33                   ]
430
grab "W-x", [ :bottom,       :bottom33                        ]
431
grab "W-c", [ :bottom_right, :bottom_right33                  ]
432

    
433
# Exec programs
434

    
435
grab "W-Return", "urxvt"
436

    
437
grab "W-S-b", "firefox"
438
grab "W-S-v", "gvim"
439
grab "W-S-l", "GTK2_RC_FILES=/home/crshd/.gtkrc-2.0-oo libreoffice"
440

    
441
grab "W-S-w", "export DISPLAY=:0.0; gempaper set"
442
grab "W-S-o", "dmount2"
443

    
444
# tmux sessions
445
grab "W-t i", "urxvt -name irc -e launchtmux irc"
446
grab "W-t r", "urxvt -name rails -e launchtmux rails"
447
grab "W-t z", "urxvt -name tmux -e launchtmux tmux"
448
#grab "W-u", "dmux"
449

    
450
# terminal progs
451
grab "W-u m", "urxvt -name mutt -e mutt"
452
grab "W-u n", "urxvt -name ncmpcpp -e ncmpcpp"
453

    
454
# Run Ruby lambdas
455
grab "S-F2" do |c|
456
  puts c.name
457
end
458

    
459
grab "S-F3" do
460
  puts Subtlext::VERSION
461
end # }}}
462

    
463
# == Tags# {{{
464
#
465
# Tags are generally used in subtle for placement of windows. This placement is# {{{
466
# strict, that means that - aside from other tiling window managers - windows
467
# must have a matching tag to be on a certain view. This also includes that
468
# windows that are started on a certain view will not automatically be placed
469
# there.
470
#
471
# There are to ways to define a tag:
472
#
473
# === Simple
474
#
475
# The simple way just needs a name and a regular expression to just handle the
476
# placement:
477
#
478
# Example:
479
#
480
#  tag "terms", "terms"
481
#
482
# === Extended
483
#
484
# Additionally tags can do a lot more then just control the placement - they
485
# also have properties than can define and control some aspects of a window
486
# like the default gravity or the default screen per view.
487
#
488
# Example:
489
#
490
#  tag "terms" do
491
#    match   "xterm|[u]?rxvt"
492
#    gravity :center
493
#  end
494
#
495
# === Default
496
#
497
# Whenever a window has no tag it will get the default tag and be placed on the
498
# default view. The default view can either be set by the user with adding the
499
# default tag to a view by choice or otherwise the first defined view will be
500
# chosen automatically.
501
#
502
# === Properties
503
#
504
# [*float*]     This property either sets the tagged client floating or prevents
505
#               it from being floating depending on the value.
506
#
507
#               Example: float true
508
#
509
# [*full*]      This property either sets the tagged client to fullscreen or
510
#               prevents it from being set to fullscreen depending on the value.
511
#
512
#               Example: full true
513
#
514
# [*geometry*]  This property sets a certain geometry as well as floating mode
515
#               to the tagged client, but only on views that have this tag too.
516
#               It expects an array with x, y, width and height values whereas
517
#               width and height must be >0.
518
#
519
#               Example: geometry [100, 100, 50, 50]
520
#
521
# [*gravity*]   This property sets a certain to gravity to the tagged client,
522
#               but only on views that have this tag too.
523
#
524
#              Example: gravity :center
525
#
526
# [*match*]    This property adds matching patterns to a tag, a tag can have
527
#              more than one. Matching works either via plaintext, regex
528
#              (see man regex(7)) or window id. Per default tags will only
529
#              match the WM_NAME and the WM_CLASS portion of a client, this
530
#              can be changed with following possible values:
531
#
532
#              [*:name*]      Match the WM_NAME
533
#              [*:instance*]  Match the first (instance) part from WM_CLASS
534
#              [*:class*]     Match the second (class) part from WM_CLASS
535
#              [*:role*]      Match the window role
536
#
537
#              Example: match :instance => "urxvt"
538
#                       match [:role, :class] => "test"
539
#                       match "[xa]+term"
540
#
541
# [*exclude*]  This property works exactly the same way as *match*, but it
542
#              excludes clients that match from this tag. That can be helpful
543
#              with catch-all tags e.g. for console apps.
544
#
545
#              Example: exclude :instance => "irssi"
546
#
547
# [*resize*]   This property either enables or disables honoring of client
548
#              resize hints and is independent of the global option.
549
#
550
#              Example: resize true
551
#
552
# [*stick*]    This property either sets the tagged client to stick or prevents
553
#              it from being set to stick depending on the value. Stick clients
554
#              are visible on every view.
555
#
556
#              Example: stick true
557
#
558
# [*type*]     This property sets the [[Tagging|tagged]] client to be treated
559
#              as a specific window type though as the window sets the type
560
#              itself. Following types are possible:
561
#
562
#              [*:desktop*]  Treat as desktop window (_NET_WM_WINDOW_TYPE_DESKTOP)
563
#              [*:dock*]     Treat as dock window (_NET_WM_WINDOW_TYPE_DOCK)
564
#              [*:toolbar*]  Treat as toolbar windows (_NET_WM_WINDOW_TYPE_TOOLBAR)
565
#              [*:splash*]   Treat as splash window (_NET_WM_WINDOW_TYPE_SPLASH)
566
#              [*:dialog*]   Treat as dialog window (_NET_WM_WINDOW_TYPE_DIALOG)
567
#
568
#              Example: type :desktop
569
#
570
# [*urgent*]   This property either sets the tagged client to be urgent or
571
#              prevents it from being urgent depending on the value. Urgent
572
#              clients will get keyboard and mouse focus automatically.
573
#
574
#              Example: urgent true
575
#
576
# === Link
577
#
578
# http://subforge.org/wiki/subtle/Tagging # }}}
579

    
580
# Simple tags
581
tag "browser", "uzbl|opera|firefox|navigator"
582
tag "flash", "<unknown>|exe|operapluginwrapper|npviewer.bin"
583
tag "gfx", "inkscape|scribus|gimp|bibble5"
584
tag "office", "grisbi|libreoffice"
585

    
586
# Placement
587

    
588
tag "irc" do
589
  match   "irc"
590
  gravity :right66
591
end
592

    
593
tag "mutt" do
594
  match   "mutt"
595
  gravity :top_left50
596
end
597

    
598
tag "ncmpcpp" do
599
  match   "ncmpcpp"
600
  gravity :bottom_left
601
end
602

    
603
tag "editor" do
604
  match "gvim"
605
  resize false
606
  gravity :left66
607
end
608

    
609
tag "devel" do
610
  match   "rails"
611
  gravity :right33
612
end
613

    
614
tag "fixed" do
615
  geometry [ 10, 10, 100, 100 ]
616
  stick    true
617
end
618

    
619
tag "gravity" do
620
  gravity :center
621
end
622

    
623
# Modes
624
tag "stick" do
625
  match "lpr|feh"
626
  float true
627
  stick true
628
end
629

    
630
tag "float" do
631
  match "display|jd-Main|snes9x-gtk"
632
  float true
633
end
634

    
635
# Gimp
636
tag "gimp_image" do
637
  match   :role => "gimp-image-window"
638
  gravity :gimp_image
639
end
640

    
641
tag "gimp_toolbox" do
642
  match   :role => "gimp-toolbox"
643
  gravity :gimp_toolbox
644
end
645

    
646
tag "gimp_dock" do
647
  match   :role => "gimp-dock"
648
  gravity :gimp_dock
649
end
650

    
651
# Wine
652
tag "wine" do
653
  match "wine"
654
  float true
655
end # }}}
656

    
657
# == Views # {{{
658
#
659
# Views are the virtual desktops in subtle, they show all windows that share a# {{{
660
# tag with them. Windows that have no tag will be visible on the default view
661
# which is the view with the default tag or the first defined view when this
662
# tag isn't set.
663
#
664
# Like tags views can be defined in two ways:
665
#
666
# === Simple
667
#
668
# The simple way is exactly the same as for tags:
669
#
670
# Example:
671
#
672
#   view "terms", "terms"
673
#
674
# === Extended
675
#
676
# The extended way for views is also similar to the tags, but with fewer
677
# properties.
678
#
679
# Example:
680
#
681
#  view "terms" do
682
#    match "terms"
683
#    icon  "/usr/share/icons/icon.xbm"
684
#  end
685
#
686
# === Properties
687
#
688
# [*match*]      This property adds a matching pattern to a view. Matching
689
#                works either via plaintext or regex (see man regex(7)) and
690
#                applies to names of tags.
691
#
692
#                Example: match "terms"
693
#
694
# [*dynamic*]    This property hides unoccupied views, views that display no
695
#                windows.
696
#
697
#                Example: dynamic true
698
#
699
# [*icon*]       This property adds an icon in front of the view name. The
700
#                icon can either be path to an icon or an instance of
701
#                Subtlext::Icon.
702
#
703
#                Example: icon "/usr/share/icons/icon.xbm"
704
#                         icon Subtlext::Icon.new("/usr/share/icons/icon.xbm")
705
#
706
# [*icon_only*]  This property hides the view name from the view buttons, just
707
#                the icon will be visible.
708
#
709
#                Example: icon_only true
710
#
711
#
712
# === Link
713
#
714
# http://subforge.org/wiki/subtle/Tagging# }}}
715

    
716
view "one" do
717
  match "default|mutt|irc|ncmpcpp"
718
  icon "/home/crshd/.local/share/subtle/icons/terminal.xbm"
719
  icon_only true
720
end
721

    
722
view "two" do
723
  match "browser|flash"
724
  icon "/home/crshd/.local/share/subtle/icons/fox.xbm"
725
  icon_only true
726
end
727

    
728
view "three" do
729
  match "editor|devel"
730
  icon "/home/crshd/.local/share/subtle/icons/quote.xbm"
731
  icon_only true
732
end
733

    
734
view "four" do
735
  match "gimp_.*|gfx"
736
  icon "/home/crshd/.local/share/subtle/icons/paint.xbm"
737
  icon_only true
738
end
739

    
740
view "five" do
741
  match "float|wine|utorrent|skype"
742
  icon "/home/crshd/.local/share/subtle/icons/game.xbm"
743
  icon_only true
744
end
745

    
746
view "six" do
747
  match "office"
748
  icon "/home/crshd/.local/share/subtle/icons/scroll.xbm"
749
  icon_only true
750
end# }}}
751

    
752
# == Sublets# {{{
753
#
754
# Sublets are Ruby scripts that provide data for the panel and can be managed
755
# with the sur script that comes with subtle.
756
#
757
# === Example
758
#
759
#  sur install clock
760
#  sur uninstall clock
761
#  sur list
762
#
763
# === Configuration
764
#
765
# All sublets have a set of configuration values that can be changed directly
766
# from the config of subtle.
767
#
768
# There are three default properties, that can be be changed for every sublet:
769
#
770
# [*interval*]    Update interval of the sublet
771
# [*foreground*]  Default foreground color
772
# [*background*]  Default background color
773
#
774
# sur can also give a brief overview about properties:
775
#
776
# === Example
777
#
778
#   sur config clock
779
#
780
# The syntax of the sublet configuration is similar to other configuration
781
# options in subtle:
782
#
783
# === Example
784

    
785
sublet :wifi do
786
  interval      1
787
  foreground    "#cc7833"
788
  background    "#151515"
789
end
790

    
791
sublet :fuzzytime do
792
  locale        "de"
793
end
794

    
795
sublet :maildir_mod do
796
  interval      5
797
  dir           "/media/data/Mail/Gmail/INBOX/new"
798
  label         "Gmail"
799
end
800

    
801
sublet :jdownloader do
802
  interval      5
803
end
804

    
805
sublet :pacman do
806
  interval      60
807
end
808

    
809
# }}}
810

    
811
# == Hooks# {{{
812
#
813
# And finally hooks are a way to bind Ruby scripts to a certain event.
814
#
815
# Following hooks exist so far:
816
#
817
# [*:client_create*]    Called whenever a window is created
818
# [*:client_configure*] Called whenever a window is configured
819
# [*:client_focus*]     Called whenever a window gets focus
820
# [*:client_kill*]      Called whenever a window is killed
821
#
822
# [*:tag_create*]       Called whenever a tag is created
823
# [*:tag_kill*]         Called whenever a tag is killed
824
#
825
# [*:view_create*]      Called whenever a view is created
826
# [*:view_configure*]   Called whenever a view is configured
827
# [*:view_jump*]        Called whenever the view is switched
828
# [*:view_kill*]        Called whenever a view is killed
829
#
830
# [*:tile*]             Called on whenever tiling would be needed
831
# [*:reload*]           Called on reload
832
# [*:start*]            Called on start
833
# [*:exit*]             Called on exit
834
#
835
# === Example
836
#
837
# This hook will print the name of the window that gets the focus:
838
#
839
#   on :client_focus do |c|
840
#     puts c.name
841
#   end
842
#
843
# === Link
844
#
845
# http://subforge.org/wiki/subtle/Hooks
846

    
847
on :start do
848
  # Some autostart stuff
849
  # Subtlext::Subtle.spawn '(sleep 5; dzen_meters)'
850
  # Subtlext::Subtle.spawn 'tail -f /home/crshd/.weechat/pipe | dzen2 -ta r -tw 145 -h 17 -l 6 -x 1000 -y 800 -bg "#151515" -fn "Pragmata:size=7"'
851
  # Subtlext::Subtle.spawn 'xsetroot -solid "#505050"'
852
  Subtlext::Subtle.spawn 'feh --bg-center ~/.wall.png'
853

    
854
  # Create missing tags
855
  views = Subtlext::View.all.map { |v| v.name }
856
  tags  = Subtlext::Tag.all.map { |t| t.name }
857
 
858
  views.each do |v|
859
    unless(tags.include?(v))
860
      t = Subtlext::Tag.new(v)
861
      t.save
862
    end
863
  end
864
end
865

    
866
#on :client_create do |c|
867
#  view = Subtlext::View.current
868
#  tags = c.tags.map { |t| t.name }
869
# 
870
#  # Add tag to view
871
#  view.tag(view.name) unless(view.tags.include?(view.name))
872
# 
873
#  # Exclusive for clients with default tag only
874
#  if(tags.include?("default") and 1 == tags.size)
875
#    c.tags = [ view.name ]
876
#  end
877
#    
878
#  # Focus client on creation
879
#  c.views.first.jump
880
#  c.focus
881
#end
882

    
883
#}}}
884

    
885
#  vim: set ts=2 sw=2 tw=0 :