惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
F
Fortinet All Blogs
云风的 BLOG
云风的 BLOG
MyScale Blog
MyScale Blog
D
DataBreaches.Net
Stack Overflow Blog
Stack Overflow Blog
A
About on SuperTechFans
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
腾讯CDC
The GitHub Blog
The GitHub Blog
Jina AI
Jina AI
B
Blog RSS Feed
I
InfoQ
N
Netflix TechBlog - Medium
T
The Blog of Author Tim Ferriss
Microsoft Azure Blog
Microsoft Azure Blog
Recent Announcements
Recent Announcements
GbyAI
GbyAI
H
Help Net Security
L
LangChain Blog
M
MIT News - Artificial intelligence
Y
Y Combinator Blog
aimingoo的专栏
aimingoo的专栏

mephisto.cc

修复rime-ice无法弹出候选框的问题 开机滚动字体显示优化 个人网站安全防护 树莓派上部署Vaultwarden 使用goaccess实时分析Caddy日志 个人网站监控 Hugo全站AVIF记 Linux下尝试使用Godot开发小游戏 Arch linux dae 透明代理 Airflow接管galler-dl下载任务 如何使用gallery-dl批量下载图像 Arch核显下如何愉快玩Dota2和CS2 Arch/labwc 环境网络相关设置 Rime添加dota2词库 Arch 重装记录 Supertuxkart iOS版终于发布了 打造自己的流媒体音乐服务 剪切板管理工具clipcat推荐 MangoHud性能监控 微信小程序开发记 Rofi试用 解决Arch下VSCode无法输入中文的问题 独立窗口管理器下无法录屏问题处理 上海市二手房成交数据监控 OpenLDAP监控 Arch linux如何顺畅连接蓝牙设备 使用Git和Ansible管理配置文件 Arch Linux SSL VPN 客户端配置 简单获取celery任务实时结果 Arch linux下iNode客户端的安装和使用方法
Ubuntu notify-send 定时通知
2022-05-22 · via mephisto.cc

使用Ubuntu的工作学习的话,有时候想给自己定时发送通知提醒,比如喝水、下班打卡什么的,使用notify-send + crontab即可简单实现:

➜  ~ env |grep -E 'DISP|DBUS'
DISPLAY=:0
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
➜  ~ crontab -l |grep -v ^#  
* * * * * DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus notify-send '紧急通知' '<b> <u>这个世界很安静是吗?</u></b>' -i /home/mephisto/Pictures/404.jpg
➜  ~ cat /etc/issue
Ubuntu 22.04 LTS \n \l
➜  ~ notify-send --help
Usage:
notify-send [OPTION…] <SUMMARY> [BODY] - create a notification

Help Options:
-?, --help                        Show help options

Application Options:
-u, --urgency=LEVEL               Specifies the urgency level (low, normal, critical).
-t, --expire-time=TIME            Specifies the timeout in milliseconds at which to expire the notification.
-a, --app-name=APP_NAME           Specifies the app name for the icon
-i, --icon=ICON[,ICON...]         Specifies an icon filename or stock icon to display.
-c, --category=TYPE[,TYPE...]     Specifies the notification category.
-h, --hint=TYPE:NAME:VALUE        Specifies basic extra data to pass. Valid types are int, double, string and byte.
-v, --version                     Version of the package.

先查看环境变量DISPLAY和DBUS_SESSION_BUS_ADDRESS的值,接着如上面所示,添加自己的提示任务,测试了下DISPLAY不是必须的,第二个环境变量设定看起来有点复杂,小功能使用场景少懒得查证了,有精力和兴趣的可以探究