guest@dotshare [~/groups/wms/subtle] $ ls subtle/ | cat

subtle (scrot, raw, dl) (+2 likes)

unexist Jun 23, 2011 (wms/subtle)

SCROT

  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
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
#
# This program can be distributed under the terms of the GNU GPL.
# See the file COPYING.
#
# $Id: .config/subtle/subtle.rb,v 359 2011/06/08 12:24:57 unexist $
#

require "socket"

# Contrib {{{
begin
  require "#{ENV["HOME"]}/projects/subtle-contrib/ruby/launcher.rb"
  require "#{ENV["HOME"]}/projects/subtle-contrib/ruby/selector.rb"
  require "#{ENV["HOME"]}/projects/subtle-contrib/ruby/merger.rb"

  Subtle::Contrib::Launcher.fonts = [
    "xft:Envy Code R:pixelsize=80",
    "xft:Envy Code R:pixelsize=13"
  ]

  Subtle::Contrib::Launcher.browser_screen_num = 0

  Subtle::Contrib::Selector.font = "xft:Envy Code R:pixelsize=13"
  Subtle::Contrib::Merger.font   = "xft:Envy Code R:pixelsize=13"
rescue LoadError
end # }}}

# Options {{{
set :step,      5
set :snap,      10
set :gravity,   :center
set :urgent,    false
set :resize,    false
set :tiling,    false
set :font,      "xft:Envy Code R:pixelsize=13"
set :separator, "ยท"
# }}}

# Screens {{{
screen 1 do
  stipple false
  top     [:title, :spacer, :views, :center, :clock, :fuzzytime, :separator, :sublets, :center]
  bottom  []
  view    1
end

screen 2 do
  stipple false
  top     [:views, :spacer, :title, :tray, :center, :mpd, :separator, :volume, :center]
  bottom  []
  view    0
end
# }}}

# Styles {{{
style :title do
  padding     2, 8
  border      "#1a1a1a", 0
  foreground  "#ffffff"
  background  "#1a1a1a"
end

style :views do
  padding     1, 8, 2, 8
  border      "#1a1a1a", 0
  foreground  "#777777"
  background  "#1a1a1a"
  margin_bottom  1
end

style :focus do
  padding        1, 8, 0, 8
  foreground     "#ffffff"
  background     "#1a1a1a"
  border_bottom  "#595959", 3
end

style :occupied do
  padding        1, 8, 0, 8
  foreground     "#a8a8a8"
  background     "#1a1a1a"
  border_bottom  "#404040", 3
end

style :urgent do
  padding        1, 8, 0, 8
  border         0
  foreground     "#a8a8a8"
  background     "#1a1a1a"
  border_bottom  "#DF8787", 3
end

style :sublets do
  padding        2, 8
  border         "#1a1a1a", 0
  foreground     "#a8a8a8"
  background     "#1a1a1a"
end

style :separator do
  padding        1, 0, 2, 0
  border         0
  background     "#1a1a1a"
  foreground     "#DF8787"
  margin_bottom  1
end

style :clients do
  active      "#a8a8a8", 2
  inactive    "#404040", 2
  margin      3
end

style :subtle do
  padding     0
  panel       "#1a1a1a"
  background  "#595959"
  stipple     "#595959"
end
# }}}

# Gravities {{{
gravity :top_left,       [   0,   0,  50,  50 ]
gravity :top_left66,     [   0,   0,  50,  66 ]
gravity :top_left33,     [   0,   0,  50,  34 ]

gravity :top,            [   0,   0, 100,  50 ]
gravity :top75,          [   0,   0, 100,  75 ]
gravity :top66,          [   0,   0, 100,  66 ]
gravity :top33,          [   0,   0, 100,  34 ]

gravity :top_right,      [  50,   0,  50,  50 ]
gravity :top_right66,    [  50,   0,  50,  66 ]
gravity :top_right33,    [  50,   0,  50,  33 ]

gravity :left,           [   0,   0,  50, 100 ]
gravity :left66,         [   0,   0,  66, 100 ]
gravity :left33,         [   0,   0,  33, 100 ]

gravity :center,         [   0,   0, 100, 100 ]
gravity :center66,       [  17,  17,  66,  66 ]
gravity :center33,       [  33,  33,  33,  33 ]

gravity :right,          [  50,   0,  50, 100 ]
gravity :right66,        [  34,   0,  66, 100 ]
gravity :right33,        [  67,  50,  33, 100 ]

gravity :bottom_left,    [   0,  50,  50,  50 ]
gravity :bottom_left66,  [   0,  34,  50,  66 ]
gravity :bottom_left33,  [   0,  67,  50,  33 ]
gravity :bottom_left25,  [   0,  75,  50,  25 ]

gravity :bottom,         [   0,  50, 100,  50 ]
gravity :bottom66,       [   0,  34, 100,  66 ]
gravity :bottom33,       [   0,  67, 100,  33 ]

gravity :bottom_right,   [  50,  50,  50,  50 ]
gravity :bottom_right66, [  50,  34,  50,  66 ]
gravity :bottom_right33, [  50,  67,  50,  33 ]
gravity :bottom_right25, [  50,  75,  50,  25 ]

