The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
A Few Wmii-3 Hacks

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Red Handed

Posts: 1158
Nickname: redhanded
Registered: Dec, 2004

Red Handed is a Ruby-focused group blog.
A Few Wmii-3 Hacks Posted: Jun 13, 2006 9:09 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Red Handed.
Original Post: A Few Wmii-3 Hacks
Feed Title: RedHanded
Feed URL: http://redhanded.hobix.com/index.xml
Feed Description: sneaking Ruby through the system
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Red Handed
Latest Posts From RedHanded

Advertisement

mfp: I guess this makes me a weirdo (maybe even more so amongst Rubyists, which would often kill for a Mac — their third or fourth one) but I much prefer this to Exposé+Dock+Dashboard and all that eye candy (not that I’ve used it that much, but more than it took me to like wmii — maybe the learning curve is too steep? :-P).

I’m all hot in the collar over this as well. Totally lovestruck. They took all the right cues from Plan 9. I’ve been enjoying Mauricio’s script. Here’s a couple minor hacks.

PLEASE NOTE: Mauricio’s hacks (and mine) only work with the stable wmii-3 just released.

Resizing Hotkeys

I don’t ever swap two windows. So I used those hotkeys for pushing the edges of a window wider. For example, Alt+Control+k adds 48 pixels to the right side of a window. Now, if that window is up against the right-hand side of the screen, this’ll have no affect.

 on_key("#{MODKEY}-Control-#{UP}") { write "/view/sel/sel/geom", "+0 -48 +0 +48" }
 on_key("#{MODKEY}-Control-#{DOWN}") { write "/view/sel/sel/geom", "+0 +0 +0 +48" }
 on_key("#{MODKEY}-Control-#{RIGHT}") { write "/view/sel/sel/geom", "+0 +0 +48 +0" }
 on_key("#{MODKEY}-Control-#{LEFT}") { write "/view/sel/sel/geom", "-48 +0 +48 +0" }

No Numbers

I don’t use the numeric tags. I use about ten verbose tags and wmii-3 displays them in order in the bar. So I use the numeric keys to tab quickly between them. (Alt+1 is the first tag, Alt+2 is the second…) I got this from Suraj N. Kurapati (who also posted his Ruby wmiirc.

I’ve also added Alt+Shift+num which adds the tag at num position to the current window’s set of tags. And Alt+Control+num removes the tag at num position from the current window’s set.

 (0..9).each do |i|
 k = (i - 1) % 10
 on_key("#{MODKEY}-#{i}") do
 view(read('/tags').split[k] || i)
 end
 on_key("#{MODKEY}-Shift-#{i}") do
 key = read('/tags').split[k] || i
 oldtags = read("/view/sel/sel/tags").split(/\+/)
 write "/view/sel/sel/tags", (oldtags + [key]).uniq.join("+")
 end
 on_key("#{MODKEY}-Control-#{i}") do
 key = read('/tags').split[k] || i
 oldtags = read("/view/sel/sel/tags").split(/\+/)
 write "/view/sel/sel/tags", (oldtags - [key]).uniq.join("+")
 end
 end

Action Commands

Mauricio lets you setup some commands in your Ruby script which you can get to from the menu. For example, Alt+a google launches a search in your browser using the current cursor selection as the search terms. I’ve just extended this a bit by allowing the search terms right on the bar. So: Alt+a google houyhnhnms.

 on_key("#{MODKEY}-a") do
 internal_actions = {
 "browser" => lambda do |selection|
 selection ||= `wmiipsel`.strip
 case browser = ENV["BROWSER"]
 when nil: system "/etc/alternatives/x-www-browser '#{selection}' &" 
 else system "#{browser} '#{selection}' &" 
 end
 end,
 "google" => lambda do |*selection|
 require 'cgi'
 if selection
 selection = CGI.escape(selection.join(" "))
 else
 selection = CGI.escape(%!"#{`wmiipsel`.strip}"!)
 end
 url = "http://www.google.com/search?q=#{selection}" 
 case browser = ENV["BROWSER"]
 when nil: system "/etc/alternatives/x-www-browser '#{url}' &" 
 else system "#{browser} '#{url}' &" 
 end
 end
 }
 wmiimenu((action_list + internal_actions.keys).sort) do |choice|
 if internal_actions[choice]
 internal_actions[choice].call
 else
 choices = choice.split(/\s+/)
 if internal_actions[choices.first]
 internal_actions[choices.shift].call(*choices)
 end
 system("$HOME/.wmii-3/#{choice} &") if /^\s*$/ !~ choice
 end
 end
 end

For some other shell snippets: snippets. And, for more about tagging: tagging.

Read: A Few Wmii-3 Hacks

Topic: Symbol#to_proc Exonerated Previous Topic   Next Topic Topic: Dual booting screws up my system clock

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use