AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题

问题[notify-send](ubuntu)

Martin Hope
4n3wv
Asked: 2020-03-05 07:28:06 +0800 CST

清理命令的输出以通过管道发送到通知发送

  • 1

Ubuntu 18.04

ExpressVPN 没有适用于 Linux 版本的 GUI 或图标。所以我把一个 .desktop 文件放在一起,然后在我的任务栏上添加了可点击的按钮来触发它们。.desktop 文件触发脚本,这些脚本运行命令以连接 VPN,或断开它,或显示指示当前状态的弹出消息。

这是我需要一些建议的状态。获取状态的命令是:

expressvpn status

在终端中运行该命令时,如果 VPN 已断开连接,您会看到:

未连接

如果 VPN 已连接,您会看到:

连接的

我的任务栏按钮触发此脚本:

#!/bin/bash
MESSAGE="expressvpn status"
notify-send --expire-time=500 "`$MESSAGE`"

现在,这行得通。我得到了我需要的信息。但有一些我不喜欢的地方。这并不重要,但我想了解它为什么会发生以及是否可以更改。

如果 VPN 断开连接,它会很好用,我看到一个显示“未连接”的弹出窗口:

清理弹出消息

但是,如果 VPN 已连接,我所看到的会非常难看。它看起来像这样:

丑陋的弹出消息

如果我将相同的输出写入文本文件,它包含以下文本:

[1;32;49mConnected to UK - East London
[0m
   - If your VPN connection unexpectedly drops, internet traffic will be blocked to protect your privacy.
   - To disable Network Lock, disconnect ExpressVPN then type 'expressvpn preferences set network_lock off'.

理想情况下,我希望它只包含上面屏幕截图中显示的绿色行 - “已连接到 [无论哪个连接处于活动状态] ”。

有任何想法吗?

谢谢!

scripts vpn bash .desktop notify-send
  • 1 个回答
  • 442 Views
Martin Hope
wjandrea
Asked: 2019-11-02 12:52:56 +0800 CST

如何制作未保存的通知?

  • 3

我编写的一些脚本会显示诸如“提高音量”或“重置亮度”之类的通知,例如,使用notify-send. 但是,通知会保存在 Ubuntu 18.04 的通知菜单中,我不希望这样,因为重复的次数太多了。我该如何防止呢?


这是我尝试过的:

  • 检查man notify-send但没有看到有关不保存通知的任何选项。
  • notify-send --urgency=low- 没有不同
  • 研究了“gnome toast 通知”,但显然它们是特定于应用程序的,这对我不起作用
  • 考虑使用 Zenity,但我找不到一种方法来制作不会窃取焦点的通知。
  • 在 Python 中,创建一个Notify.notification对象.show()两次 - 没有区别
notification notify-osd gnome-shell notify-send 18.04
  • 1 个回答
  • 844 Views
Martin Hope
Angular Orbit
Asked: 2019-10-29 22:17:24 +0800 CST

Crontab 未运行任务 [重复]

  • 1
这个问题在这里已经有了答案:
如何在 crontab 中使用通知发送?[重复] (2个答案)
2年前关闭。

然后我crontab -e添加了*/2 * * * * /usr/bin/notify-send "test",它应该每 2 分钟发送一次通知,但它不起作用。

crontab 文件如下所示。

# Edit this file to introduce tasks to be run by cron.
# 
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
# 
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').# 
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
# 
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
# 
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
# 
# For more information see the manual pages of crontab(5) and cron(8)
# 
# m h  dom mon dow   command

*/2 * * * * /usr/bin/notify-send "test"
cron schedule notify-send 19.04
  • 1 个回答
  • 744 Views
Martin Hope
Mateo Gutierrez
Asked: 2019-07-25 14:44:21 +0800 CST

不断检查正在运行的进程

  • 1

我需要检查进程何时运行,并在进程死亡、停止或关闭时发出警报。

我使用了 pgrep 和 processName,然后发出警报,如下所示:

pgrep processName && notifiy-send

但这只是给了我进程的pid,还有其他方法吗?

notification process notify-send
  • 1 个回答
  • 115 Views
Martin Hope
Rafael Muynarsk
Asked: 2019-01-05 17:20:43 +0800 CST

是否可以在我的屏幕上永久显示通知?

  • 4

使用命令notify-send,可以在屏幕上显示一小段时间的通知。但我想在我的屏幕上显示一个特定的通知,时间不定。我正在创建一个由用户启动和终止的脚本,对我来说,拥有一个激活通知然后在我的脚本完成后将其停用的命令会很有用。伪代码将是这样的:

#!/bin/bash

activatenotification "my text"

# my script commands

deactivatenotification

有可能吗?是否有这样的命令行工具,或者我可以使用它做类似的事情notify-send吗?

notification scripts notify-send
  • 1 个回答
  • 560 Views
Martin Hope
Kalle Elmér
Asked: 2018-02-03 02:30:29 +0800 CST

从 systemd 守护进程发送通知

  • 3

我知道我可以向用户发送一条通知,该通知将出现在屏幕右上角并自行消失,如下所示:

notify-send "Device detected correctly"

gnome-terminal但是,这仅在我在图形环境中运行时才有效。

我想从守护进程发送通知。它以不同的用户身份运行,并由 systemd 启动。我怎样才能做到这一点?

notification notify-osd notify-send
  • 1 个回答
  • 1009 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve