Giter VIP home page Giter VIP logo

notify-send.sh's Introduction

Россияне! Остановите эту бессмысленную войну

Я — одессит, русский — мой родной язык, как и для миллиона одесситов. Я, как и абсолютное большинство русскоговорящих здесь, считаю себя украинцем и желаю жить в независимой Украине. Мы имеем право на самоопределение. Россияне не имеют права определять нас.

Россия ведёт войну против Украины. Десятки тысяч людей погибли и продолжают гибнуть. Треть украинцев были вынуждены покинуть свои дома. Города, в которых велись боевые действия, находятся в руинах. Украинцы это испытывают сейчас и видят эти ужасы своими глазами, а не по телевизору за тысячи километров. Выключите телевизор в своих головах. Прислушайтесь к людям, которые живут в Украине. Остановите эту бессмысленную войну

Мариуполь

Разрушенный Мариуполь

05 апреля 2022 - Разрушенный Мариуполь

Reuters / Scanpix / LETA

Спутниковое фото, на котором виден разрушенный Мариуполь

31 марта 2022 - Спутниковое фото, на котором виден разрушенный Мариуполь

Maxar Technologies / AP / Scanpix / LETA

Харьков

Последствия обстрела Харькова

01 марта 2022 - Харьков

Последствия обстрела Харькова российскими войсками

Sergey Dolzhenko / EPA / Scanpix / LETA

Люди прячутся в метро Харькова, которое во время войны превратилось в бомбоубежище

25 марта 2022 - Харьков

Люди прячутся в метро Харькова, которое во время войны превратилось в бомбоубежище

Efrem Lukatsky / AP / Scanpix / LETA

Николаев

30 марта 2022 - Здание областной администрации в Николаеве после обстрела. 37 человек погибших, не менее 33 человек были ранены

Petros Giannakouris / AP / Scanpix / LETA

9 июня 2022 - Николаев регулярно подвергается артиллерийским обстрелам — с начала войны, по данным властей, в нем погибли 108 жителей, были повреждены около 1200 домов.

Буча

Мертвые люди на улице в городе Буча. Здесь и в других населенных пунктах Киевской области после ухода российских войск обнаружили множество тел. По информации украинских властей и СМИ, это мирные жители, убитые российскими военнослужащими.

03 апреля 2022 - Буча

Мертвые люди на улице в городе Буча.

Здесь и в других населенных пунктах Киевской области после ухода российских войск обнаружили множество тел мирных жителей, убитых российскими военнослужащими.

Ronaldo Schemidt / AFP / Scanpix / LETA

Одесса

04 июня 2022 — Сергеевка, Одесская область. Из-за ракетного обстрела российскими войсками многоквартирного дома и базы отдыха погиб 21 человек, в том числе и ребенок, 39 человек — в больнице

Чернигов

22 ареля 2022 — Чернигов

notify-send.sh's People

Contributors

baod-rate avatar bsilvereagle avatar edaubert avatar lsteeger avatar luigi-98 avatar nylen avatar phrozenbyte avatar vlevit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

notify-send.sh's Issues

bash

Hello, isn"t this better on the first line?

!/usr/bin/env bash

(this works on systems, where bash is not in /bin/bash - like FreeBSD)

notification position under void/xfce

Hey there!
I used your brilliant code to script a simple volume notification under xfce and void linux.
The issue that I have is that the notifications will not appear in the position specified under Settings Manager > Notifications. No matter what I do, the notification appears in the upper right corner.
Any hint to what I'm doing wrong or what I can do to change the position another way somehow?
(I cannot use the -h int:x/y:value hint, because xfce-notifyd does not understand these.)

Any help would be appreciated! Thanks!

Color

Is there any way to add color to the text ?

notify-send.sh -t 4000 "<i>Time Now</i>" "<span color='#57dafd' font='26px'><i><b>color text</b></i></span>" >/dev/null 2>&1

Doesn't seem to work

Doesn't seem to working out for me.

I am using Manjaro with i3-gaps wm. I tried all combos but didn't work.
I am using fish if it matters.
I tried it in bash also, but same thing.
I have glib2 installed too.
Also it takes about 50 seconds to run the command then nothing happens.
Is there logging functionality? I can't find it.

Start another notification from "--action=" and newline is not inserted

Hi, I have a bash script which does some actions and then display a notification which contains the --action= flag, which does other actions, is set as follow:

