LoginSignup
8
6

More than 5 years have passed since last update.

Python3でシンプルなカップ麺専用タイマー(通知機能付き) + macのAutomatorでアプリ化

Last updated at Posted at 2018-04-02

コーティング中にカップ麺に湯を入れたまま忘れることが頻繁に起こっていました。カップ麺好きの僕にとっては耐えられません!(自分のせいですが汗)そこで、カップラーメン専用のタイマーを作りました!

Pythonのコード

ramenTimer.py

#!/Users/my_name/.pyenv/versions/3.6.5/bin/python3.6 -tt 

import os
import time

def ramenTimer():
    #タイマーの時間を設定(180秒 = 3分)
    time.sleep(180)

    #通知メッセージ
    os.system("""
              osascript -e 'display notification "ラーメンできたよ!" with title "Times Up"'
              """)


def main():
    ramenTimer()

if __name__ == '__main__':
    main()

設定時間は3分(180秒)にしています。
通知メッセージを設定することで、3分後に画面右上に⬇️のような通知が出ます。

スクリーンショット 2018-04-02 18.12.18.png

Automaterでapp化

スクリーンショット 2018-04-02 18.02.52.png

シェルスクリプトに、上で作ったpython ファイル(ramenTimer.py)のパスを書くだけ。
command + s でappとして保存。

これで、spotlightから呼び出せるようになります。
スマホで3分タイマーを設定するより早いです!!

のびたカップ麺を食べたくない人は、ご自由にコピペしてください。

8
6
2

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
8
6