Jun'uary

wmii + urxvt + screen

Jan 发表于 2008-08-24 17:28:19

WMII is a tiling window manager that every ruby/rails programmer should try. It can be easily configurated with ruby scripts. WMII has a 'tag' concept, that every X window will be related to a tag, such as 'web', 'database' etc.

I'm a heavy keyboard user who relys on urxvt and screen. Many times when I'm working in  a view, like 'web', I want to temporarily do something in console or look on something in my screen session, but the screen window is opened in the other view, like 'database'. I don't want to switch to 'database' view to use screen, it's what we try to avoid by using a tiling window manager.

So I write this piece of code to resolve the problem, it follow these rules:

1. there will always be only one screen window
2. if no detached screen session, create a new one
3. if there's a detached screen session, reuse it in urxvt
4. if the screen window is in another view, bring it to current view

Now I has a more smart urxvt+screen window which I can use in any view with my METAKEY+RETURN.

(the code is based on ruby-wmii, you should add it into your wmiirc-config.rb)
  on_key("MODKEY-Return") do
    file = `wmiir ls /client`.split("\n").map{|x| x[%r{[^/]+}]}.find {|c| read("/client/#{c}/label")[0,6] == 'screen'}
    if file
      write "/client/#{file}/tags", "!"
    else
      # replace jan with your username
      cmd = Dir.glob("/tmp/screens/S-jan/*").size > 0 ? "screen -r" : "screen"
      system "urxvt -title screen -e #{cmd} &"
    end
  end
关键词(Tag): screen urxvt wmii

曾经的这一天...


收藏: QQ书签 del.icio.us 订阅: Google 抓虾

最新评论

发表评论

* 昵称

已经注册过? 请登录

新用户请先注册 以便能显示头像及追踪评论回复

Email
网址
* 评论
表情
 
 

分类小组论坛
杂谈, 娱乐、八卦, 文学、艺术, 体育, 旅游、同城, 象牙塔, 情感, 时尚、生活, 星座, 科技

请注意遵守中华人民共和国法律法规, 如威胁到本站生存, 将依法向有关部门报告, 同时本站的相关记录可能成为对您不利的证据.

相关法律法规
全国人大常委会关于维护互联网安全的决定
中华人民共和国计算机信息系统安全保护条例
中华人民共和国计算机信息网络国际联网管理暂行规定
计算机信息网络国际联网安全保护管理办法
计算机信息系统国际联网保密管理规定

Jan'uary

人类一思考,老夫就发笑

搜索

日历