[mythtv] [PATCH] MythTV LIRC KeyPress Spawn External App
Dan Morphis
dan at milkcarton.com
Sat Mar 27 18:07:46 EST 2004
Now only one db hit is experienced.
-dan
Dan Morphis wrote:
> Heh, I can certainly do that. But, as to the performance, my mysql
> host runs on a different, much slower box, and I don't have any
> issues. I will certainly make the change though.
>
> -dan
>
> Isaac Richards wrote:
>
>> On Saturday 27 March 2004 02:05 pm, Dan Morphis wrote:
>>
>>
>>> I saw a bunch of commits this morning, but I didn't see this one go
>>> through. Don't know if it fell off the radar or what not. Let me
>>> know.
>>>
>>
>>
>> Sorry, missed it when I was going through things last night. If you
>> want this applied, though, you'll need to get rid of the GetSetting
>> call every keypress. That's a database hit every time a key's
>> pressed, and wouldn't be all that nice for people with mysql host !=
>> frontend host. =)
>>
>> Isaac
>> _______________________________________________
>> mythtv-dev mailing list
>> mythtv-dev at mythtv.org
>> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev
>>
>>
> _______________________________________________
> mythtv-dev mailing list
> mythtv-dev at mythtv.org
> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev
-------------- next part --------------
#!/bin/sh
REMOTE_NAME=GI #DVD-Panasonic-0490
KEY=EXIT
irsend SEND_ONCE $REMOTE_NAME $KEY
-------------- next part --------------
Index: libs/libmyth/lirc.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/lirc.cpp,v
retrieving revision 1.6
diff -u -d -r1.6 lirc.cpp
--- libs/libmyth/lirc.cpp 25 Jan 2004 08:27:42 -0000 1.6
+++ libs/libmyth/lirc.cpp 27 Mar 2004 23:02:44 -0000
@@ -3,6 +3,9 @@
#include <qkeysequence.h>
#include <cstdio>
#include <cerrno>
+#include "mythcontext.h"
+
+#include <sys/wait.h>
#include <iostream>
using namespace std;
@@ -40,6 +43,8 @@
lirc_deinit();
return -1;
}
+
+ external_app = gContext->GetSetting("LircKeyPressedApp") + " &";
return 0;
}
@@ -83,6 +88,38 @@
QApplication::postEvent(mainWindow, new LircKeycodeEvent(code,
keycode, false));
}
+
+ //Spawn app to thwap led (or what ever the user has picked if
+ // anything) to give positive feedback that a key was received
+ if(external_app != " &")
+ {
+ pid_t child = fork();
+ if (child < 0)
+ {
+ perror("fork");
+ }
+ else if (child == 0)
+ {
+ for(int i = 3; i < sysconf(_SC_OPEN_MAX) - 1; ++i)
+ close(i);
+ execl("/bin/sh", "sh", "-c", external_app.ascii(), NULL);
+ perror("exec");
+ _exit(1);
+ }
+ else
+ {
+ int status;
+ if (waitpid(child, &status, 0) < 0)
+ {
+ perror("waitpid");
+ }
+ else if (status != 0)
+ {
+ cerr << "External key pressed command exited with status "
+ << status << endl;
+ }
+ }
+ }
}
free(ir);
Index: libs/libmyth/lirc.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/lirc.h,v
retrieving revision 1.1
diff -u -d -r1.1 lirc.h
--- libs/libmyth/lirc.h 4 Aug 2003 22:09:43 -0000 1.1
+++ libs/libmyth/lirc.h 27 Mar 2004 23:02:44 -0000
@@ -21,6 +21,7 @@
struct lirc_config *lircConfig;
QObject *mainWindow;
pthread_t pth;
+ QString external_app;
};
#endif
Index: programs/mythfrontend/globalsettings.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/globalsettings.cpp,v
retrieving revision 1.147
diff -u -d -r1.147 globalsettings.cpp
--- programs/mythfrontend/globalsettings.cpp 14 Mar 2004 07:35:33 -0000 1.147
+++ programs/mythfrontend/globalsettings.cpp 27 Mar 2004 23:02:45 -0000
@@ -958,6 +958,17 @@
};
};
+class LircKeyPressedApp: public LineEditSetting, public GlobalSetting {
+public:
+ LircKeyPressedApp():
+ GlobalSetting("LircKeyPressedApp") {
+ setLabel(QObject::tr("Keypress Application"));
+ setValue("halt");
+ setHelpText(QObject::tr("External application or script to run when "
+ "a keypress is received by lirc"));
+ };
+};
+
class SetupPinCode: public LineEditSetting, public GlobalSetting {
public:
SetupPinCode():
@@ -1937,6 +1948,7 @@
general->addChild(new AllowQuitShutdown());
general->addChild(new NoPromptOnExit());
general->addChild(new HaltCommand());
+ general->addChild(new LircKeyPressedApp());
general->addChild(new SetupPinCodeRequired());
general->addChild(new SetupPinCode());
general->addChild(new EnableMediaMon());
More information about the mythtv-dev
mailing list