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

copy_notification_images.sh: expire time #1056

Merged
merged 10 commits into from
Mar 25, 2022
Merged

Conversation

EricClaeys
Copy link
Collaborator

This PR introduces the concept of notification image expiration times, the default being 5 seconds.
If a notification was displayed in the last 5 seconds a new one is to be displayed, don't display it.
For example, if we just displayed "Restarting Allsky" then don't display a "Allsky is starting up" notification because the user likely won't see the "Restarting Allsky" message.

This PR also keeps a log of the notification images displayed. A future PR will have allsky.sh truncate the log so it only lasts through the current Allsky session. This will be more important in the future when the capture programs can be sent a signal to re-read the settings, since that will be done in the same session.

This PR also allows a program calling copy_notification_images.sh to pass in argument to create a custom notification message.
The capture programs and allsky.sh will be modified in a future PR to do this when, for example, the cause of an error is known - it can be displayed in the notification message to better alert the user as to what the problem is. This should aid in support.

* New variable NOTIFICATIONFILETYPE to hold ${1} which is the notification type we are to display.
* Added LAST_NOTIFICATION_FILE to hold the file name that contains the timestamp and notification type that was last displayed.  Subsequent calls to copy_notification_image.sh check if the timestamp on the file is "recent", and if so, skip the current notification.
* Added "_" to $NOTIFICATIONFILETYPE and $NOTIFICATIONFILE
* Renamed $RECENTLY to $EXPIRES_IN_SECONDS and made it an optional command-line argument.  Some notification messages may want to wait longer than normal, for example, "Restarting"  since it can take  several seconds to restart.
* Renamed $LAST_NOTIFICATION_FILE to $ALLSKY_NOTIFICATION_LOG  and moved to variables.sh so allsky.sh can use it.
* Improved some comments.
* Save Notification_type,expires_in_seconds,expiration_time to log file, not just Notification_type.
* If the passed-in EXPIRES_IN_SECONDS is 0, then force sending the notification, even if we just sent a different one.
This will be used by notifications that typically stay for a while, like taking dark frames, non-recoverable error, and not taking pictures during daytime
Since the ALLSKY_NOTIFICATION_LOG now contains all log entries in this session, the name of the file no longer contains "last".
* Created usage_and_exit() function to centralize displaying the usage.
* Added "--help" option.
* Renamed "NOTIFICATION_FILETYPE" to "NOTIFICATION_TYPE" since it's not a file type.
* Changed "expires_in_seconds" from being after the notification type on the command line, to being "--expires seconds".  This allowed the next change...
* Added ability to create custom notifications when "notification_type" is "custom".  The "custom_args" command-line arguments specify the attributes of the notification.  allsky.sh and the capture* programs will use that feature in a separate PR.
* Tell generate_notification_images.sh what directory to put the image in
* Use "find" instead of "ls", per shellcheck.
* Check for failed "cp".
Copy link
Collaborator

@AndreasLMeg AndreasLMeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine for me. Reviewed but not tested.
After your merge I will update my system und make some testing

@EricClaeys EricClaeys merged commit 136b16c into master Mar 25, 2022
@EricClaeys EricClaeys deleted the save-last-notification branch March 25, 2022 13:38
@EricClaeys
Copy link
Collaborator Author

EricClaeys commented Mar 25, 2022 via email

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.

None yet

2 participants