kakakakakku blog

Weekly Tech Blog: Keep on Learning!

超簡単に Pebble のスクリーンショットを撮る方法

Kickstarter で支援した Pebble 2 が 10/21 に届いて,それから2週間ずっと Pebble 生活を送っている.

スマホの通知を Pebble でサッと確認できるのは効率的だし,歩数計で毎日の歩数を KPI として追うことができるし,時計をしていることを意識しないほどに軽く薄く製造されていて,とにかく最高!と感じる.

まだウォッチフェイス開発は試して無くて,まだまだ奥が深そうな Pebble!

www.kickstarter.com

超簡単にスクリーンショットを撮る

1. pebble コマンドをインストールする

pebble コマンドを使うと簡単にできる.まず最初に pebble コマンドをインストールする必要がある.

developer.pebble.com

ドキュメントに書いてある通り,brew 経由でインストールすることができる.

$ brew update && brew install pebble/pebble-sdk/pebble-sdk
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
(中略)

最初は brew update でエラーになってしまったけど,brew prune でシンボリックリンクを整理してから再実行したら通った.

$ brew prune
Pruned 41 symbolic links and 6 directories from /usr/local

$ brew update && brew install pebble/pebble-sdk/pebble-sdk

pebble コマンドが使えるようになった.

$ which pebble
/usr/local/bin/pebble

2. pebble screenshot コマンドを実行する

developer.pebble.com

事前準備として Pebble 側で "Enable Developer Mode" を ON にして,Server IP を確認しておく.

f:id:kakku22:20161104003728p:plain

Server IP を PEBBLE_PHONE 環境変数に設定したら,pebble screenshot コマンドを実行するだけ!

$ export PEBBLE_PHONE=111.222.333.444

$ pebble screenshot sample.png
100%[==============================================================================================================================================================================] 645.29  B/s 0:00:04
Saved screenshot to sample.png

ほら簡単!スクリーンショットが撮れた!

f:id:kakku22:20161104003956p:plain

繰り返し撮ることも考えて以下のようなコマンドをエイリアスにしておくと良さそう.

$ pebble screenshot pebble_screenshot_$(date +%Y%m%d_%H%M%S).png