LoginSignup
13

More than 5 years have passed since last update.

日々の情報収集と通知

Last updated at Posted at 2014-08-28

はじめに

基本的には、Twitterのリストを使って、情報収集をしています。これは、主に通知に流します。よって、今回は、主に、私の通知の使い方を紹介します。

ここで、Twitterのリストは、botを登録するなどしていますが、botを自作してもいいのですが、Twitter APIなどは面倒くさそうなので、あまり触りたくありません。したがって、既存のbotを登録していることが多いです。

Twitter

TweetVim

~/.vimrc
NeoBundle 'basyura/TweetVim'
NeoBundle 'tyru/open-browser.vim'
NeoBundle 'basyura/twibill.vim'

NeoBundle 'syui/tweetvim_notfiy'
NeoBundle 'gist:rhysd/4201877', {
\   'name': 'tweetvim_update',
\   'script_type': 'plugin'
\}
~/.zshrc
function tweetvim-auto(){
  vim -c "TweetVimListStatuses $1" +TweetVimAutoUpdate +TweetVimStartNotify
}

リスト名を引数で渡します。

ここで、リスト多い人は、リスト補完を作ってもいいのですが、私はやってません。少ないので。

必要なもの

Mac

growlnotify

$ brew install growlnotify

Linux

notify-send

$ pacman -S inotify-tools

Windows

growlnotify.exe

$ choco install Growl

設定

リロードする時間間隔を設定できます。

~/.vim/bundle/tweetvim_update/plugin/tweetvim_autoupdate.vim
let s:tweetvim_update_interval_seconds = 10
~/.vim/bundle/tweetvim_notfiy/plugin/tweetvim_notfiy.vim
let s:tweetvim_notfiy_update_interval_seconds = 5

コード

tweetvim_notify.vimは、自分で作りましたので、少し解説できます。

参考にしたのは、オートリロードを担当するtweetvim_autoupdate.vimです。

本体のコードは以下の様な感じで、単純に最新ツイートを比較し、違いがあれば、通知コマンドを叩きます。

tweetvim_notify.vim
let s:tweetvim_notfiy_update_interval_seconds = 2
let s:tweetvim_notfiy_timestamp = reltime()[0]
let s:tweetvim_notfiy_getline_1 = getline(3)

fu! s:tweetvim_notfiy()
  let n_current = reltime()[0]
    if n_current - s:tweetvim_notfiy_timestamp > s:tweetvim_notfiy_update_interval_seconds
        if s:tweetvim_notfiy_getline_1 != getline(3)
          let s:tweetvim_notfiy_getline_1 = getline(3)
          call system("growlnotify -m '" . getline(3) . "'")
        end
        let s:tweetvim_notfiy_timestamp = n_current
    end
endf

fu! s:tweetvim_notfiy_setup_autoupdate()
    aug vimrc-tweetvim-notfiy-autoupdate
        au!
        au CursorHold * call <SID>tweetvim_notfiy()
    aug END
endf

com! -nargs=0 TweetVimStartNotify call <SID>tweetvim_notfiy_setup_autoupdate()
com! -nargs=0 TweetVimStopNotfiy au! vimrc-tweetvim-notfiy-autoupdate

通知コマンドは、各OSによって異なるので、処理を分岐しました。

test/ostype.vim
fu! s:air_test_ostype()
let OSTYPE = substitute(system('uname'), "\n", "", "")
if OSTYPE == "Darwin"
  echo OSTYPE
elsei OSTYPE == "Linux"
  echo OSTYPE
elsei has('win32') || has('win16') || OSTYPE =~ "CYGWIN"
  echo OSTYPE
en
endf
com! -nargs=0 AirTestOstype call <SID>air_test_ostype()

一応、アイコンパスが読み込めているかのテストです。

test/system.vim
let s:air_test_dir_icon= expand("<sfile>:p:h:h") . "/icon/twitter.png"
fu! s:air_test_system()
  call system("growlnotify -a Twitter -m '" . s:air_test_dir_icon . "/test'")
endf
com! -nargs=0 AirTestSystem call <SID>air_test_system()

通知コマンドは、各OSごとに以下の通りです。これは、各自用意してください。

" mac
call system("growlnotify -a Twitter -m '" . getline(3) . "'")

" Linux
call system("notify-send -i " . s:tweetvim_notfiy_dir_icon . " '" . getline(3) . "'")

" Windows
call system('growlnotify.exe /i:' . s:tweetvim_notfiy_dir_icon . " '" . getline(3) . "'")

Linux

Linuxでの通知は、notify-sendを使います。

Awesome

awesomeの通知は、デフォルトではnaughtyが使用されている感じですので、各自設定します。表示される場所とか大きさとか表示時間とか。

~/.config/awesome/rc.lua
naughty.config.defaults.timeout          = 5
naughty.config.defaults.position         = "bottom_right"
naughty.config.defaults.margin           = 4
naughty.config.defaults.width            = 300
naughty.config.defaults.height           = nil
naughty.config.defaults.hover_timeout    = nil

http://awesome.naquadah.org/wiki/Naughty
http://awesome.naquadah.org/doc/api/modules/naughty.html

Lingr

J6uil

J6uil.vim

j6uil_notify

~/.vimrc
NeoBundle 'basyura/J6uil.vim'
NeoBundle 'syui/j6uil_notify'

通知

$ vim +J6uil +J6uilStartNotify

追記

指定するやつ作りました。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13