forked from Paul-S/Subtle-Configs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
subtle.rb
executable file
·622 lines (516 loc) · 16 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
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
require "socket"
require "subtle/subtlext"
set :step, 5
set :snap, 10
set :gravity, :center
set :urgent, true
set :resize, false
set :font, "xft:arial:bold:size=10"
#set :font, "-*-*-medium-*-*-*-10-*-*-*-*-*-*-*"
set :separator, "«»"
#set :separator, "|"
set :wmname, "LG3D"
begin
require "#{ENV["HOME"]}/bin/launcher/launcher.rb"
require "#{ENV["HOME"]}/bin/selector.rb"
require "#{ENV["HOME"]}/bin/merger.rb"
Subtle::Contrib::Launcher.fonts = [
"xft:Liberation Sans:pixelsize=20:antialias=true",
"xft:Liberation Sans:pixelsize=10:antialias=true"
]
Subtle::Contrib::Selector.font = "xft:Liberation Sans:pixelsize=20:antialias=true"
Subtle::Contrib::Merger.font = "xft:Liberation Sans:pixelsize=20:antialias=true"
rescue LoadError
end # }}}
screen 1 do
# Add stipple to panels
stipple false
arch = Subtlext::Icon.new("/home/paul/.icons/subtle/subtle1.xbm")
# top [ :netchart, :separator, :smpd, :spacer, :cpu, :separator, :battery, :separator, :volume, :separator, arch ]
top [ ]
# top [ :sublets ]
bottom [ :views, :title, :spacer, :tasks, :separator, :clock, :separator, :notify, :tray ]
end
#Blue
style :views do
padding 2, 5, 2, 5
border_bottom "#505050", 2
foreground "#505050"
background "#ffffff"
#background "#080808"
end
style :title do
padding 2, 5, 2, 5
border "#080808", 0
foreground "#d16587"
background "#ffffff"
#background "#080808"
end
style :focus do
padding 2, 5, 2, 5
border_bottom "#ff0000", 2
foreground "#d16587"
background "#ffffff"
#background "#080808"
end
style :urgent do
padding 2, 5, 2, 5
border_bottom "#e67373", 2
#foreground "#FFFFFF"
foreground "#080808"
background "#e67373"
end
style :occupied do
padding 2, 5, 2, 5
border_bottom "#708ee9", 2
foreground "#708ee9"
background "#ffffff"
# background "#080808"
end
style :sublets do
padding 2, 5, 2, 5
border "#708ee9", 0
foreground "#6699ff"
background "#ffffff"
#background "#080808"
end
style :separator do
padding 1, 0, 3, 3
border 0
background "#ffffff"
#background "#080808"
foreground "#080808"
end
style :clients do
active "#708ee9", 1
#inactive "#080808", 1
inactive "#ffffff", 1
margin 0
end
style :subtle do
padding 24, 0, 0, 0
#panel_top "#080808"
#panel_bottom "#080808"
panel_top "#ffffff"
panel_bottom "#ffffff"
stipple "#757575"
end
#Mpd Sublet Colours
col1 = Subtlext::Color.new("#52d017")
col2 = Subtlext::Color.new("#e67373")
#col3 = Subtlext::Color.new("#ffffff")
col3 = Subtlext::Color.new("#080808")
col4 = Subtlext::Color.new("#d16587")
col5 = Subtlext::Color.new("#0D25FD")
col6 = Subtlext::Color.new("#6699ff")
# Full
gravity :full, [ 0, 0, 100, 100 ]
# Top left
gravity :top_left, [ 100, 0, 50, 50 ]
gravity :top_left66, [ 100, 0, 50, 66 ]
gravity :top_left33, [ 100, 0, 50, 34 ]
# Top
gravity :top, [ 100, 0, 100, 50 ]
gravity :top66, [ 100, 0, 100, 66 ]
gravity :top33, [ 100, 0, 100, 34 ]
# Top right
gravity :top_right, [ 100, 50, 50, 50 ]
gravity :top_right66, [ 100, 50, 50, 66 ]
gravity :top_right33, [ 100, 50, 50, 34 ]
# Left
gravity :left, [ 0, 50, 50, 100 ]
gravity :left66, [ 0, 50, 50, 66 ]
gravity :left33, [ 0, 50, 25, 34 ]
# Center
gravity :center, [ 0, 0, 100, 100 ]
gravity :center66, [ 0, 0, 100, 66 ]
gravity :center33, [ 0, 0, 100, 34 ]
# Right
gravity :right, [ 50, 0, 50, 100 ]
gravity :right66, [ 50, 0, 50, 66 ]
gravity :right33, [ 50, 0, 50, 34 ]
# Bottom left
gravity :bottom_left, [ 0, 50, 50, 50 ]
gravity :bottom_left66, [ 0, 50, 50, 66 ]
gravity :bottom_left33, [ 0, 50, 50, 34 ]
# Bottom
gravity :bottom, [ 50, 0, 100, 100 ]
gravity :bottom66, [ 50, 0, 100, 66 ]
gravity :bottom33, [ 50, 0, 100, 34 ]
# Bottom right
gravity :bottom_right, [ 0, 50, 50, 50 ]
gravity :bottom_right66, [ 0, 50, 50, 66 ]
gravity :bottom_right33, [ 0, 50, 50, 34 ]
# Gimp
#gravity :gimp_image, [ 50, 50, 80, 100 ]
#gravity :gimp_toolbox, [ 0, 0, 10, 100 ]
#gravity :gimp_dock, [ 100, 0, 10, 100 ]
#Gimp
gravity :gimp_image, [ 10, 0, 80, 100 ]
gravity :gimp_toolbox, [ 0, 0, 10, 100 ]
gravity :gimp_dock, [ 90, 0, 10, 100 ]
# Scratchpad
gravity :scratchpad, [ 25, 25, 50, 50 ]
# Jump to view1, view2, ...
grab "W-S-1", :ViewJump1
grab "W-S-2", :ViewJump2
grab "W-S-3", :ViewJump3
grab "W-S-4", :ViewJump4
grab "W-S-5", :ViewJump5
grab "W-S-6", :ViewJump6
grab "W-S-7", :ViewJump7
# Switch current view
grab "W-1", :ViewSwitch1
grab "W-2", :ViewSwitch2
grab "W-3", :ViewSwitch3
grab "W-4", :ViewSwitch4
grab "W-5", :ViewSwitch5
grab "W-6", :ViewSwitch6
grab "W-7", :ViewSwitch7
# Select next and prev view */
grab "KP_Add", :ViewNext
grab "KP_Subtract", :ViewPrev
# Move mouse to screen1, screen2, ...
grab "W-A-1", :ScreenJump1
grab "W-A-2", :ScreenJump2
grab "W-A-3", :ScreenJump3
grab "W-A-4", :ScreenJump4
grab "W-A-5", :ScreenJump5
grab "W-A-6", :ScreenJump6
grab "W-A-7", :ScreenJump7
#
# = jump next/prev view
#
def jump_next_view
current, views = Subtlext::View.current, Subtlext::View.all
views.each_with_index{|view,idx| views[ (idx+1 >= views.size) ? 0 : idx+1 ].jump if view == current }
end
def jump_prev_view
current, views = Subtlext::View.current, Subtlext::View.all.reverse
views.each_with_index{|view,idx| views[ (idx+1 >= views.size) ? 0 : idx+1 ].jump if view == current }
end
grab("W-Right", &method(:jump_next_view))
grab("W-Left", &method(:jump_prev_view))
grab("W-l", &method(:jump_next_view))
grab("W-h", &method(:jump_prev_view))
# Force restart of subtle
grab "W-C-S-r", :SubtleRestart
# Quit subtle
grab "W-C-q", :SubtleQuit
# Move current window
grab "W-B1", :WindowMove
# Resize current window
grab "W-B3", :WindowResize
# Toggle floating mode of window
grab "A-C-f", :WindowFloat
# Toggle fullscreen mode of window
grab "W-space", :WindowFull
# Toggle sticky mode of window (will be visible on all views)
grab "A-C-t", :WindowStick
# Raise window
grab "W-r", :WindowRaise
# Lower window
grab "W-l", :WindowLower
# Select next windows
grab "W-Left", :WindowLeft
grab "W-Down", :WindowDown
grab "W-Up", :WindowUp
grab "W-Right", :WindowRight
# Kill current window
grab "W-S-c", :WindowKill
grab "A-Tab" do |c|
sel = 0
clients = Subtlext::Client.visible
clients.each_index do |idx|
if(clients[idx].id == c.id)
sel = idx + 1 if(idx < clients.size - 1)
end
end
clients[sel].focus
end
# In case no numpad is available e.g. on notebooks
grab "W-q", [ :top_left, :top_left66, :top_left33 ]
grab "W-w", [ :top, :top66, :top33 ]
grab "W-e", [ :top_right, :top_right66, :top_right33 ]
grab "W-a", [ :left, :left66, :left33 ]
grab "W-s", [ :center, :center66, :center33 ]
grab "W-d", [ :right, :right66, :right33 ]
grab "W-y", [ :bottom_left, :bottom_left66, :bottom_left33 ]
grab "W-x", [ :bottom, :bottom66, :bottom33 ]
#grab "W-c", [ :bottom_right, :bottom_right66, :bottom_right33 ]
# Exec programs
# Contrib
grab "W-S-Return" do
Subtle::Contrib::Launcher.run
end
grab "W-S-z" do
Subtle::Contrib::Selector.run
end
grab "W-S-u" do
Subtle::Contrib::Merger.run
end
grab "W-Return", "urxvtc"
grab "W-t", "thunar"
grab "W-p", "bashrun"
grab "W-c", "chromium"
#grab "W-S-Return", "ruby /home/paul/bin/launcher/launcher.rb"
#grab "W-S-s", "urxvtc -name scratchpad -geometry 80x15+280+500"
#grab "W-S-s", "ruby /home/paul/scripts/styler.rb"
#grab "W-S-s", "urxvtc -name scratchpad"
#grab "W-m", "urxvtc -name mc -e mc"
grab "W-S-m", "urxvtc -name ranger -e ranger"
grab "W-m", "urxvtc -name mc -e mc -S xoria256"
#grab "W-m", "urxvtc -name mc -e mc -S nicedark"
grab "XF86AudioMute", :VolumeToggle
grab "XF86AudioRaiseVolume", :VolumeRaise
grab "XF86AudioLowerVolume", :VolumeLower
grab "S-Return" do
@move_to_view = true
spawn "urxvtc -name mojo"
nil
end
on(:client_create){|client|
if @move_to_view == true
@move_to_view = false
view = Subtlext::View.current
client.tags = view.tags unless client.views.include?(view)
client.gravity = :top_left
end
nil
}
grab "W-S-s" do
if((c = Subtlext::Client["scratchpad"]))
c.toggle_stick
c.focus
elsif((c = Subtlext::Subtle.spawn("urxvtc -name scratchpad")))
c.tags = []
c.flags = [ :stick ]
end
end
grab "A-S-s", "urxvtc -name screen"
grab "A-S-l", "urxvtc -name slrn -e slrn"
grab "A-S-t", "Terminal"
grab "A-S-n", "mpd && urxvtc -name ncmpcpp -e ncmpcpp"
grab "A-S-m", "urxvtc -name mutt -e mutt"
grab "W-S-b", "bashrun"
grab "A-s", "/home/paul/scripts/scrotmenu.sh"
grab "XF86AudioRaiseVolume", "aumix -v +5"
grab "XF86AudioLowerVolume", "aumix -v -5"
# Run Ruby lambdas
grab "S-F2" do |c|
puts c.name
end
grab "S-F3" do
puts Subtlext::VERSION
end
# Simple tags
tag "browser", do match "chromium|uzbl|opera|firefox|navigator|jumanji|default" end
tag "terms", do match "urxvtc|mutt|screen|slrn" end
tag "files", do match "thunar|nautilus|mc|ranger" end
tag "media" do match "ncmpcpp" end
tag "editor", do match "gedit|mousepad|leafpad" end
tag "chat", do match "hotot|pidgin" end
tag "stuff", do match "k3b" end
tag "gimp", do match "gimp_.*" end
# Placement
tag "editor" do
match :instance => "[g]?vim"
resize true
end
tag "bashrun" do
match :instance => "bashrun"
geometry [ 0, 0, 200, 20 ]
stick true
float true
urgent true
end
tag "fixed" do
geometry [ 10, 10, 100, 100 ]
stick true
end
tag "resize" do
match "sakura|gvim"
resize true
end
tag "gravity" do
gravity :center
end
tag "urgent" do
match "urxvtc"
match "mc"
match "ssh"
match "chromium"
match "screen"
match "pidgin"
match "thunar"
match "hotot"
urgent true
end
#Modes
tag "stick" do
match "mplayer"
float true
stick true
end
tag "scratchpad" do
match :instance => "scratchpad"
gravity :scratchpad
urgent false
stick true
end
tag "float" do
#match "scratchpad"
match "display"
match :name => "Copying*";
match :name => "Moving*";
match :name => "File*";
float true
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 "dialogs" do
match :type => "display|dialog|subtly|subtle|preferences"
match :type => :dialog
match :type => :splash
float true
stick true
urgent true
end
tag "xmessage" do
match "xmessage"
float true
stick true
urgent true
end
grab "W-C-r", <<SCRIPT
subtle -k &>/dev/null
reload=$?
if [ $reload -eq 1 ] ; then
xmessage 'Syntax error, reload anyway?' -center -buttons NO:1,YES:0
reload=$?
fi
[ $reload -eq 0 ] && subtler -r
SCRIPT
on :start do
Subtlext::Subtle.spawn "start-pulseaudio-x11"
end
on :start do
Subtlext::Subtle.spawn "urxvtd -q -o -f"
end
on :start do
Subtlext::Subtle.spawn "feh --bg-center /home/paul/downloads/wallpaper/Netbook/19.jpg"
end
on :start do
Subtlext::Subtle.spawn "/home/paul/bin/conky -c ~/.conkyrc.top.right | /home/paul/bin/dzen2 -h '24' -fg '#777777' -bg '#ffffff' -fn 'arial:bold:size=10' -x '512' -y '0' -w '512' -ta right"
end
on :start do
Subtlext::Subtle.spawn "/home/paul/bin/conky -c ~/.conkyrc.top.left | /home/paul/bin/dzen2 -h '24' -fg '#777777' -bg '#ffffff' -fn 'arial:bold:size=10' -x '0' -y '0' -w '512' -ta left"
end
on :start do
Subtlext::Subtle.spawn "xfsettingsd"
end
on :start do
Subtlext::Subtle.spawn "wicd-client"
end
on :start do
Subtlext::Subtle.spawn "pidgin"
end
iconpath = "#{ENV["HOME"]}/.icons/subtle"
view "net" do
match "browser"
icon "#{iconpath}/world.xbm"
icon_only true
end
view "terms" do
match "terms"
exclude :instance => "scratchpad"
icon "#{iconpath}/terminal.xbm"
icon_only true
end
view "files" do
match "files"
icon "#{iconpath}/binder.xbm"
icon_only true
end
view "chat" do
match "chat"
icon "#{iconpath}/balloon.xbm"
icon_only true
end
view "media" do
match "media"
icon "#{iconpath}/movie.xbm"
icon_only true
end
view "stuff" do
match "stuff|editor"
icon "#{iconpath}/notepad.xbm"
icon_only true
end
view "gimp" do
match "gimp_.*"
icon "#{iconpath}/pencil.xbm"
icon_only true
end
sublet :clock do
interval 60
format_string "#{col6}%H:%M : %d/%m/%Y"
end
#sublet :netchart do
# interval 10
# device "wlan0"
# title "#{col5}Net"
#end
#sublet :weather do
# locale "en-gb"
# interval 1800
# units "c"
# location "Swansea"
# current_label "Now"
# forecast_length 2
# sep "|"
#end
sublet :fuzzytime do
interval 60
locale "en"
end
sublet :battery do
path "/sys/class/power_supply/BAT1"
end
sublet :notify do
interval 30
end
#sublet :mpd do
# interval 30
# foreground "#6699ff"
# format_string "#{col1}%note%#{col2}%artist% #{col3}- #{col4}%title%"
#end
#sublet :smpd do
# interval 30
# foreground "#6699FF"
# background "snow1"
# format_string "%artist% - %title%"
# pause_label "smpd paused :("
# artist_color "#52d017"
# title_color "#0D25FD"
# stop_text "smpd stopped :("
# album_color "#0D25FD"
# stop_color "#6699ff"
# pause_color "red"
#end
[ :cpu, :battery, :volume ].each do |sublet|
sublet sublet do
icon_fg "#e67373"
end
end
# vim:ts=2:bs=2:sw=2:et:fdm=marker