gravity :gimp_image,     [  10,   0,  80, 100 ]
gravity :gimp_toolbox,   [   0,   0,  10, 100 ]
gravity :gimp_dock,      [  90,   0,  10, 100 ]

gravity :dia_toolbox,    [   0,   0,  15, 100 ]
gravity :dia_window,     [  15,   0,  85, 100 ]
# }}}

# Grabs {{{
# Host specific
host     = Socket.gethostname
modkey   = "W"
gravkeys = [ "KP_7", "KP_8", "KP_9", "KP_4", "KP_5", "KP_6", "KP_1", "KP_2", "KP_3" ]

if("telas" == host || "mockra" == host) #< Netbooks
  gravkeys = [ "q", "w", "e", "a", "s", "d", "y", "x", "c" ]
elsif("test" == host) #< Usually VMs
  modkey = "A"
end

# Views and screens
(1..6).each do |i|
  grab modkey + "-#{i}",   "ViewSwitch#{i}".to_sym
  grab modkey + "-S-#{i}", "ViewJump#{i}".to_sym
  grab modkey + "-F#{i}",  "ScreenJump#{i}".to_sym
end

# Windows
grab modkey + "-B1",      :WindowMove
grab modkey + "-B3",      :WindowResize
grab modkey + "-S-f",     :WindowFloat
grab modkey + "-S-space", :WindowFull
grab modkey + "-S-s",     :WindowStick
grab modkey + "-S-equal", :WindowZaphod
grab modkey + "-r",       :WindowRaise
grab modkey + "-l",       :WindowLower
grab modkey + "-Left",    :WindowLeft
grab modkey + "-Down",    :WindowDown
grab modkey + "-Up",      :WindowUp
grab modkey + "-Right",   :WindowRight
grab modkey + "-k",       :WindowKill
grab modkey + "-h", lambda { |c| c.retag }

# Reload/restart
grab modkey + "-C-q",     :SubtleQuit
grab modkey + "-C-r",     :SubtleReload
grab modkey + "-C-A-r",   :SubtleRestart

# Gravity keys and focus
gravities = [
  [:top_left, :top_left33, :top_left66, :top_left75],
  [:top, :top33, :top66, :top75],
  [:top_right, :top_right33, :top_right66, :top_right75],
  [:left, :left33, :left66],
  [:center, :center33, :center66],
  [:right, :right33, :right66],
  [:bottom_left, :bottom_left25, :bottom_left33, :bottom_left66],
  [:bottom, :bottom33, :bottom66],
  [:bottom_right, :bottom_right25, :bottom_right33, :bottom_right66]
]

gravities.each_index do |i|
  grab "%s-%s" % [ modkey, gravkeys[i] ], gravities[i]

  grab "%s-C-%s" % [ modkey, gravkeys[i] ], lambda {
    c = Subtlext::Client.visible.select { |c|
      gravities[i].include?(c.gravity.name.to_sym)
    }

    c.first.focus unless(c.empty?)
  }
end

# Multimedia keys
grab "XF86AudioMute",        :VolumeToggle
grab "XF86AudioRaiseVolume", :VolumeRaise
grab "XF86AudioLowerVolume", :VolumeLower
grab "XF86AudioPlay",        :MpdToggle
grab "XF86AudioStop",        :MpdStop
grab "XF86AudioNext",        :MpdNext
grab "XF86AudioPrev",        :MpdPrevious

grab modkey + "-m", "mpc current | tr -d '\n' | xclip"

# Programs
grab modkey + "-Return", "urxvt"
grab modkey + "-g", "gvim"

# Contrib
grab "W-x" do
  Subtle::Contrib::Launcher.run
end

grab "W-z" do
  Subtle::Contrib::Selector.run
end

grab "W-u" do
  Subtle::Contrib::Merger.run
end

# Scratchpad
grab "W-y" do
  if((c = Subtlext::Client["scratch"]))
    c.toggle_stick
    c.focus
  elsif((c = Subtlext::Subtle.spawn("urxvt -name scratch")))
    c.tags  = [] 
    c.flags = [ :stick ]
  end
end

# Pychrom
grab modkey + "-p" do
  if((t = Subtlext::Tray[:pychrom]))
    t.click
  else
    Subtlext::Subtle.spawn("pychrom")
  end
end

# Tabbing
grab modkey + "-Tab" do
  Subtlext::Client.recent[1].focus
end

# Set layout
grab modkey + "-numbersign" do
  # Find stuff
  tag            = Subtlext::Tag["editor"]
  urxvt1, urxvt2, editor =
    [ "urxvt1", "urxvt2", "gvim" ].map { |name| Subtlext::Client[name] }

  # Add tags
  urxvt1 + tag
  urxvt2 + tag

  # Set gravities
  urxvt1.gravity = { :editor => :bottom_right25 }
  urxvt2.gravity = { :editor => :bottom_left25 }
  editor.gravity = { :editor => :top75 }

  Subtlext::Screen[1].view = Subtlext::View["editor"]
end
# }}}