notify-send.sh -u critical -t 0 -o Execute:'command1; command2' --icon=/path/to/icon/icon.png " " "<span color='#F6FF45' font='16px'><b>$processname\nThe commands has been executed</b></span>"

After 'command1; command2' I would like to add another notification, so I tried:

notify-send.sh -u critical -t 0 -o Execute:'command1; command2; notify-send.sh -u critical -t 0 --icon=/path/to/icon/icon.png "$processname\nrestored"' --icon=/path/to/icon/icon.png " " "<span color='#F6FF45' font='16px'><b>$processname\nThe commands has been executed</b></span>"

Which half-works: the fact is that in the second notification, the new line parameter "\n" is not applyed and furthermore $processname\nrestored is not displayed at all, when in the first notification, is properly displayed. And if I execute notify-send.sh -u critical -t 0 --icon=/path/to/icon/icon.png "$processname\nrestored" alone, works as expected.
What I am missing?

What I have been able to achieve for now is:

notify-send.sh -u critical -t 0 \
 --icon=/path/to/icon/icon.png \
"$processname\nhas been paused and minimized" \
-o \
Resume:'notify-send.sh -u critical -t 0  --icon=/path/to/icon/icon.png \
"$processname \
Restored"'

In this way the second notification display the message, but the newline is not inserted (only in the first notification, the new line is inserted).

EDIT:

Well, I needed to escape the new line as follow:

"$processname \
\\n\
has been restored"'

Feel free to close this ticket, or to say anything about, if there is another way to achieve the aim :-)

D-Bus Support

This seems to depend on GDBUS explicitly, is it possible to add an option to support D-Bus directly?

I don't have anything gnome installed except the terminal, and the doesn't seem to be anything on the GDBUS.

But

dbus-monitor --session "type='signal',path=/org/freedesktop/Notifications,interface=org.freedesktop.Notifications"

correctly prints the action click messages

I can try to give you a PR if you're open to that

Enhancement: Show QR Codes generated in /tmp

It would be great to add a python generated QR Code just big enough to be readable in the main body of the message.

$ sudo pip3 install pyqrcode
$ sudo pip3 install pypng
import pyqrcode
import png
from pyqrcode import QRCode

url = "http://www.example.com"
qrl = pyqrcode.create(url)
irl = "/tmp/qr_" + url.replace("://", "-") + ".png"

qrl.png(irl, scale =8, module_color=[0, 0, 0, 255], background=[0xff, 0xff, 0xff])

https://www.geeksforgeeks.org/python-generate-qr-code-using-pyqrcode-module/
https://github.com/phuhl/notify-send.py

several things...

I had a few problems with this script, and ended up resolving them, and in the process did a complete re-write, or refactor more exactly.

I don't think you want my stylistic chnages (but I do) so I don't have a pull-request, however, I re-created a fresh git commit history in a fork where I tried to do most of the stylistic stuff in the first couple commits and then the rest of the commits show the functional changes more clearly.

You may or may not be interested, but here is the fork with a commit history that should be more or less readable so you can see how I got rid of all the seds and other unneeded external tools like bc and dc etc, and resolved my main problem which was background processes that just accumulated forever because of not really handling the conditions that can happen with notifications.

I tried to make each commit add one conceptual change. Not always perfectly but pretty close mostly.
You could also just look at the final/current version and probably get it.
https://github.com/bkw777/notify-send.sh

This version is now working well and bulletproof for me.

Two things I did which I want in my copy that you may not want are,
1 - I execute the action command directly, not with "bash -c". If I really need to execute a command that needs bash interpretation, like redirection, I'll just run bash as the command, and bonus, it doesn't have to be bash. Otherwise, the 99% common case is running a binary or script with args, and I'd rather optimize for that, no unnecessary extra shell process.
2 - I removed the use of printf %q on the action command in send.sh. I haven't missed it, and I think it was the cause of a cosmetic ugliness where the -d command or any -o command with empty button label, produced a button that looked like [ ' ' ] (I undertstand that could be dependat on the particular notification daemon, still, I no longer have that problem. Now if I specify and emty label, I get a clean blank button.) However, I haven't tried every crazy possible command string, just some basics that do include spaces and embedded escaped quotes etc, and they all worked. It's possible that without the %q there are command strings that used to work that now don't.

--action blocks until button is pressed or notification expires

My use case:

  1. Take a screenshot
  2. Show a notification using this library saying it's uploading to hosting service, show a button to copy the raw image to clipboard in meantime
  3. When done uploading, replace the original notification with one containing 2 buttons: one to copy the url of the image and one to copy raw image

