termux-notification例子

termux: 0.117
termux-api: 0.49
MIUI: 12.5.7

$ termux-notification-list

//显示通知列表(json格式)
[
{
“id”: 20006,
“tag”: “”,
“key”: “0|com.miui.securitycenter|20006|null|1000”,
“group”: “”,
“packageName”: “com.miui.securitycenter”,
“title”: ““手机管家”正在运行”,
“content”: “可能导致系统卡顿,降低待机时间,点按关闭”,
“when”: “2021-12-07 19:32:51”
},
{
“id”: 0,
“tag”: “91099064-da82-493a-a0dc-7cffc7509a83”,
“key”: “0|com.termux.api|0|91099064-da82-493a-a0dc-7cffc7509a83|10264”,
“group”: “”,
“packageName”: “com.termux.api”,
“title”: “”, “content”: “”,
“when”: “2021-12-08 11:12:24”
},
{
…省略…
}
]
注:会有一些通知栏没有显示的通知

$ termux-notification

图片1$ termux-notification -h
或termux-notification --help
(以下参考百度翻译)
Usage: termux-notification [options]Display a system notification. Content text is specified using -c/–content or read from stdin.Please read --help-actions for help with action arguments.
(显示系统通知。显示的通知内容由-c或–content参数指定或者由stdin读取。如需操作参数的帮助,请使用–help-actions参数。(即termux-notification --help-actions))
–action action action to execute when pressing the notification 设置点按通知时的操作
–alert-once do not alert when the notification is edited
编辑通知即修改通知时不再alert
–button1 text text to show on the first notification button
设置通知的第一个按钮,和按钮的文本
–button1-action action action to execute on the first notification button
设置点按第一个按钮时的操作(2,3同理)
–button2 text text to show on the second notification button
–button2-action action action to execute on the second notification button
–button3 text text to show on the third notification button
–button3-action action action to execute on the third notification button
-c/–content content content to show in the notification. Will take precedence over stdin. If content is not passed as an argument or with stdin, then there will be a 3s delay.
设置显示在通知中的文本。这个参数设置的文本优先于stdin。如果没有设置这个参数,将采用stdin作为通知文本,并且会延迟3秒。
–group group notification group (notifications with the same group are shown together)
设置通知的组别。(相同组的通知会一起显示)
-h/–help show this help
–help-actions show the help for actions 显示帮助。使用–help-actions参数查看操作方面的帮助。
-i/–id id notification id (will overwrite any previous notification with the same id)
设置通知id。(如果通知中已有某个id的通知,再次使用此id发布通知会覆盖之前的通知)
–icon icon-name set the icon that shows up in the status bar. View available icons at https://material.io/resources/icons/ (default icon: event_note)
设置通知栏中显示的图标。在这个↑网址寻找可用的图标。(好像打不开)(默认使用名为 event_note 的图标)
–image-path path absolute path to an image which will be shown in the notification
设置通知中显示的图片,要用图片的绝对路径。
–led-color rrggbb color of the blinking led as RRGGBB (default: none)
led灯的颜色,默认是none(这个能变颜色?)
–led-off milliseconds number of milliseconds for the LED to be off while it’s flashing (default: 800)
led等熄灭时的毫秒数(默认是800)
–led-on milliseconds number of milliseconds for the LED to be on while it’s flashing (default: 800)
led灯亮起时的毫秒数(默认是800)
(上两个都默认,则相当于led灯不亮)
–on-delete action action to execute when the the notification is cleared
清除通知时的操作
–ongoing pin the notification
发送持续通知(锁定通知)
–priority prio notification priority (high/low/max/min/default)
设置通知的优先级(high高/low低/max最高/min最低/default默认)
–sound play a sound with the notification
发出通知的同时发出声音
-t/–title title notification title to show
设置通知标题
–vibrate pattern vibrate pattern, comma separated as in 500,1000,200
设置震动模式,逗号分割,例如 500,1000,200
–type type notification style to use (default/media)
设置通知样式。只能选default(默认)和media
Media actions (available with --type “media”):
媒体操作(当设置了–type “media” 时可用)
–media-next action to execute on the media-next button
播放下一首
–media-pause action to execute on the media-pause button
播放暂停
–media-play action to execute on the media-play button
继续播放
–media-previous action to execute on the media-previous button
播放上一首
$ termux-notification -i 7 -t ‘mytitle’ -c ‘mytext3’ --button1 ‘button1’ --button1-action ‘date|termux-toast’ --group 0 --led-color ff0000 --led-on 1000 --led-off 2000 --type default --priority max
注:第二次下滑打开状态栏,按钮可能会隐藏,可长按使其显示。长按后如下图:
图片2

$ termux-notification-remove 7

移除通知,参数为通知的id(提前设置,或通过termux-notification-list查看)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

今夕何夕2112

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值