# Tags {{{
tag "terms" do
  match    instance: "xterm|urxvt"
  gravity  :center
  resize   true
end

tag "test" do
  match instance: "test", class: "urxvt"
  geometry [ 943, 548, 640, 480 ]
end

tag "browser" do
  match "navigator|(google\-)?chrom[e|ium]"

  if("proteus" == host or "pc03112" == host)
    gravity :top75
  else
    gravity :center
  end
end

tag "pdf" do
  match "apvlv|evince"
  stick true
end

tag "editor" do
  match  "[g]?vim"
  resize true

  if("mockra" == host or "proteus" == host or "pc03112" == host)
    gravity :top75
  else
    gravity :center
  end
end

tag "xeph640" do
  match    "xeph640"
  geometry [ 943, 548, 640, 480 ]
end

tag "xeph800" do
  match    "xeph800"
  geometry [ 855, 172, 800, 800 ]
end


tag "android" do
  match    :name => "5554:AVD"
  geometry [ 873, 47, 791, 534 ]
end

tag "mplayer" do
  match   "mplayer"
  float   true
  stick   true
  #urgent  true
  position [ 2650, 50 ]
end

tag "stick" do
  match  "dialog|subtly|python|gtk.rb|display|pychrom|skype|xev"
  stick  true
  float  true
end

tag "urgent" do
  match  "sun-awt-X11-XDialogPeer"
  type   :dialog
  stick  true
  urgent true
  float  true
end

tag "void" do
  match "jd-Main|Virtualbox"
end

tag "powerfolder" do
  match "de-dal33t-powerfolder-PowerFolder"
  float true
  stick true
end

tag "pms" do
  match "net-pms-PMS"
  resize true
end

tag "dialogs" do
  match :type => [ :dialog, :splash ]
  stick true
end

tag "flash" do
  match "exe|<unknown>"
  stick true
end

tag "one" do
  match    "urxvt2"
  gravity  :bottom_left
end

tag "one25" do
  match    "urxvt2"
  gravity  :bottom_left25
end

tag "two" do
  match    "urxvt2"
  gravity  :bottom
end

tag "three25" do
  match    "urxvt1"
  gravity  :bottom_right25
end

tag "seven" do
  match    "urxvt1"
  gravity  :top_left
end

tag "eight" do
  match    "urxvt1"
  gravity  :top
end

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

tag "gimp_scum" do
  match :role => "gimp-.*|screenshot"
end

tag "dia_window" do
  match   :role => "diagram_window"
  gravity :dia_window
end

tag "dia_toolbox" do
  match   :role => "toolbox_window"
  gravity :dia_toolbox
end

tag "inkscape" do
  match "inkscape"
end

tag "xfontsel" do
  match    "xfontsel"
  geometry [464, 433, 676, 113]
  stick    true
end

tag "xev" do
  match    :name => "Event[ ]Tester"
  geometry [1213, 98, 377, 321]
  float    true
  stick    true
end
# }}}

# Views {{{
if("mockra" == host or "proteus" == host or "pc03112" == host)
  www_re    = "browser|one25|three25"
  test_re   = "xeph[0-9]+|android|three25"
  editor_re = "android|editor|one25|three25"
  icons     = true
else
  www_re    = "browser"
  test_re   = "android|xeph[0-9]+|eight|one$|test"
  editor_re = "editor"
  icons     = true
end

iconpath = "#{ENV["HOME"]}/.local/share/icons"

view "terms" do
  match     "terms|eight|two"
  icon      "#{iconpath}/terminal.xbm"
  icon_only icons
end

view "www" do
  match     www_re
  icon      "#{iconpath}/world.xbm"
  icon_only icons
end

view "void" do
  match     "default|void|powerfolder|pms"
  icon      "#{iconpath}/quote.xbm"
  icon_only icons
end

view "sketch" do
  match     "inkscape|dia_*|gimp_.*"
  icon      "#{iconpath}/paint.xbm"
  icon_only icons
end

view "test" do
  match     test_re
  icon      "#{iconpath}/bug.xbm"
  icon_only icons
end

view "editor" do
  match     editor_re
  icon      "#{iconpath}/ruby.xbm"
  icon_only icons
end
# }^}}

# Sublets {{{
sublet :clock do
  format_string "%a %b %d,"
  icon_fg "#777777"
end

[ :cpu, :jdownloader, :wifi, :mpd, :volume ].each do |sublet|
  sublet sublet do
    icon_fg "#777777"
  end
end
# }}}

# Commands {{{
def xbmc
  Subtlext::Screen[0].view = :terms
  Subtlext::Screen[1].view = :browser

  Subtlext::Subtle.spawn("xinit xbmc -- :#{rand(10)}")
end # }}}

CLICK TO VIEW

x

Comments

dipilibupap said about 13 years ago

It doesn’t get much better does it :)

edited about 13 years ago

unexist said about 13 years ago

Nope, no need for any improvements. :D

bulters said about 13 years ago

What do you use as ‘launcher’? (i.e. the thingy displaying “scrot_”)

d33n said about 13 years ago

that would be the launcher.rb from subtle-contrib!