LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices

Reply
 
Search this Thread
Old 08-29-2006, 07:19 PM   #1
mattsn
LQ Newbie
 
Registered: Jun 2006
Posts: 1

Rep: Reputation: 0
korganizer(3.5) alarm/reminder script argument problem


Hi all,

I'm using KDE 3.5.2, and korganizer 3.5, and have a simple problem.
In the advanced alarm configuration section for events and todos, there is a textbox where you can pass arguments to the script that the alarm will run. However, nothing entered in this textbox actually makes it to the script as an argument. I ran a sample bash script which indicates an argument list length of zero, no matter how many arguments were placed in this textbox, quoted or not.

Hope someone can help!
=)
Matt
 
Old 12-05-2006, 10:35 PM   #2
mpdavig
Member
 
Registered: May 2004
Location: Boston, MA
Distribution: Fedora
Posts: 30

Rep: Reputation: 19
Not implemented yet, patch included

This is not unlike the grayed out Email Reminder Type, the Program file: value is used however the Program arguments: value is ignored. The following patch adds support for this field and any number of arguments. It also allows you to use substitution characters as arguments as well:

%c - Categories
%d - Description
%D - Start date
%e - End date
%l - Location
%o - Organizer
%s - Summary

This patch is not mine, I just adapted it for korganizer 3.5.5, should work for all 3.5.x's though.

http://lists.kde.org/?l=kde-pim&m=112006762610911&w=2

--- begin patch text ---
Code:
diff -Naur kdepim-3.5.5/korganizer/korgac/alarmdialog.cpp kdepim-3.5.5.arg/korganizer/korgac/alarmdialog.cpp
--- kdepim-3.5.5/korganizer/korgac/alarmdialog.cpp    2005-09-10 04:24:44.000000000 -0400
+++ kdepim-3.5.5.arg/korganizer/korgac/alarmdialog.cpp    2006-12-05 16:45:39.000000000 -0500
@@ -38,11 +38,13 @@
 #include <kprocess.h>
 #include <kaudioplayer.h>
 #include <kdebug.h>
+#include <kmacroexpander.h>
 #include <kmessagebox.h>
 #include <knotifyclient.h>
 #include <kcombobox.h>
 #include <kwin.h>
 #include <klockfile.h>
+#include <kshell.h>
 
 #include <libkcal/event.h>
 
@@ -196,12 +198,54 @@
   Alarm::List::ConstIterator it;
   for ( it = alarms.begin(); it != alarms.end(); ++it ) {
     Alarm *alarm = *it;
+
+    // MPD 12/05/2006: Add Argument support for Alarm::Procedure
 // FIXME: Check whether this should be done for all multiple alarms
-    if (alarm->type() == Alarm::Procedure) {
+    if (alarm->type() == Alarm::Procedure && !alarm->programFile().isEmpty() ) {
 // FIXME: Add a message box asking whether the procedure should really be executed
-      kdDebug(5890) << "Starting program: '" << alarm->programFile() << "'" << endl;
       KProcess proc;
+      QString expanded;
       proc << QFile::encodeName(alarm->programFile());
+      kdDebug(5890) << "Program name: '" << alarm->programFile() << "'" << endl;
+      kdDebug(5890) << "Arguments: '" << alarm->programArguments() << "'" << endl;
+      //
+      // Arguments
+      if (!alarm->programArguments().isEmpty() ) {
+        QMap<QChar,QString> subst;
+        subst.insert( 'c', mIncidence->categoriesStr() );
+        subst.insert( 'd', mIncidence->description() );
+        subst.insert( 'D', mIncidence->dtStart().toString());
+        subst.insert( 'e', mIncidence->dtEnd().toString() );
+        subst.insert( 'l', mIncidence->location() );
+        subst.insert( 'o', mIncidence->organizer().fullName() );
+        subst.insert( 's', mIncidence->summary() );
+
+        //If the procedure failures on reading, no procedure is invoked 
+        //(RFC2445 p.71)
+        expanded = KMacroExpander::expandMacrosShellQuote( 
+            alarm->programArguments(), subst );
+
+        if ( expanded.isEmpty() ) {
+          kdDebug( 5890 ) << "error on expanding arguments: " << expanded << endl;
+          continue; //continue with the next alarms
+        }
+
+        kdDebug( 5890 ) << "Arguments expanded: " << expanded << endl;
+
+        int err;
+        proc << KShell::splitArgs( expanded, KShell::NoOptions, &err );
+
+        if ( err ) {
+          kdDebug( 5890 ) << "error on spliting arguments: " << expanded << endl;
+          continue; //continue with the next alarms
+        }
+
+      }
+
+      kdDebug(5890) << "Starting program: '" << alarm->programFile() 
+        << " " << expanded << "'" << endl;
+      // MPD 12/05/2006: End of Argument support changes
+
       proc.start(KProcess::DontCare);
     }
     else if (alarm->type() == Alarm::Audio) {
--- endof patch text ---
 
  


Reply

Tags
alarm, alert, korganizer, reminder, script


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script 'for each command line argument' true_atlantis Linux - Newbie 3 01-28-2009 01:51 PM
a script to give me the last argument !!! rameshvl Linux - General 18 12-29-2008 01:02 PM
KOrganizer Alarm Daemon wooot Linux - Software 1 04-19-2005 12:55 AM
PHP pass argument to shell script monzter Programming 2 08-14-2004 06:16 AM
PHP Script argument passing error... lokee Linux - Software 5 04-24-2003 09:42 AM


All times are GMT -5. The time now is 02:53 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration