termtterのnotify-send3プラグインを画面外にはみ出ないように

termtterのnotify-send3プラグインを使うと、アイコン画像付きでなかなかいい感じで表示されるけど、
件数が多すぎると画面外にはみ出ててしまうので、ちょっと改造して運用してる(今は6件ごとに表示)

notify-send4.rbみたいにテキトーに名前を付けて、~/.termtter/plugins/の下に保存して使用するといいと思います

改造したnotify-send3.rb
# -*- coding: utf-8 -*-

require 'fileutils'
require 'RMagick'
require 'uri'

# Copy from notify-send2.rb
config.plugins.notify_send.set_default(:icon_cache_dir, "#{Termtter::CONF_DIR}/tmp/user_profile_images")
def get_icon_path(s)
  FileUtils.mkdir_p(config.plugins.notify_send.icon_cache_dir) unless File.exist?(config.plugins.notify_send.icon_cache_dir)
  cache_file = "%s/%s%s" % [  config.plugins.notify_send.icon_cache_dir,
                              s.user.screen_name,
                              File.extname(s.user.profile_image_url)  ]
  if !File.exist?(cache_file) || (File.atime(cache_file) + 24*60*60) < Time.now
    File.open(cache_file, "wb") do |f|
      begin
        http_class = Net::HTTP
        unless config.proxy.host.nil? or config.proxy.host.empty?
          http_class = Net::HTTP::Proxy(config.proxy.host,
                                        config.proxy.port,
                                        config.proxy.user_name,
                                        config.proxy.password)
        end
        uri = URI.parse(URI.escape(s.user.profile_image_url))
        image = http_class.get(uri.host, uri.path, uri.port)
        rimage = Magick::Image.from_blob(image).first
        rimage = rimage.resize_to_fill(90,90)
        f << rimage.to_blob
      rescue Net::ProtocolError
        return nil
      end
    end
  end
  cache_file
end

Termtter::Client.register_hook(
  :name => :notify_send4,
  :points => [:output],
  :exec_proc => lambda {|statuses, event|
    return unless event == :update_friends_timeline
    Thread.start do
      i = 0
      statuses.each do |s|
        i = i + 1
        text = CGI.escapeHTML(s.text)
        text = %Q{"#{text}"} if text =~ /^-/
        text.gsub!(URI.regexp,'<a href="\0">\0</a>')
        begin
          system 'notify-send', '-i', get_icon_path(s), '-t','10000','--', s.user.screen_name, text
          sleep 0.01
          if i % 6 == 0
              sleep 10.0
          end
        rescue
        end
      end
    end
  }
)
設定ファイルはこんな感じ(~/.termtter/config)
config.user_name = 'username'                                                                                                                                                                                                                                          
config.password = 'password'
config.update_interval = 60 # 更新間隔を60秒に
Termtter::Client.init do |t|
      t.plug 'notify-send4'
      t.plug 'uri-open'
end