Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: vdr-xine



On Montag 28 Juni 2004 20:57, Darren Salt wrote:
> Hmm... I'd find it useful for vdr's volume controls to be passed through to
> (g)xine (I've got gxine passing keypresses to vdr, but I'm not entirely happy
> with it yet).

For something similar, I wrote a patch which lets me do something like this
in keymacros.conf:

Volume+   @execute /usr/local/bin/vol 5%+
Volume-   @execute /usr/local/bin/vol 5%-
Mute      @execute amixer sset CD mute # was toggle

/usr/local/bin/vol is a script that either unmutes or changes the volume.

Patch attached. It does no more apply cleanly to 1.3.11, but still applies.

1. Macros can be defined for all keys, they override the normal key.
2. A macro can execute a system command


Notes:
1. this supposes there will never be a plugin called execute
2. my patch also modifies existing macros: it makes them repeat while
key pressed. I am not sure what is the wanted behaviour here. I 
certainly need it to be repeatable.

-- 
Wolfgang
diff -ur vdr-1.3.5/keys.c vdr-wr/keys.c
--- vdr-1.3.5/keys.c	2003-09-14 12:07:47.000000000 +0200
+++ vdr-wr/keys.c	2004-03-03 09:13:53.000000000 +0100
@@ -184,17 +184,34 @@
   for (int i = 0; i < MAXKEYSINMACRO; i++)
       macro[i] = kNone;
   plugin = NULL;
+  execute = NULL;
 }
 
 cKeyMacro::~cKeyMacro()
 {
   free(plugin);
+  free(execute);
 }
 
 bool cKeyMacro::Parse(char *s)
 {
   int n = 0;
   char *p;
+  {
+     char *cmd = s;
+     while (*cmd && strncmp(cmd,"@execute",8)) cmd++;
+     if (*cmd) {
+        cmd += 8;
+        execute=strdup(cmd);
+	p = strtok(s," \t");
+	if (p) {
+	   macro[0] = cKey::FromString(p);
+	   return(macro[0] != kNone);
+	   }
+	else
+	   return false;
+        }
+  }
   while ((p = strtok(s, " \t")) != NULL) {
         if (n < MAXKEYSINMACRO) {
            if (*p == '@') {
@@ -248,6 +265,7 @@
 
 const cKeyMacro *cKeyMacros::Get(eKeys Key)
 {
+  if (Key==kNone) return NULL;
   for (cKeyMacro *k = First(); k; k = Next(k)) {
       if (*k->Macro() == Key)
          return k;
diff -ur vdr-1.3.5/keys.h vdr-wr/keys.h
--- vdr-1.3.5/keys.h	2002-12-14 16:49:42.000000000 +0100
+++ vdr-wr/keys.h	2004-03-03 07:19:24.000000000 +0100
@@ -113,12 +113,14 @@
 private:
   eKeys macro[MAXKEYSINMACRO];
   char *plugin;
+  char *execute;
 public:
   cKeyMacro(void);
   ~cKeyMacro();
   bool Parse(char *s);
   const eKeys *Macro(void) const { return macro; }
   const char *Plugin(void) const { return plugin; }
+  const char *Execute(void) const { return execute; }
   };
 
 class cKeyMacros : public cConfig<cKeyMacro> {
diff -ur vdr-1.3.5/remote.c vdr-wr/remote.c
--- vdr-1.3.5/remote.c	2003-10-18 13:35:32.000000000 +0200
+++ vdr-wr/remote.c	2004-03-03 09:03:24.000000000 +0100
@@ -90,6 +90,10 @@
 {
   const cKeyMacro *km = KeyMacros.Get(Key);
   if (km) {
+     if (km->Execute()) {
+	system(km->Execute());
+	return true;
+        }
      plugin = km->Plugin();
      for (int i = 1; i < MAXKEYSINMACRO; i++) {
          if (km->Macro()[i] != kNone) {
diff -ur vdr-1.3.5/vdr.c vdr-wr/vdr.c
--- vdr-1.3.5/vdr.c	2004-02-29 15:21:22.000000000 +0100
+++ vdr-wr/vdr.c	2004-03-03 09:04:00.000000000 +0100
@@ -592,6 +592,11 @@
            LastActivity = time(NULL);
            }
         // Keys that must work independent of any interactive mode:
+	const cKeyMacro *km = KeyMacros.Get(NORMALKEY(key));
+	if (km) {
+		cRemote::PutMacro(NORMALKEY(key));
+		key=kNone;
+	}
         switch (key) {
           // Menu control:
           case kMenu:

Home | Main Index | Thread Index