Moode Forum
[How to do instruction] FLIRC-USB for remote control - Printable Version

+- Moode Forum (https://moodeaudio.org/forum)
+-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3)
+--- Forum: FAQ and Guides (https://moodeaudio.org/forum/forumdisplay.php?fid=9)
+--- Thread: [How to do instruction] FLIRC-USB for remote control (/showthread.php?tid=925)



FLIRC-USB for remote control - didier31 - 01-25-2019

I want to use an unique IR remote control for moode audio and for my Hifi equipments.
On an amplifier remote control, you have a lot of buttons not used, you can choice some of them to pilot moOde. For me I use only 8 buttons for functions "Play/pause" "previous" "next" "cover view" "decrease/incfrease sound" "shutdoaw" "F5 to refresh browser".

I describe here a simple solution with a RPI3, MoOde audio, lxde, and flirc/usb receiver. (**)
For a complete embarqued solution, you must add the official touchscreen 7" and xdotool.

Do not hesitate to comment or correct my remarks.


Solution summary
First of all, you must install the moode audio player on a micro SD card.
With lxde you can define keyboard shortcuts to execute MPD commands  (for example "mpc toggle"  for play/pause command)  (*)
With FLIRC receiver you can generate keyboard shortcut with your personnal IR remote control.
With xdotool (and touchscreen) you can generate mouse movements and clicks to simulate actions on the screen like "cover view" activation.
To improve, use lightdm and unclutter.

Tutorial details
(I suppose that you have already installed moOde audio on your RPi)
Use an ethernet or a Wifi connection, log into Raspbian with a ssh session. The username is pi and the password is moodeaudio.

First of all, you must extand the SD root partition.

Code:
df -k (to see the partitions size)
sudo raspi-config (--> advanced options --> expand root partition)
df -k (to see the new size)


To have the latest files and packages:

Code:
sudo apt-get update
sudo apt-get upgrade
(you would type "y" when asked "Do you want to continue?)

Install LXDE/OpenBox
Code:
sudo apt-get install --no-install-recommends lxde-core
sudo nano /home/pi/.xinitrc (and add the line "exec startlxde")
nano /home/pi/.config/lxsession/LXDE/autostart (and add the original .xinitrc)

Install XDOTOOL (to simulate  mouse's moves and cliks)
Code:
sudo apt-get install xdotool


Configure LXDE/OpenBox:
(with vi or nano)  modify the file ~/.config/openbox/lxde-rc.xml, for example insert these lines,
(just after lines:
<keyboard>
  <chainQuitKey>C-g</chainQuitKey> ) :

Code:
      <keybind key="A-u">    <!-- alt-u for next-->
         <action name="Execute">
            <command>mpc next</command>
         </action>
      </keybind>
      <keybind key="A-i">   <!-- alt-i for play/pause -->
         <action name="Execute">
            <command>mpc toggle</command>
         </action>
      </keybind>
      <keybind key="A-n">  <!-- alt-n for cover view -->
        <action name="Execute">
          <command>xdotool mousemove --sync 1180 20 sleep 1 click 1 sleep 1 mousemove 1020 460 sleep 1 click 1 sleep 1 mousemove 880 120 sleep 1 click 1</command>
        </action>
      </keybind>
      <keybind key="A-t">  <!-- alt-t for screen off -->
         <action name="Execute">
           <command>xset dpms force off</command>
         </action>
       </keybind>
After that, reboot your RPi and with a keyboard connected to the RPi USB port, you can test these shortcuts. If it's OK, you can configurate these shortcuts in the FLIRC receiver and synchronise it with your personnal remote control. (**)

Improvements

With these modifications some problems can appear:

1- to automatize the session login, you must install "lightdm" and configure the autologin.

Code:
sudo apt-get install lightdm

use "sudo raspi-config" -> Boot options -> Desktop / Cli and select "Desktop GUI autologin ")
(you can also insert line "autologin-user=pi" in file /etc/lightdm/lightdm.oonf)
and reboot

2-  delay of the boot of the RPi is very long. To optimize that, configure raspi_config to not wait the network


Code:
disable option "wait for natwork at boot"
use "sudo raspi-config" -> Boot options -> Wait for network at boot and select "No")
and reboot


3- with LXDE the "nocursor" option (configured by moOde) doesn't work. For that, you must install "unclutter"

Code:
sudo apt-get install unclutter

insert line "@unclutter -idle 0"  in file  /home/pi/.config/lxsession/LXDE/autostart
and reboot


(*) for the complete list of MPC options to control MPD, read this web page  https://linux.die.net/man/1/mpc  (or type "mpc help" on RPi)
(**) to configure FLIRC receiver, read the user guide https://flirc.gitbooks.io/flirc-instructions/content/title-page.html


I hope that my explanations are clear (sorry I'm french).
Any comments and corrections are welcome.


Didier


RE: FLIRC-USB for remote control - Edenmap1 - 05-20-2019

(01-25-2019, 08:56 PM)didier31 Wrote: I want to use an unique IR remote control for moode audio and for my Hifi equipments.
On an amplifier remote control, you have a lot of buttons not used, you can choice some of them to pilot moOde. For me I use only 8 buttons for functions "Play/pause" "previous" "next" "cover view" "decrease/incfrease sound" "shutdoaw" "F5 to refresh browser".

I describe here a simple solution with a RPI3, MoOde audio, lxde, and flirc/usb receiver. (**)
For a complete embarqued solution, you must add the official touchscreen 7" and xdotool.

Do not hesitate to comment or correct my remarks.


Solution summary
First of all, you must install the moode audio player on a micro SD card.
With lxde you can define keyboard shortcuts to execute MPD commands  (for example "mpc toggle"  for play/pause command)  (*)
With FLIRC receiver you can generate keyboard shortcut with your personnal IR remote control.
With xdotool (and touchscreen) you can generate mouse movements and clicks to simulate actions on the screen like "cover view" activation.
To improve, use lightdm and unclutter.

Tutorial details
(I suppose that you have already installed moOde audio on your RPi)
Use an ethernet or a Wifi connection, log into Raspbian with a ssh session. The username is pi and the password is moodeaudio.

First of all, you must extand the SD root partition.

Code:
df -k (to see the partitions size)
sudo raspi-config (--> advanced options --> expand root partition)
df -k (to see the new size)


To have the latest files and packages:

Code:
sudo apt-get update
sudo apt-get upgrade
(you would type "y" when asked "Do you want to continue?)

Install LXDE/OpenBox
Code:
sudo apt-get install --no-install-recommends lxde-core
nano /home/pi/.xinitrc (and add the line "exec startlxde")
nano /home/pi/.config/lxsession/LXDE/autostart (and add the original .xinitrc)

Configure LXDE/OpenBox:
(with vi or nano)  modify the file ~/.config/openbox/lxde-pi-rc.xml, for example insert these lines:

Code:
      <keybind key="A-u">    <!-- alt-u for next-->
         <action name="Execute">
            <command>mpc next</command>
         </action>
      </keybind>
      <keybind key="A-i">   <!-- alt-i for play/pause -->
         <action name="Execute">
            <command>mpc toggle</command>
         </action>
      </keybind>
      <keybind key="A-n">  <!-- alt-n for cover view -->
        <action name="Execute">
          <command>xdotool mousemove --sync 1180 20 sleep 1 click 1 sleep 1 mousemove 1020 460 sleep 1 click 1 sleep 1 mousemove 880 120 sleep 1 click 1</command>
        </action>
      </keybind>
      <keybind key="A-t">  <!-- alt-t for screen off -->
         <action name="Execute">
           <command>xset dpms force off</command>
         </action>
       </keybind>
After that, reboot your RPi and with a keyboard connected to the RPi USB port, you can test these shortcuts. If it's OK, you can configurate these shortcuts in the FLIRC receiver and synchronise it with your personnal remote control. (**)

Improvements

With these modifications some problems can appear:

1- to automatize the session login, you must install "lightdm" and configure the autologin.

Code:
sudo apt-get install ligthdm

use "sudo raspi-config" -> Boot options -> Desktop / Cli and select "Desktop GUI autologin ")
(you can also insert line "autologin-user=pi" in file /etc/lightdm/lightdm.oonf)
and reboot

2-  delay of the boot of the RPi is very long. To optimize that, configure raspi_config to not wait the network


Code:
disable option "wait for natwork at boot"
use "sudo raspi-config" -> Boot options -> Wait for network at boot and select "No")
and reboot


3- with LXDE the "nocursor" option (configured by moOde) doesn't work. For that, you must install "unclutter"

Code:
sudo apt-get install unclutter

insert line "@unclutter -idle 0"  in file  /home/pi/.config/lxsession/LXDE/autostart
and reboot


(*) for the complete list of MPC options to control MPD, read this web page  https://linux.die.net/man/1/mpc  (or type "mpc help" on RPi)
(**) to configure FLIRC receiver, read the user guide https://flirc.gitbooks.io/flirc-instructions/content/title-page.html


I hope that my explanations are clear (sorry I'm french).
Any comments and corrections are welcome.


Didier

Bonjour Didier,

I tried to follow your instructions but on Step 3 (Install LXDE/OpenBox), every time I try to add the line "exec startlxde" to file .xinitrc, I get "permission denied". The file seems to be locked. Do you know why this happens? I'm quite novice at all thesee keyboard commands so I can follow steps, but if an error occurs, I often do not know what to do... Your help would be "très appréciée". I am from Montreal (Quebec), so I too speak French and my English is not parfait... ;-)  Merci. JP



RE: FLIRC-USB for remote control - didier31 - 05-22-2019

Sorry Jean-Pierre,

the correct command is:  
Code:
sudo nano /home/pi/.xinitrc

because the owner of the file .xinitrc  is "root"

(I have corrected my tuto)

Didier


RE: FLIRC-USB for remote control - LaserGecko - 05-12-2020

Hi there,

What does "(and add the original .xinitrc)" in this step mean? I'm not fluent in Linux, but I can usually follow most instructions from tutorials.

Code:
nano /home/pi/.config/lxsession/LXDE/autostart (and add the original .xinitrc)

Has the OS included in the img changed since 2019? All of my directories are similar to /etc/xdg/lxsession/LXDE/autostart and all of the above paths show up as "no such directory".

Also, get the drivers for Raspberry Pi systems from the links here. Trying to install from the Flirc user guide was incredibly frustrating.

https://flirc.tv/support/flirc-usb