向移动设备发送通知
notifyourself的Python项目详细描述
通知我们自己
notifyourselfcli使向手机发送通知变得简单。只需遵循以下简单步骤:
- 在发送计算机上安装notifyourselfcli
- 从Play Store安装NotifyourSelf Android应用程序或自行编译它
- 在应用程序的配置页中查找您的令牌
- 运行
notifyourself -T <token> "Hello yourself!"
向自己发送通知
当您的长跑模拟、nn训练或计算完成时,您可以使用此功能向自己发送一条消息:
$ longRunningCalculation.sh && notifyourself "Job finished :)"
安装
只需使用pip安装notifyourself:
$ python -m pip install notifyourself
使用源目录
您也可以直接使用python script source;确保安装requests
包:python -m pip install requests
配置
配置是使用文件~/.config/notifyourself/config.ini
(或windows上的%USERPROFILE%\.config\notifyourself\config.ini
)完成的。
# notifYourself configuration## You can define multiple targets with different tokens and use# the -t flag to choose one. Default is the DEFAULT target.[DEFAULT]# Use your notifYourself app to find this tokentoken=# [ANOTHER_TARGET]# token=ANOTHER_TARGETS_TOKEN
用法
usage: notifyourself [-h] [-T TOKEN | -t TARGET] [--config CONFIG]
title [body]
Send a notification to your phone
positional arguments:
title Notification title
body Longer message in the body of the notification
optional arguments:
-h, --help show this help message and exit
-T TOKEN, --token TOKEN
Use this token to send the message
-t TARGET, --target TARGET
Send message to this target phone specified in the
config file
--config CONFIG Configfile to use instead of default
示例
- 发送带有通知的简短结果
$ echo "42" > ./result
$ notifyourself "Job's finished :)" "Result: $(cat ./result)"
- 更改标记
$ notifyourself -T "longlong:token-foobar" "It works :)"
- 预先配置多部手机
$ cat ~/.config/notifyourself/config.ini
# notifYourself configuration
#
# You can define multiple targets with different tokens and use
# the -t flag to choose one. Default is the DEFAULT target.
[DEFAULT]
# Use your notifYourself app to find this token
token=foobarbaz1
[ANOTHER_TARGET]
token=target2token
$ notifyourself -t ANOTHER_TARGET "This shows in the other one"