LoginSignup
3
3

More than 5 years have passed since last update.

CentOS 6.4から、Mac OS X El Capitanに通知を送り、Growlでポップアップ表示

Last updated at Posted at 2016-05-02

やること

リモートのCentOS 6.4から、ローカルのMac OS X El Capitanに通知を送り、通知ポップアップを表示。(Growlで)

前提

ローカル(Mac)にGrowlがインストールされている。

手順

手元のMacで準備 [外部からの通知を許可]

(参考資料: http://umezo.hatenablog.jp/entry/20100920/1284974406)

Growlの設定を開く。
ネットワーク>外部からの通知を受け付ける にチェック。

2016-04-28 18.12.26.png

リモート(CentOS)側で準備 [ruby-growlインストール]

ruby-growlをリモート(CentOS)にインストール。

ローカルのIP確認

ローカル(Mac)にてifconfigし、リモートへ接続する際に利用しているネットワーク・インターフェースのIPアドレスをメモる。
IPアドレスはinet欄に記載されている。

$ ifconfig
.
.
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
.
.
    inet 192.168.1.2 netmask 0xffffff00 broadcast 192.168.24.255
.
.

今回は192.168.1.2。

リモート(CentOS)でruby-growlを動かしてみる

リモート(CentOS)に以下スクリプトを作成。先ほどのIPアドレスを入れておく。詳しくはruby-growl docs参照。

notify.rb
equire 'ruby-growl'

g = Growl.new "{ここにIPアドレス}", "ruby-growl"
g.add_notification "ruby-growl Notification"
g.notify "ruby-growl Notification", "It came from ruby-growl!",
         "Greetings!"

実行します。

$ ruby growl.rb

表示はこんな感じ

image

表示形式やアイコンが変えられるので、詳しくは ruby-growl docs へどうぞ。

3
3
0

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
3
3