Issue: notify-send with --action parameter won't return until action is triggered or notification expires. This means I can't start uploading the image until one of either happens.

-o action only works during initial display timout, not from notification history

Is there any way to make the action buttons keep working after the notification has timed out and gone to the notification daemon's history?

Example, my desktop default notification timeout is set to only 3 seconds. (lxqt-notificationd in my case). Notifications only appear briefly, then stack up in a history I can pull up when I want.

Now take this command:
notify-send.sh -o eyes:xeyes "" ""

If I press the "eyes" button during that first 3 seconds, it works.

If I allow the notification to expire, and then pop it back up from the history, the "eyes" button is still there and still clickable, but has no effect.

I see that during the initial display time there are two notify-action.sh processes that exist in the background while the notification is visible the first time. Once it times out, both of those disappear. When I pull the notification back up from the history, the bg processes do not reappear with it, so that surely explains why the button no longer functions.

Is there a way to make it so the monitor process doesn't go away until the user actively does something with the notification?

In my case, I'm trying to use this from within https://github.com/bkw777/mainline
In that context, it would be ok to have a single notification that gets refreshed or replaced rather than a stack of individual notifications. So maybe there is some way to rig this up using -p or -r or -R or something?

Otherwise, the best I can think of right now is I can override the timeout by using the -t option to specify a very long timeout, and maybe add the -f option, so that the notification never goes to the history, it's either visible and working, or totally gone.

Permission issues and other fun stuff.

Running on Linux Mint 18 "Sarah" (which is based on Ubuntu 16.04)
on 64 bit architecture.

After getting past the permission errors with (sudo sh), there are some additional problems:

(The script was run from the home folder).

sudo sh ./notify-send.sh --print-id Subject Message
./notify-send.sh: 23: ./notify-send.sh: Syntax error: "(" unexpected

I checked line 23 and this is what is in there:

NOTIFY_ARGS=(--session

It would be very nice of you to investigate this. Thank you. I really need that "re-draw" ish feature, as killing dunst every time I want to update causes uneccesary flickering due to the delay of restarting dunst (and I assume any other notification server).

Bypass GNOME's "no expiration" design decision

GNOME made the (pretty weird) "design decision" to always ignore the expire time of notifications and even making all notifications persistent (the latter since the introduction of GNOME's notification center). Most applications bypass this behaviour by manually closing notifications after some individual timeouts (yes, instead of unifying expiration times, GNOME made it worse).

It would be great if notify-send.sh could easily bypass this behaviour, too. I wrote a simple wrapper script, even though implementing this into notify-send.sh's base script would obviously be simpler and a better approach:

#!/bin/bash
EXPIRE_TIME=-1
PRINT_ID=

NOTIFY_ARGS=()
while (( $# > 0 )); do
    case "$1" in
        -t|--expire-time|--expire-time=*)
            [[ "$1" = --expire-time=* ]] \
                && EXPIRE_TIME="${1#*=}" \
                || { shift; EXPIRE_TIME="$1"; }
            NOTIFY_ARGS+=( --expire-time "$EXPIRE_TIME" )
            ;;

        -p|--print-id)
            PRINT_ID=yes
            NOTIFY_ARGS+=( --print-id )
            ;;

        *)
            NOTIFY_ARGS+=( "$1" )
            ;;
    esac
    shift
done

NOTIFY_SEND="$(dirname "${BASH_SOURCE[0]}")/notify-send.sh"
if (( "$EXPIRE_TIME" != -1 )); then
    NOTIFICATION_ID="$("$NOTIFY_SEND" --print-id "${NOTIFY_ARGS[@]}")"
    NOTIFY_RC=$?

    if [[ -n "$PRINT_ID" ]]; then
        echo "$NOTIFICATION_ID"
    fi

    if (( "$EXPIRE_TIME" > 0 )); then
        SLEEP_TIME="$(bc <<< "scale=3; $EXPIRE_TIME / 1000")"
        ( sleep "$SLEEP_TIME" ; "$NOTIFY_SEND" --close "$NOTIFICATION_ID" ) &
    else
        "$NOTIFY_SEND" --close "$NOTIFICATION_ID"
    fi

    exit $NOTIFY_RC
fi

"$NOTIFY_SEND" "${NOTIFY_ARGS[@]}"
exit $?

-o and -d options not working

For me, when using options -o or -d (and even their long versions) it shows

Unknown option -o

System: Manjaro Linux
Desktop: KDE Plasma 5

Installed from AUR

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.