Project

General

Profile

unexist.dev

/

subtle

Assorted tidbits and projects

Hooks » History » Version 10

Version 9 (Jonathan Dahan, 11/22/2009 08:30 PM) → Version 10/47 (Anonymous, 12/06/2009 03:07 PM)

h1. Hooks\015\012\015\012[[Hooks]] Hooks\015\012\015\012Here is a list of the existing types of [[hooks]], although more are small chunks planned. Every feature of code (procs) that [[Subtlext]] can be called on certain events of used inside these [[hooks]] without instantiating a *Subtlext::Subtle* object first:\015\012\015\012<pre><code class="ruby">\015\012clients.each { |c| puts c.name }\015\012\015\012find_tag("subtle")\015\012</code></pre>\015\012\015\012Every [[hooks|hook]] except the window manager.\015\012\015\012Here *create hook* will be run before the event is a list actually processed and the return value of the existing types supplied proc will determine if processing continues or not. A return value of [[hooks]]:\015\012 \015\012{{>toc}}\015\012\015\012h2. Create client\015\012\015\012Triggers *false* will effectively stop processing of the event.\015\012\015\012Following [[hooks]] exist so far:\015\012\015\012{{>toc}}\015\012\015\012h2. Create\015\012\015\012Triggers on creation of new clients.\015\012<pre><code class="ruby">\015\012:HookClientCreate class="ruby">\015\012:HookCreate => lambda { |c| puts c.name }\015\012</code></pre>\015\012\015\012h2. Client configure\015\012\015\012Triggers whenever Focus\015\012\015\012Triggers when a client is configured.\015\012<pre><code class="ruby">\015\012:HookClientFocus gets focus and has the focussed client as parameter.\015\012<pre><code class="ruby">\015\012:HookFocus => lambda { |c| puts c.name }\015\012</code></pre>\015\012\015\012h2. Client focus\015\012\015\012Triggers whenever Gravity\015\012\015\012Triggers when a client gets focus.\015\012<pre><code class="ruby">\015\012:HookClientFocus => lambda { |c| puts c.name }\015\012</code></pre>\015\012\015\012h2. Client kill\015\012\015\012Triggers when a client is killed.\015\012<pre><code class="ruby">\015\012:HookClientKill new gravtiy.\015\012<pre><code class="ruby">\015\012:HookGravity => lambda { |c| puts c.name }\015\012</code></pre>\015\012\015\012h2. View client\015\012\015\012Triggers Jump\015\012\015\012Triggers on creation of new views.\015\012<pre><code class="ruby">\015\012:HookViewCreate => lambda { |v| puts v.name }\015\012</code></pre>\015\012\015\012h2. View configure\015\012\015\012Triggers whenever a view is configured.\015\012<pre><code class="ruby">\015\012:HookViewFocus => lambda { |v| puts v.name }\015\012</code></pre>\015\012\015\012h2. View jump\015\012\015\012Triggers on a jump to a view.\015\012<pre><code class="ruby">\015\012:HookViewJump => lambda { |v| puts v.name }\015\012</code></pre>\015\012\015\012h2. View kill\015\012\015\012Triggers when a jumps and has the active view is killed.\015\012<pre><code class="ruby">\015\012:HookViewKill as parameter.\015\012<pre><code class="ruby">\015\012:HookJump => lambda { |v| puts v.name }\015\012</code></pre>\015\012\015\012h2. }\015\012</code></pre>\015\012\015\012\015\012h2. Examples\015\012\015\012Switch to the first view of new client\015\012<pre><code class="ruby">\015\012:HookCreate => lambda { |c| c.views.first.jump }\015\012</code></pre>\015\012\015\012Tag a new client with the current view\015\012<pre><code class="ruby">\015\012:HookClientCreate class="ruby">\015\012:HookCreate = lamda { |c| c.tag(current_view.name) }\015\012</code></pre>\015\012\015\012Tag a new client with the current view only if it has no other tags\015\012<pre><code class="ruby">\015\012:HookClientCreate class="ruby">\015\012:HookCreate => lambda { |c| \015\012 if(c.tags.empty?)\015\012 if(!tags.include?(current_view.name))\015\012 add_tag(current_view.name)\015\012 if(c.tags.empty?); if(!tags.include?(current_view.name)); add_tag(current_view.name); end \015\012 c.tag(current_view.name);\015\012 end\015\012}\015\012</code></pre>\015\012\015\012Display c.tag(current_view.name); end }\015\012</code></pre>\015\012\015\012Display information about the currently focused window\015\012<pre><code class="ruby">\015\012:HookClientFocus class="ruby">\015\012:HookFocus => { |c| find_sublet("client").data = "%s (%s)" % [ c.name, c.class ] }\015\012</code></pre>\015\012\015\012