用于在通知中显示CMU当前状态的包

cmus-notif的Python项目详细描述


https://travis-ci.org/AntoineGagne/cmus-notify.svg?branch=masterhttps://img.shields.io/pypi/v/cmus-notify.svg
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

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java在一个问题被连续正确回答三次/并添加差异后,我如何将程序循环回开始   Java中未实例化的匿名类   java如何在Android中录制视频,只允许横向模式和最长时间录制时间   java从另一个活动发送实时消息   多线程java线程和互斥   java禁用Spring安全日志   JAVA伊奥。StreamCorruptedException:在与子级和父级ProcessBuilder通信时写入子级中的标准输出时,流头无效   使用Java(HttpURLConnection)对Restheart进行身份验证(对于Mongodb)   java如何解决Jenkins中的SAXParseException?   java为什么我需要mockito来测试Spring应用程序?   计算sin-cos和tan时缺乏精度(java)   java Hibernate。不同项目中相同一对一映射的不同行为   java图像滑块:如何使用JavaFX将图像放在另一个图像上   java Mockito在使用when时抛出NotAMockException   http Java servlet发送回响应