#chiroruLab

趣味と日々の雑記録

【Growl通知付】NEX-5Rのパソコン保存で失敗する時に便利な、QuitAPP。

f:id:chiroru_27:20130821191356j:plain:w300
パソコン保存でいつまで経っても転送が始まらない時が何度かありました。

そんな時は、アクティビティモニタから
「WirelessImporterDaemon」を一旦終了してあげるとすぐに繋がるのですが
2,3回目になるとそれすらも面倒になってきてしまいます。

そこでAppleScriptで手早く終了できるスクリプトを用意しました。



どうも、@chiroru_27 です
NEX-5Rを購入してから2週間程度経ちました。やっぱりいいですNEX-5R

特に便利なのはスマートフォン転送、パソコン保存!
SDカードを抜かなくても、写真を色々なデバイスに取り込めるのなんてすごい時代ですね・・・。

でも、本当たまにですが失敗することがあります。
(ここ1週間ほどは安定しています。なんでだろう?)
今まではアクティビティモニタから対処していたのですが

  1. Dockから起動
  2. 一覧から探す
  3. プロセスを終了
  4. 終了

という手順が必要で、ちょっと面倒。

そこでAlfredを使って、ぱぱっとWirelessImporterDaemonをkillしちゃうAppleScriptを作ってみました。

Alfred App - Productivity App for Mac OS X
Alfred saves you time when you search for files online or on your Mac. Be more productive with hotke...

無料版と、有料版がありますが、基本無料版で事足りちゃいます。

AppleScript

参考にしたサイト


Mac Stuff >> Using Applescript to kill off a process
I use AppleScript to clean up some temp spaces on my lab machines. It's easy to use and gives me mos...

QuitAPP-WID.scpt

set app_name to "WirelessImporterDaemon"

set the_pid to (do shell script "ps ax | grep " & (quoted form of app_name) & " | grep -v grep | awk '{print $1}'")
set res to app_name & QuitAPP(the_pid)

on QuitAPP(PID)
	set state to ""
	
	if PID is not "" then
		do shell script ("kill -9 " & PID)
		set state to " を再起動するね!"
	else
		set state to " は起動していないみたい・・・。"
	end if
	
	return state
end QuitAPP

-- Growl通知
tell application "Growl"
	notify with name ¬
		"Command" title ¬
		"QuitAPP" description ¬
		res application name ¬
		"AppleScript" icon of application ¬
		"System Preferences"
end tell

DLはこちら
Dropbox - QuitAPP-WID.scpt

これが本体です。
ほとんど参考元のまま、Growl通知を追加しただけですね(笑)

使い方


コンパイルしてみて問題がないようなら準備はおkです

あとはAlfredがインストール済みなら
コマンド欄に「quitapp」とかなんとか入れれば候補に出てくると思うので
そこから実行。

f:id:chiroru_27:20130826181716p:plainf:id:chiroru_27:20130826181717p:plain
Growlをインストールしている時は、こんな感じで通知が出ます。

Subscribe Growl.scpt

--Growl登録
tell application "Growl"
	register as application ¬
		"AppleScript" all notifications {"Command", "Another"} ¬
		default notifications {"Command"} ¬
		icon of application "AppleScript Editor"
end tell

DLはこちら
Dropbox - Subscribe Growl.scpt

Growlに通知を飛ばしたい時は
これをつかって登録する必要があります。

使い方


コンパイルしてみて問題がないようなら準備はおkです

あとは、実行するだけ。
1度やれば完了です。



最近は落ち着いたみたいで、もしかしたら使わなくても良くなったかもしれませんが一応。
もし失敗するような時は、たぶんこれで少しは楽できるかな。