This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Calculate birthday age

Tags: None
(comma "," separated)
manjato
Registered Member
Posts
4
Karma
0

Calculate birthday age

Wed May 20, 2020 4:48 am
Starting to use Kalarm for reminders including birthdays can Kalarm calculate the age of an birthday and how to get this.

Example: insert Smith <1950> showing “Smith 70th Birthday” or something like this.
Thank you
djarvie
KDE Developer
Posts
103
Karma
0
OS

Re: Calculate birthday age

Fri May 22, 2020 12:10 am
There is no specific facility in KAlarm to do what you want. However, by some simple scripting, and the use of command output in a display alarm, it is possible. For example:

Create a script ~/bin/birthday_message.sh which takes two parameters (name and birth year), with contents
Code: Select all
#!/bin/bash
echo $1 birthday - age $(($(date +%Y) - $2))

Remember to set the script file's permissions to allow execution: either do this in a file manager, or enter the following command in a terminal:
Code: Select all
chmod +x ~/bin/birthday_message.sh

Then, to create a birthday alarm for Smith, who was born in 1950, select New Display Alarm, and in the dialog set the Display type to Command output. Do NOT check Enter a script. In the script text box, enter
Code: Select all
~/bin/birthday_message.sh Smith 1950

Then set the alarm to recur every year on the person's birthday date. The text shown in the alarm message for this person's birthday this year would be "Smith birthday - age 70".


KAlarm author
manjato
Registered Member
Posts
4
Karma
0

Re: Calculate birthday age

Fri May 22, 2020 7:36 am
I like the idea and thank you for it. It could be a add on to the program.
I have few problems one is don't know scripting .
Second is this written in Terminal?
Third where is this script installed?
I f you can help me to achieve this it will be a great.
Thank you
djarvie
KDE Developer
Posts
103
Karma
0
OS

Re: Calculate birthday age

Fri May 22, 2020 9:41 am
A script is a plain text file with commands in it. To create it, use a text editor, for example Kate, but NOT a word processor because that might add formatting characters which would prevent the script from working. The most reliable way of creating the script would be to copy and paste its contents from my last message, and make sure you don't insert any spaces before the first '#' character. As I said, the script file needs to have executable permissions in order to work.

You can install the script anywhere you want. In my example, it is in the file called birthday_message.sh in ~/bin, which is the the directory called "bin" in your home directory. But you could equally put it in your documents directory, or anywhere else that you prefer. You just need to put the script file's full path into the text entry field in the KAlarm edit dialog, so that KAlarm can find it.

I hope this explains things enough. If you need more help, please ask.


KAlarm author


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], kesang, Yahoo [Bot]