用于在通知中显示CMU当前状态的包
cmus-notif的Python项目详细描述
Author: | Antoine Gagné |
---|
1要求
要安装此程序,您必须具备以下条件:
- python 3.5+
- Python库notify2
- notify-send
2安装
要安装此程序,只需运行以下命令:
python setup.py install
此程序也可以在Pypi上找到,这意味着您可以通过下载控制盘或使用以下命令来安装它:
pip install cmus-notify
您可以通过执行以下命令来检查安装是否正确:
cmus_notify -h
它应该显示一条消息
3连接到CMU
要将此程序挂接到cmus,必须创建一个shell脚本,其中包含以下行:
#! /bin/sh cmus_notify "$*"&
然后,必须使用以下命令使文件可执行(假定脚本名为cmus_notify.sh):
chmod +x cmus_notify.sh
最后,进入cmus后,可以使用以下命令添加钩子:
:set status_display_program=<path-to-the-shell-script>
4定制
如果需要,可以通过指定格式字符串来指定通知的格式例如:
#! /bin/sh cmus_notify --title "Now playing: {title} by {artist}" --body "$(printf"<b>Album:</b> {album}\n<b>Duration:</b> {duration}")""$*"
您还可以指定从中读取这些值的配置。默认情况下,程序将搜索名为~/.cmus-notify的配置文件。格式如下:
[notifications]application_name=Cmus custom_notification = /home/user/.cmus/custom_notification.py[format]title=Now playing: {title} by {artist} body = <b>Album:</b> {album} <b>Duration:</b> {duration}
这些选项接受与其等效的命令行选项相同的值
5种选择
要查看完整选项,可以运行以下命令:
cmus_notify --help
将显示以下提示:
usage: cmus_notify [-h] [-a APPLICATION_NAME] [-b BODY_FORMAT_STRING] [-t TITLE_FORMAT_STRING] [-f CONFIGURATION_FILE] [-c CUSTOM_NOTIFICATION] INFORMATION Display a notification about Cmus's current status positional arguments: INFORMATION Parse the given information optional arguments: -h, --help show this help message and exit -a APPLICATION_NAME, --application_name APPLICATION_NAME The name of the application -b BODY_FORMAT_STRING, --body BODY_FORMAT_STRING A format string that can be specified to tell the software how to format the body. The syntax is the same as Python's. The available options are specified at the end of this help message. (i.e. 'Artist: {artist}') -t TITLE_FORMAT_STRING, --title TITLE_FORMAT_STRING A format string that can be specified to tell the software how to format the title. The syntax is the same as Python's. The available options are specified at the end of this help message. (i.e. 'Now playing: {title}') -f CONFIGURATION_FILE, --configuration_file CONFIGURATION_FILE The path to the configuration file. If it is not specified, the program will use the default values of the other options. -c CUSTOM_NOTIFICATION, --custom_notification CUSTOM_NOTIFICATION The path to a custom implementation of the notification class. If it is not specified, the standard implementation will be used (the one using notify2). Format String Parameters ======================== The available arguments to the format strings are the following: - album: The song's album - albumartist: The song's album's artist - artist: The song's artist - date: The song's release date - discnumber: The song's disc's number - duration: The song's duration - file: The song's file's path - status: Cmus current status - title: The song's title - tracknumber: The song's track number
6文件
可以找到项目文档here