how do I execute a script every time the channel is changed?

  • Hi,


    Is there any way that I can execute a script automatically every time the channel is changed on either the DM500 or DM800?


    I can think of many uses for this but the main one at the moment is to tell my other sat dreambox (which is hooked up to a motor) to move the satellite if needed. I already have a script that I can execute manually from the Niablo scripts menu (on DM800) to move to another satellite but hoping that there is a clever way to automate this.


    Cheers.

  • by remember previous service reference and compare with current one you can chose do something or sleep some seconds


    example /usr/script/Collect_SIDs.sh
    (chmod 755)

  • thanks for the suggestion... very detailed :)


    I did think about a script running in the background and checking old/new channel etc but just wondered if there was something that fires in the background whenever a channel changes. That's why I have a manual script at the moment. Obviously for the motorised setup, enigma must call something to move the satellite and I was holding out for hope that I could modify one of the files to call an additional script ?(


    For your script below, I can see that you are basically getting the channel info etc from getcurrent, however what command would I need to call to get the satellite? For example, if the current channel is on 13e, then I would like to change the channel on my other dreambox to BBC World (i.e. not just changing to the same channel that I've selected on my DM800). The manual script I have at the moment just changes to the channel to match that of my DM800.

  • In ChannelSelection.py - there is a zap function. You can run a script from there. But - depending on the script - this may slow down your zapping between channels.



    Cheers, pcd.

  • In ChannelSelection.py - there is a zap function. You can run a script from there. But - depending on the script - this may slow down your zapping between channels.




    Cheers, pcd.

    All I want to do is check if the satellite has changed. If it has then make a call to my other dreambox (through web) to change to a channel on that satellite. So hopefully there isn't any real delay to changing to channels on the same satellite as its just making a quick check to see what satellite is selected.


    I opened up ChannelSelection.py and had a look. Seems interesting... is it correct that if I replace ChannelSelection.py with a modified version and reboot my box, the new pyc file will automatically be created? Is it as simple as this to get this to work???

    Edited 2 times, last by hotbaws11 ().

  • you have to restart enigma2 on your box after you made changes to *.py files. E2 will compile them to *.pyo files then on restart

    Theorie ist, wenn man alles weiß, aber nichts funktioniert.
    Praxis ist, wenn alles funktioniert aber niemand weiß warum.

  • you have to restart enigma2 on your box after you made changes to *.py files. E2 will compile them to *.pyo files then on restart

    is there any way to compile the modified py file without restarting? I think I read I could create a new py file that has an import statement for the modified file (i.e. import ChannelSelection.py) and by executing the new py file, python would compile ChannelSelection.py as part of that.


    Any idea if this will cause any issues as I've prefer not to restart my box at the moment.


    btw thanks for all the help so far...

  • just an update to say that I tried the above without restarting the box and I managed to create the pyc file. I modified the zap function to write a temp file (just a test) but it didn't seem to work. Note sure what I did wrong... possibly I need to restart the box before it takes effect?????


    any additional pointers would be appreciated.

  • No need to restart the box. Just restart enigma2 (also known as Restart Gui). This is necessary for the program to recognize changes to enigma2 (the new .py file patch - in this case).

  • I'm very confused about the ChannelSelection.py script ?( ?( ?(


    I've updated the zap function to the following so that it writes a text file in temp every time its called. However nothing happens when I change channel though. I've restarted enigma and the box but no difference. What am I doing wrong here... help ;(



    note the function is properly indented however its not showing it above.

  • I tested just now - and it worked.



    How did you restart enigma2 ?


    BTW press # to insert coding in the post.


    Cheers, pcd.

  • finally got it working... no idea what I did wrong but just checked there and testzap file has been created :)


    Any idea what phython/web command I can use to identify which satellite the new channel is on (i.e. 28E, 13E etc). Otherwise I'd be changing the channel on my other box every time I change the channel on the DM800???


    Also, does anyone know if there is a similar function on the DM500 that tracks channel changes so that I can customise this on my DM500 as well?


    cheers for the help so far :thumbup:

    Edited once, last by hotbaws11 ().

  • Hi, is there a solution to get it working on a dm500 (openpli) --> enigma1 too ?
    On enigma1 I cant find any pithon files.


    I would like that:
    A receiver (DM500).
    B receiver (DM500).


    If I switch channel on Receiver B, also the same changel change on Receiver A. Master-Slave like.
    I am good and scripting and so on...but i dont know only one thin:
    how can i run a "script" on channel zap (channel change).
    Can you please guys help me please ?

  • Hi,

    Also, does anyone know if there is a similar function on the DM500 that tracks channel changes so that I can customise this on my DM500 as well?

    Did you find a similar solution for dm500 function ?


    I would like to get help to do this:



    I need a plugin which can run 1, only one bash script in the background. I try to write it 2 times, but not succeess.
    1st time: made a sample.sh and sample.cfg and put them into /var/tuxbox/plugins...Strange thing: I can see it in the "plugins". If I chosse the plugins menu and choose the sample program, then it does not go to background or close that windows, but the script will run in the window.
    2nd attempt: try to write a c++ program. I googled it how can i compile and run a script for dm500. Here coces the tricky part. I cant compile...after that I can compile, but if I want to run it, then it asked that it is not a dynamical...and after that it say that it is missing the pluginexec variable.



    Here is what I would like:
    I would like to bind a program what I can run on keypress and run in the background.
    Can you please help me how to write or can you write a plugin what i can copy to /var/tuxbox/plugins dir (channel-changer.so and channel-changer.cfg) run a bash script and this plugin runs that in the background. So if I have bind that plugin to a yellow keypress, then nothing show up, just the program has been run.


    I would even pay for the solution. :-)

  • you may try getrc by SnowHead, he put all his plugins under GPL
    http://www.dbox2-tuning.net/forum/viewtopic.php?f=27&t=49098
    it is written for dbox2, will also run on other ppc boxes like older dreams (DM500, DM7000, DM7020..), each time you press a key on your remote control getrc will return a hex code of that key, the hint, you compare the return key with your pressed key, if true then .....{ apply your script } ...., the problem might be different hex codes of dm500 RC and dbox2 RC, even other ppc dreams have other return codes, you may run getrc on Telnet and watch what codes it returns when you press channel up/down key, if it returns nothing, you´ll have to recompile getrc for DM500, i added the getrc archive with ppc binary


    mrvica

    Files

    • getrc_0.01.rar

      (3.99 kB, downloaded 162 times, last: )
  • Hi,


    First of all thanks the effort.
    Unfortunatelly it is not working, I have run the getrc, pushing the buttons, but no luck.
    I know, it will be a lame question, but how can I recompile it to a DM500 ?
    I have downloaded "Toolchain_powerpc-tuxbox-linux_dm500.tar.bz2" extract it, and I have copy the source code, but it dont want to compile.
    Can you please help me ?

    you may try getrc by SnowHead, he put all his plugins under GPL
    http://www.dbox2-tuning.net/forum/viewtopic.php?f=27&t=49098
    it is written for dbox2, will also run on other ppc boxes like older dreams (DM500, DM7000, DM7020..), each time you press a key on your remote control getrc will return a hex code of that key, the hint, you compare the return key with your pressed key, if true then .....{ apply your script } ...., the problem might be different hex codes of dm500 RC and dbox2 RC, even other ppc dreams have other return codes, you may run getrc on Telnet and watch what codes it returns when you press channel up/down key, if it returns nothing, you´ll have to recompile getrc for DM500, i added the getrc archive with ppc binary


    mrvica

  • recompiling wan´t do the Job I think , you´ll have to adapt the code for DM500, getrc starts but returns no codes, on dbox2 all OK, I wrote an example script to see it in action, getrc must be in path


    instead of echo commands you could put here your own commands
    just have a look at this thread too, someone asked similiar question
    Dreambox via Script steuern


    mrvica

  • I'm very confused about the ChannelSelection.py script ?( ?( ?(


    I've updated the zap function to the following so that it writes a text file in temp every time its called. However nothing happens when I change channel though. I've restarted enigma and the box but no difference. What am I doing wrong here... help ;(



    note the function is properly indented however its not showing it above.

    Hi,


    I cant see this code section in the ChannelSelection.py, where should i find this ?