OESF Portables Forum
Model Specific Forums => Sharp Zaurus => Zaurus - pdaXrom => Topic started by: Christoph on August 04, 2005, 11:27:40 am
-
Hi fvwm-users (and others),
perhaps you are interested in a menu that shows the coming appointments and
todos from your .ics calendar file.
I wrote it because I do not want to have kopi open all the time and I missed a
feature like the "Today" app for opie and qpe. And for pleasure, of course ;-)
It is writen in AWK and builds the menu on-the-fly. To give you an idea how it looks:
[ You are not allowed to view attachments ]
Of couse it may be changed (this one is for my desktop, the pdaXrom version looks different). To integrate it you may do the following:
In your .fvwm2rc add lines like
DestroyFunc RecreateTodayMenu
AddToFunc RecreateTodayMenu
+ I DestroyMenu recreate TodayMenu
+ I ChangeMenuStyle today TodayMenu
+ I Piperead '$[HOME]/bin/appointment-applet.awk MENU_NAME=TodayMenu\
DAYSAHEAD=10\
$[HOME]/kdepim/config/korganizerrc\
$[HOME]/kdepim/apps/korganizer/mycalendar.ics'
+ I AddToMenu TodayMenu DynamicPopupAction RecreateTodayMenu
CopyMenuStyle * today
Colorset 31 fg black, bg white, sh #ababab, hi white
MenuStyle today ItemFormat "%3i%5.5l%.2r"
MenuStyle today MenuColorset 31
ChangeMenuStyle today TodayMenu
AddToMenu TodayMenu DynamicPopupAction RecreateTodayMenu
# Add to root menu
AddToMenu MenuFvwmRoot Popup TodayMenu
Of course the script may also by used by others. It is structured in a simple way.
There is the BEGIN block where some defaults are set. There you should change the
icons to ones that exists on pdaXrom.
Then comes the evaluation of the text lines from korganizerrc and mycalendar.ics.
The special block /END:(VEVENT|VTODO)/ collects the data for one appointment or todo and stores it in arrays.
In the END block that data is printed.
If you intend to use it on the desktop be sure to have gawk installed. At least with the awk version that comes with ubuntu base installation the script doesn't work. On pdaXrom I had no problems.
I hope you like it and I would appreciate comments and hints to enhance it.
Christoph
-
I havn't had a chance to check it out properly, but it looks really good. You may actually have something there that can help with another issue, that of waking the Z up when the next alarm comes in.
I've been trying to work out iCalander support in python last night and am battling with the really sparse document (plus the fact that korganizer stores its .ics without \r\n, so it breaks a parse). What I'm trying to work out is when the NEXT alarm is.
Can your script work that out easily? If so I'll put up a script that when a uses suspends the Z, it calls the script to work out next alarm (either relative time, or absolute time), uses apmsleep when suspending such that when the alarm is due, it will wake the Z up for it.
- Bundabrg
Hi fvwm-users (and others),
perhaps you are interested in a menu that shows the coming appointments and
todos from your .ics calendar file.
I wrote it because I do not want to have kopi open all the time and I missed a
feature like the "Today" app for opie and qpe. And for pleasure, of course ;-)
It is writen in AWK and builds the menu on-the-fly. To give you an idea how it looks:
[ You are not allowed to view attachments ]
Of couse it may be changed (this one is for my desktop, the pdaXrom version looks different). To integrate it you may do the following:
In your .fvwm2rc add lines like
DestroyFunc RecreateTodayMenu
AddToFunc RecreateTodayMenu
+ I DestroyMenu recreate TodayMenu
+ I ChangeMenuStyle today TodayMenu
+ I Piperead '$[HOME]/bin/appointment-applet.awk MENU_NAME=TodayMenu\
DAYSAHEAD=10\
$[HOME]/kdepim/config/korganizerrc\
$[HOME]/kdepim/apps/korganizer/mycalendar.ics'
+ I AddToMenu TodayMenu DynamicPopupAction RecreateTodayMenu
CopyMenuStyle * today
Colorset 31 fg black, bg white, sh #ababab, hi white
MenuStyle today ItemFormat "%3i%5.5l%.2r"
MenuStyle today MenuColorset 31
ChangeMenuStyle today TodayMenu
AddToMenu TodayMenu DynamicPopupAction RecreateTodayMenu
# Add to root menu
AddToMenu MenuFvwmRoot Popup TodayMenu
Of course the script may also by used by others. It is structured in a simple way.
There is the BEGIN block where some defaults are set. There you should change the
icons to ones that exists on pdaXrom.
Then comes the evaluation of the text lines from korganizerrc and mycalendar.ics.
The special block /END:(VEVENT|VTODO)/ collects the data for one appointment or todo and stores it in arrays.
In the END block that data is printed.
If you intend to use it on the desktop be sure to have gawk installed. At least with the awk version that comes with ubuntu base installation the script doesn't work. On pdaXrom I had no problems.
I hope you like it and I would appreciate comments and hints to enhance it.
Christoph
[div align=\"right\"][a href=\"index.php?act=findpost&pid=90752\"][{POST_SNAPBACK}][/a][/div]
-
I looked at the possibility to use the script or awk in general to determine the next
alarm time. The simplest way would have been to use timestamps to determine the
time of the alarm from the begin of the event and the alarm duration.
Unfortunatly the busybox version of awk doesn't know the mktime command, so
that would have to be implemented in awk itself, which in turns look like a bit of work ;-)
Perhaps someone knows a simple solution for that?
Apart from that "little" problem it shouldn't be too hard to implement it.
There is a newer version of the appointment applet that fixes a bug with the Title
(it showed the wrong day and month).
Apart from that I would like to know if the combination of the time zone and summer time
defined in the konquerorrc works. Does the menu show the correct times for everybody?
Christoph
-
Thanks, I've been playing around with it to get the alarm time. Essentially pull off the -PT1H28M etc.. and subtract it from the DTSTART. Just working out how DTSTART etc stores hours and minutes. Nearly done.
BTW, I don't think your script handles recursive events, though that I imagine would be quite difficult.
Thanks for all this. It makes my job far easier . If you made it an applet for matchbox, then you've basically replaced kopi-alarm applet entirely ;-)
- Bundabrg
I looked at the possibility to use the script or awk in general to determine the next
alarm time. The simplest way would have been to use timestamps to determine the
time of the alarm from the begin of the event and the alarm duration.
Unfortunatly the busybox version of awk doesn't know the mktime command, so
that would have to be implemented in awk itself, which in turns look like a bit of work ;-)
Perhaps someone knows a simple solution for that?
Apart from that "little" problem it shouldn't be too hard to implement it.
There is a newer version of the appointment applet that fixes a bug with the Title
(it showed the wrong day and month).
Apart from that I would like to know if the combination of the time zone and summer time
defined in the konquerorrc works. Does the menu show the correct times for everybody?
Christoph
[div align=\"right\"][a href=\"index.php?act=findpost&pid=90918\"][{POST_SNAPBACK}][/a][/div]
-
Thanks, I've been playing around with it to get the alarm time. Essentially pull off the -PT1H28M etc.. and subtract it from the DTSTART. Just working out how DTSTART etc stores hours and minutes. Nearly done.
I'm impressed! How do you subtract "PT1H28M" from, let's say "20040220T091800Z", considering leap years etc?
When it's done I hope you publish it.
BTW, I don't think your script handles recursive events, though that I imagine would be quite difficult.
Right, I still didn't think about that.
If you made it an applet for matchbox, then you've basically replaced kopi-alarm applet entirely ;-)
I am no expert for matchbox (ok, for fvwm neither, but I know a bit more of it than of matchbox).
And I thought that to customize it for other wm than fvwm I would left as an exercise to the reader ;-)
But.
Here is the logical continuation:
[ You are not allowed to view attachments ]
If you managed to include the appointment-applet, this here may simply be included by adding
+ I Piperead '$[HOME]/bin/birthday-applet.awk MENU_NAME=TodayMenu DAYSAHEAD=10 $[HOME]/kdepim/apps/kabc/std.vcf'
just after the line where the appointment applet is read.
And again you have to change the path to the icon to see it in the menu.
Christoph
-
I'm impressed! How do you subtract "PT1H28M" from, let's say "20040220T091800Z", considering leap years etc?
When it's done I hope you publish it.
You do similar with tzadd (which BTW doesn't work for me. I'm -8:00 hours, and if I have an appointment at 7:00am, it comes up with some wierd number).
Essentially I strip off -PT. Convert xD yH zM to minutes. Take DTSTART, subtract minutes from the time, subtract hours and minutes and days if necessary (trying to figure out a portable way of subtracting a day when we need to go back to a previous month).
Thats the plan anyway.
- Bundabrg
-
You do similar with tzadd (which BTW doesn't work for me. I'm -8:00 hours, and if I have an appointment at 7:00am, it comes up with some wierd number).
You are too far away from Greenwich ;-)
I will look at that. I didn't think of day changes with the time zone.
Essentially I strip off -PT. Convert xD yH zM to minutes. Take DTSTART, subtract minutes from the time, subtract hours and minutes and days if necessary (trying to figure out a portable way of subtracting a day when we need to go back to a previous month).
If you get stuck: On the gawk pages I found an mktime function that is implemented in awk, so it should work with the awk on
pdaXrom. I still didn't include it in the appointment applet but I think that is the way I would re-implement the tzadd:
#!/usr/bin/awk -f
BEGIN {
##
# initialization for the mktime function
##
# Initialize table of month lengths
_tm_months[0,1] = _tm_months[1,1] = 31
_tm_months[0,2] = 28; _tm_months[1,2] = 29
_tm_months[0,3] = _tm_months[1,3] = 31
_tm_months[0,4] = _tm_months[1,4] = 30
_tm_months[0,5] = _tm_months[1,5] = 31
_tm_months[0,6] = _tm_months[1,6] = 30
_tm_months[0,7] = _tm_months[1,7] = 31
_tm_months[0,8] = _tm_months[1,8] = 31
_tm_months[0,9] = _tm_months[1,9] = 30
_tm_months[0,10] = _tm_months[1,10] = 31
_tm_months[0,11] = _tm_months[1,11] = 30
_tm_months[0,12] = _tm_months[1,12] = 31
}
#########################################################
# the mktime function
#########################################################
function _tm_isleap(year, ret) {
ret = (year % 4 == 0 && year % 100 != 0) ||
(year % 400 == 0)
return ret
}
function _tm_addup(a, total, yearsecs, daysecs,
hoursecs, i, j) {
hoursecs = 60 * 60
daysecs = 24 * hoursecs
yearsecs = 365 * daysecs
total = (a[1] - 1970) * yearsecs
# extra day for leap years
for (i = 1970; i < a[1]; i++)
if (_tm_isleap(i))
total += daysecs
j = _tm_isleap(a[1])
for (i = 1; i < a[2]; i++)
total += _tm_months[j, i] * daysecs
total += (a[3] - 1) * daysecs
total += a[4] * hoursecs
total += a[5] * 60
total += a[6]
return total
}
function my_mktime(str, res1, res2, a, b, i, j, t, diff) {
i = split(str, a, " ") # don't rely on FS
if (i != 6)
return -1
# force numeric
for (j in a)
a[j] += 0
# validate
if (a[1] < 1970 ||
a[2] < 1 || a[2] > 12 ||
a[3] < 1 || a[3] > 31 ||
a[4] < 0 || a[4] > 23 ||
a[5] < 0 || a[5] > 59 ||
a[6] < 0 || a[6] > 61 )
return -1
res1 = _tm_addup(a)
t = strftime("%Y %m %d %H %M %S", res1)
if (_tm_debug)
printf("(%s) -> (%s)\n", str, t) > "/dev/stderr"
split(t, b, " ")
res2 = _tm_addup(b)
diff = res1 - res2
if (_tm_debug)
printf("diff = %d seconds\n", diff) > "/dev/stderr"
res1 += diff
return res1
}
{
printf("MyMkTime: %d\n", my_mktime("2005 08 07 10 54 18"));
printf("GawkMkTime: %d\n", mktime("2005 08 07 10 54 18"));
}
to test it you can make a file test_mktime.awk (chmod 755) and call
echo 1 | ./test_mktime.awk
with gawk installed.
I simply copied it from the page. The usage is
mktime("YYYY MM DD HH MM SS"),
and this information can be stripped from the DTSTART. Then you would need a translation of the alarm duration to
seconds and subtract the seconds from the result of mktime. After that you don't have to bother with leap years.
Christoph
-
Hi,
here is now a new version of the appointment applet. This time it uses the mktime function implemented
in awk. It should now work on all timezones and for (nearly) all daylight savings. Maybe there are problems with events around the day of daylight saving start/end.
Still no implementation of recurrent events.
And the events aren't sorted per time within a day.
In the fvwm part I made a mistake with the setting of awk variables. All variables are set by -v <variable name>=<value>.
I also exported more variables, making it easier to customize. Here is how it should look now:
DestroyFunc RecreateTodayMenu
AddToFunc RecreateTodayMenu
+ I DestroyMenu recreate TodayMenu
+ I ChangeMenuStyle today TodayMenu
+ I Piperead '$[HOME]/bin/appointment-applet.awk\
-v MENU_NAME=TodayMenu\
-v LANGUAGE=en\
-v DAYSAHEAD=10\
-v APPOINTMENT_ICON=/usr/lib/qt/lib/kdepim/korganizer/icons16/newevent.png\
-v TODO_ICON=/usr/lib/qt/lib/kdepim/korganizer/icons16/todo.png\
-v ALARM_ICON=/usr/lib/qt/lib/kdepim/korganizer/icons16/bell.png\
$[HOME]/kdepim/config/korganizerrc $[HOME]/kdepim/apps/korganizer/mycalendar.ics'
+ I Piperead '$[HOME]/bin/birthday-applet.awk\
-v MENU_NAME=TodayMenu\
-v LANGUAGE=en\
-v DAYSAHEAD=21\
$[HOME]/kdepim/apps/kabc/std.vcf'
+ I AddToMenu TodayMenu DynamicPopupAction RecreateTodayMenu
Style Today StaysOnTop
Colorset 30 fg black, bg white, hi white, sh black
MenuStyle today ItemFormat "%.5s%3i%5p%5.5l%.5r"
MenuStyle today MenuColorset 30
MenuStyle today SidePic /home/root/.fvwm/pixmaps/today-sidepicture.png
MenuStyle today SeparatorsShort, HilightBackOff, Hilight3DOff, ActiveForeOff, BorderWidth 0
MenuStyle today Foreground black, Background white
MenuStyle today Font "StringEncoding=UTF-8:xft:Arial:size=14:encoding=iso8859-1"
ChangeMenuStyle today TodayMenu
AddToMenu TodayMenu DynamicPopupAction RecreateTodayMenu
I assume that the kdepim files are installed in /usr/lib/qt/lib. If you have another encoding of the ics file
change the StringEncoding to your needs.
The scripts starts to become a bit slow. On my C860 it now needs 2-3 seconds to show.
If you like you may also add the sidepicture:
[ You are not allowed to view attachments ]
Christoph
-
I've got it working. Just building an ipk file (this is for next alarm event).
I used date to determine other dates, as it is locale and daylight savings aware.
ie
date --date "1/7/2005 11:36 utc 628 minutes ago"
Will return the time in local format minus 628 minutes
- Bundabrg
-
I've added a reply here (https://www.oesf.org/forums/index.php?showtopic=14032&st=15&p=91053entry91053) with the ipk details etc.
- Bundabrg
-
Is this still being developed or is it working with no bugs?
Thanks