Custom notifications

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
john138
Level 1
Level 1
Posts: 21
Joined: Thu Dec 05, 2019 11:44 am

Custom notifications

Post by john138 »

I would like to create a notification that displays a block of text or opens a text file at boot-up on specific dates. I looked at All Applications > Notifications but I cannot see how to use it. Any suggestions. please?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Welcome
Level 6
Level 6
Posts: 1026
Joined: Wed Aug 19, 2020 11:38 am

Re: Custom notifications

Post by Welcome »

How much bash experience do you have?

I can help you set up a really neat little thing, but I need to know how much of the code I need to write, or if I can just give you some quick ideas.
Welcome
Level 6
Level 6
Posts: 1026
Joined: Wed Aug 19, 2020 11:38 am

Re: Custom notifications

Post by Welcome »

Try this code, as a sample of what could be done.

Copy this code and paste it into a text document. Save it on your desktop as "SpecialNotice".

Code: Select all

#!/bin/bash

# Determine today's date in the format YYYY-mm-dd
mydate=$( date +%F )

if [[ $mydate == 2020-09-26 ]]; then
    # notify-send - a program to send desktop notifications   
    # -u can be low, normal or critical (critical must be manually cleared)
    # -i icons  from /usr/share/icons
    notify-send -u critical -i /usr/share/icons/gnome/16x16/emotes/face-smile.png "summary goes here" "the body goes here"
fi

# end of file

Open a terminal and enter this:

Code: Select all

chmod 755 ~/Desktop/SpecialNotice
Since today is 2020-09-26, double click it and run it in a terminal. Look up at the upper right of your screen.

Is this something that you could use? Can you edit the file to change the date and message? Please let me know how much help you need, and I'll be happy to assist.
Welcome
Level 6
Level 6
Posts: 1026
Joined: Wed Aug 19, 2020 11:38 am

Re: Custom notifications

Post by Welcome »

If you like the SpecialNotice bash script, you can add it to your Startup Applications.

Open up Startup Applications, click the '+' at the bottom to Add, select Custom Command. Put in a name, perhaps "Special Notice", and then click Browse... to find and select your version of the SpecialNotice script. I'd recommend a startup delay of maybe 30 to 60 seconds. Save it. I recommend clicking on the 'Test' icon at the bottom right (it looks like gears). If everything is okay, exit Startup Applications, and you're done!

There are some other options. You might be interested in KAlarm with the ability set up alarms at special times and dates.
Welcome
Level 6
Level 6
Posts: 1026
Joined: Wed Aug 19, 2020 11:38 am

Re: Custom notifications

Post by Welcome »

There are other options, too. For example you could change the script to use zenity...

Code: Select all

#!/bin/bash

# Determine today's date in the format YYYY-mm-dd
mydate=$( date +%F )

if [[ $mydate == 2020-09-28 ]]; then
    # zenity  is  a program that will display GTK+ dialogs
    # see man zenity for options
    zenity --info --width=500 --timeout=60 --title="Title goes here" --text="Put the main body of your info here"
fi

if [[ $mydate == 2020-09-27 ]]; then
    # notify-send - a program to send desktop notifications
    # -u can be low, normal or critical (critical must be manually cleared)
    # -i icons  from /usr/share/icons
    notify-send -u critical -i /usr/share/icons/gnome/16x16/emotes/face-smile.png "Title goes here" "Put the main body of your info here"
fi

# end of file

Edit: BTW, zenity offers a number of different dialogs and options. Take a look at man zenity for details!
Last edited by Welcome on Sun Sep 27, 2020 1:15 pm, edited 1 time in total.
Welcome
Level 6
Level 6
Posts: 1026
Joined: Wed Aug 19, 2020 11:38 am

Re: Custom notifications

Post by Welcome »

john138 wrote: Sat Sep 26, 2020 3:55 am I would like to create a notification that displays a block of text or opens a text file at boot-up on specific dates. I looked at All Applications > Notifications but I cannot see how to use it. Any suggestions. please?
To create a notification that displays a block of text or opens a text file at boot-up on specific dates, try this...

