Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Onetime functionality #2

Merged
merged 6 commits into from
Sep 19, 2020
Merged

Onetime functionality #2

merged 6 commits into from
Sep 19, 2020

Conversation

budRich
Copy link
Contributor

@budRich budRich commented Sep 19, 2020

this patch adds -o option. If set, xnotify will terminate after the first notifications timeout is reached.

with this functionality together with #1 one can achieve a simple yet dynamic notification center.

f.i. One can have a normal xnotify process reading from a fifo:

mkfif /tmp/xnotify.fifo
cat /tmp/xnotify.fifo > xnotify -G SE &

But also spawn context specific onetime notifications at the same time:

#!/bin/bash
[[ everything_beautiful = must_die ]] && { echo "its true you know" | xnotify -c '#FF0000' -s 5 -o -G NW   ;}
echo notification has been shown

It can also be used to "pause" execution of a script (like example above).

added commandline option -o
if present it will set int onetime to 1

timeitems() now returns an int (number of deleted notifications)

at end of mainloop, if (config.onetime && timeitems()) break;
@phillbush
Copy link
Owner

Nice addition.
I'm gonna merge it and do some modifications, in special, remove the onetime flag from the config structure since it is not set on config.h at compile time, but on command line option at runtime, and adapt the indentation and comment style to the rest of the program.

One downside of this -o option is that it does not queue the notifications, so if you invoke two xnotify instances at the same time the notifications will overlap one another. Cating a fifo into xnotify and echoing a line on demand queue the notifications, since only a single xnotify instance would be involved.

@phillbush phillbush merged commit efd7d7d into phillbush:master Sep 19, 2020
@phillbush
Copy link
Owner

I removed xnotify.h accidentally, I was supposed to just remove a line...

@budRich budRich deleted the onetime branch September 19, 2020 12:10
phillbush added a commit that referenced this pull request Sep 28, 2020
@phillbush
Copy link
Owner

I removed the -o flag and made the one-time behavior the default behavior for xnotify.
(That is, now when you echo Hello World | xnotify, xnotify will exit when the notification is done).

@budRich
Copy link
Contributor Author

budRich commented Sep 29, 2020

sweet!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants