Project

General

Profile

unexist.dev

Assorted tidbits and projects

subtle.rb

Jonathan Dahan, 12/13/2009 06:59 PM

 
1
# 
2
#  Author:: Jonathan Dahan <jedahan@gmail.com>
3
# Version:: 0.1
4
# License:: GNU GPL
5
#
6

    
7
OPTIONS = {
8
  :border  => 2,                                   
9
  :step    => 5,
10
  :snap    => 10,
11
  :gravity => :center,
12
  :urgent  => true,
13
  :resize  => false,
14
  :padding => [ 0, 0, 0, 0 ],
15
  :font    => "-*-fixed-*-*-*-*-18-*-*-*-*-*-*-*"
16
#  :font    => "-*-lucidatypewriter-medium-r-normal-*-12-*-*-*-*-*-*-*"
17
#  :font     =>"-*-inconsolata-*-*-*-*-20-*-*-*-*-*-*-*"
18
}
19

    
20
PANEL = {
21
  :top       => [ :views, :title, :spacer, :tray, :sublets ],
22
  :bottom    => [ ],
23
  :stipple   => false,
24
  :separator => "  "
25
}
26

    
27
COLORS = { 
28
  :fg_panel      => "#5881ed",
29
  :fg_views      => "#5881ed",
30
  :fg_sublets    => "#ffffff",
31
  :fg_focus      => "#ffffff",
32
  :fg_urgent     => "#572923",
33

    
34
  :bg_panel      => "#5d5d5d",
35
  :bg_views      => "#5d5d5d",
36
  :bg_sublets    => "#5881ed",
37
  :bg_focus      => "#5881ed",
38
  :bg_urgent     => "#883421",
39

    
40
  :border_focus  => "#5881ed",
41
  :border_normal => "#5d5d5d",
42
  
43
  :background    => "#ffffff",
44
}
45

    
46
GRAVITIES = {
47
  :top_left       => [   0,   0,  50,  50 ], 
48
  :top_left66     => [   0,   0,  50,  66 ],
49
  :top_left33     => [   0,   0,  50,  33 ],
50
  :top            => [   0,   0, 100,  50 ],
51
  :top66          => [   0,   0, 100,  66 ],
52
  :top33          => [   0,   0, 100,  33 ],
53
  :top_right      => [ 100,   0,  50,  50 ],
54
  :top_right66    => [ 100,   0,  50,  66 ],
55
  :top_right33    => [ 100,   0,  50,  33 ],
56
  :left           => [   0,   0,  50, 100 ],
57
  :left66         => [   0,  50,  50,  33 ],
58
  :left33         => [   0,  50,  25,  33 ],
59
  :center         => [   0,   0, 100, 100 ],
60
  :center66       => [   0,  50, 100,  33 ],
61
  :center33       => [  50,  50,  50,  33 ],
62
  :right          => [ 100,   0,  50, 100 ],
63
  :right66        => [ 100,  50,  50,  33 ],
64
  :right33        => [ 100,  50,  25,  33 ],
65
  :bottom_left    => [   0, 100,  50,  50 ],
66
  :bottom_left66  => [   0, 100,  50,  66 ],
67
  :bottom_left33  => [   0, 100,  50,  33 ],
68
  :bottom         => [   0, 100, 100,  50 ],
69
  :bottom66       => [   0, 100, 100,  66 ],
70
  :bottom33       => [   0, 100, 100,  33 ],
71
  :bottom_right   => [ 100, 100,  50,  50 ],
72
  :bottom_right66 => [ 100, 100,  50,  66 ],
73
  :bottom_right33 => [ 100, 100,  50,  33 ]
74
}  
75

    
76
@dmenu = "dmenu_run -fn '%s' -nb '%s' -nf '%s' -sb '%s' -sf '%s' -p 'Select:'" % [
77
  OPTIONS[:font],
78
  COLORS[:bg_panel], COLORS[:fg_panel], 
79
  COLORS[:bg_focus], COLORS[:fg_focus]
80
]
81

    
82
# An action is something that happens when a grab is activated, this can be one of the following:
83
#
84
# [*symbol*] Run a subtle action
85
# [*string*] Start a certain program
86
# [*array*]  Cycle through gravities
87
# [*lambda*] Run a Ruby proc
88
#
89
GRABS = {
90
  # Switch to view1, view2, ...
91
  "W-1"      => :ViewJump1,
92
  "W-2"      => :ViewJump2,
93
  "W-3"      => :ViewJump3,
94
  "W-4"      => :ViewJump4,
95

    
96
  # Move mouse to screen1, screen2, ...
97
  "W-A-1"    => :ScreenJump1,
98
  "W-A-2"    => :ScreenJump2,
99
  "W-A-3"    => :ScreenJump3,
100
  "W-A-4"    => :ScreenJump4,
101

    
102
  # Move window to screen1, screen2, ...
103
  "A-S-1"    => :WindowScreen1,
104
  "A-S-2"    => :WindowScreen2,
105
  "A-S-3"    => :WindowScreen3,
106
  "A-S-4"    => :WindowScreen4,
107

    
108
  # Force reload of config
109
  "W-C-r"    => :SubtleReload,
110

    
111
  # Quit subtle
112
  "W-C-q"    => :SubtleQuit,
113

    
114
  # Move current window
115
  "W-B1"     => :WindowMove,
116

    
117
  # Resize current window
118
  "W-B3"     => :WindowResize,
119

    
120
  # Toggle floating mode of window
121
  "W-f"      => :WindowFloat,
122

    
123
  # Toggle fullscreen mode of window
124
  "W-space"  => :WindowFull,
125

    
126
  # Toggle sticky mode of window (will be visible on all views)
127
  "W-s"      => :WindowStick,
128

    
129
  # Raise window
130
  "W-r"      => :WindowRaise,
131
  
132
  # Lower window
133
  "W-l"      => :WindowLower,
134

    
135
  # Fake alt-tab
136
  "A-Tab"    => :WindowLower,
137

    
138
  # Select next windows
139
  "W-Left"   => :WindowLeft,
140
  "W-Down"   => :WindowDown,
141
  "W-Up"     => :WindowUp,
142
  "W-Right"  => :WindowRight,
143

    
144
  # Kill current window
145
  "W-S-k"    => :WindowKill,
146

    
147
  # Cycle between given gravities
148
  "W-S-7"    => [ :top_left,     :top_left66,     :top_left33     ],
149
  "W-S-Up"    => [ :top,          :top66,          :top33          ],
150
  "W-S-9"    => [ :top_right,    :top_right66,    :top_right33    ],
151
  "W-S-Left"    => [ :left,         :left66,         :left33         ],
152
  "W-S-I"    => [ :center,       :center66,       :center33       ],
153
  "W-S-Right"    => [ :right,        :right66,        :right33        ],
154
  "W-S-J"    => [ :bottom_left,  :bottom_left66,  :bottom_left33  ],
155
  "W-S-Down"    => [ :bottom,       :bottom66,       :bottom33       ],
156
  "W-S-L"    => [ :bottom_right, :bottom_right66, :bottom_right33 ],
157

    
158
  # Exec some programs
159
  "W-Return" => "urxvt",
160
  "W-d"      => @dmenu,
161
  "W-c"     => "chromium",
162
  "W-x"     => "xchat"
163

    
164
}
165

    
166
TAGS = {
167
  "terminal"   => "xterm|[u]?rxvt",
168
  "browser" => "uzbl|opera|firefox|navigator",
169
  "torrent" => "transmission",
170
  "irc"     => "xchat",
171
  "pdf"     => "epdfview",
172
  "editor"  => { :regex => "[g]?vim", :resize => true },
173
  "stick"   => { :regex => "mplayer|imagemagick|wpa_gui", :float => true, :stick => true },
174
  "float"   => { :regex => "gimp|qjackctl|Qjackctl", :float => true },
175
  "fixed"   => { :geometry => [ 10, 10, 100, 100 ], :stick => true },
176
  "resize"  => { :regex => "sakura|gvim", :resize => true },
177
  "gravity" => { :gravity => :center }
178
}  
179

    
180
VIEWS = {
181
  "0"     => "default",
182
  "dev"   => "editor|terminal",
183
  "read"  => "pdf|browser",
184
  "chat"  => "irc",
185
  "down"  => "torrent"
186
}
187

    
188
HOOKS = {
189
    :HookClientCreate => lambda { |c| puts c.views} 
190
}
191

    
192
PANEL = {
193
    :top    => [ :views, :title, :spacer, :tray ],
194
    :bottom => [ :ddate, :spacer, :clock ]
195
}
196