Code: Select all

#!/bin/bash

# Determine today's date in the format YYYY-mm-dd
mydate=$( date +%F )

if [[ $mydate == 2020-09-27 ]]; then
    # xed is a text editor
    xed ~/Desktop/SpecialNotice
fi

if [[ $mydate == 2020-09-28 ]]; then
    # zenity  is  a program that will display GTK+ dialogs
    zenity --info --width=500 --timeout=60 --title="Title goes here" --text="Put the main body of your info here"
fi

if [[ $mydate == 2020-09-29 ]]; then
    # notify-send - a program to send desktop notifications
    # -u can be low, normal or critical (critical must be manually cleared)
    # -i icons  from /usr/share/icons
    notify-send -u critical -i /usr/share/icons/gnome/16x16/emotes/face-smile.png "Title goes here" "Put the main body of your info here"
fi

# end of file

Is this what you're looking for? If you need something else, just let me know! And there's many other ways to do this! Want to add a little sound to the notice? It's fairly easy, too.
john138
Level 1
Level 1
Posts: 21
Joined: Thu Dec 05, 2019 11:44 am

Re: Custom notifications

Post by john138 »

Thanks, I think that points me in the right direction. I'm still learning the basics of Linux (takes a while at my age!). Hadn't spotted there's an application called Startup Applications.
Thanks again.
Welcome
Level 6
Level 6
Posts: 1026
Joined: Wed Aug 19, 2020 11:38 am

Re: Custom notifications

Post by Welcome »

Which version of Linux Mint are you using? If it's Linux Mint 20 Cinnamon, you can find Startup Applications on the menu under Preferences. Or, a quicker way to find it is to click on the start button, and then start typing 'start' in the search box. That's what I normally do. I've found that this search box is a lot easier if you know the name of the application.
tkocou
Level 2
Level 2
Posts: 82
Joined: Mon Jul 30, 2012 6:25 pm

Re: Custom notifications

Post by tkocou »

Very nice approach. I wanted a simple alert and tried 'kalarm'. What I got was a slew of extra options which I did not want. To make matters worse, the extra 'stuff' slowed down my system. So, I purged the 'akonadi' stuff and got my system performance back to normal.
I came across this posting while searching the forums. Thank you. I'll combine the zenity idea with a crontab entry to get the selectivity I need for popping the notification on the screen. Example: every Monday through Friday at 1 pm, pop a reminder on the screen.
Welcome wrote: Sun Sep 27, 2020 7:32 am There are other options, too. For example you could change the script to use zenity...

Code: Select all

#!/bin/bash

# Determine today's date in the format YYYY-mm-dd
mydate=$( date +%F )

if [[ $mydate == 2020-09-28 ]]; then
    # zenity  is  a program that will display GTK+ dialogs
    # see man zenity for options
    zenity --info --width=500 --timeout=60 --title="Title goes here" --text="Put the main body of your info here"
fi

if [[ $mydate == 2020-09-27 ]]; then
    # notify-send - a program to send desktop notifications
    # -u can be low, normal or critical (critical must be manually cleared)
    # -i icons  from /usr/share/icons
    notify-send -u critical -i /usr/share/icons/gnome/16x16/emotes/face-smile.png "Title goes here" "Put the main body of your info here"
fi

# end of file

Edit: BTW, zenity offers a number of different dialogs and options. Take a look at man zenity for details!
Linux Mint 21.1 Cinnamon
User avatar
AndyMH
Level 21
Level 21
Posts: 13753
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Custom notifications

Post by AndyMH »

An alternative to zenity is yad, not installed by default. It offers more options than zenity.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
tkocou
Level 2
Level 2
Posts: 82
Joined: Mon Jul 30, 2012 6:25 pm

Re: Custom notifications

Post by tkocou »

Thank you for the information. I'll have a look at 'yad'
Linux Mint 21.1 Cinnamon
Locked

Return to “Software & Applications”