{{tag>tutoriel matériel media_center télécommande multimédia}} ---- ====== Création de fichiers lircrc ====== Cette page montre comment créer des fichiers de configuration lircrc pour [[:LIRC]]. La syntaxe des fichiers montrée ici est la plus simple possible (un bouton pour une action). Pour approfondir le sujet, on pourra se reporter au [[https://www.lirc.org/html/configure.html|site officiel]] (en anglais) du projet LIRC (à la partie « //The .lircrc file format// »). ===== Utilité des fichiers lircrc ===== Les fichiers lircrc permettent de faire la liaison entre les boutons de la télécommande sur lesquelles on appuie et les actions dans les programmes. Ils sont donc indispensables pour utiliser une télécommande dans une application particulière. Le fichier principal est ''~/.lircrc''. Pour les applications, on écrit généralement un fichier que l'on met dans le répertoire de configuration dans le dossier personnel. Par exemple, pour MythTV, c'est le fichier ''~/.mythtv/lircrc''. On peut lier le fichier principal aux fichiers des applications comme décrit dans le paragraphe [[#Manuellement]]. ===== Création des fichiers lircrc ===== Il existe plusieurs façons de créer des fichiers lircrc. La plus simple est d'utiliser un script (paquet [[apt://mythbuntu-lirc-generator]]) écrit pour la distribution [[:Mythbuntu]] se trouvant dans le dépôt universe, ce qui est le plus plus simple. On peut aussi créer les fichiers manuellement, ce qui est fastidieux. Il existe aussi des utilitaires pour LIRC pour le bureau [[:KDE]]. ==== Avec mythbuntu-lirc-generator ==== Ce script permet de créer les fichiers lircrc pour six applications : [[:MythTV]], [[:Xine]], [[:MPlayer]], [[:VLC]], [[:Totem]] et Elisa (aujourd'hui [[http://www.moovida.com/|Moovida]]). Il crée les fichiers lircrc pour les six applications et met un lien vers chacun d'eux dans le fichier ~/.lircrc. Avant de l'utiliser, il faut avoir un fichier lircd.conf configuré pour la télécommande que l'on veut utiliser dans le répertoire /etc/lirc/. Il faut [[:tutoriel:comment_installer_un_paquet|installer le paquet]] [[apt://mythbuntu-lirc-generator|mythbuntu-lirc-generator]], si ce n'est déjà fait, pour pouvoir utiliser le script. Le script s'utilise avec la commande suivante : mythbuntu-lircrc-generator ==== Manuellement ==== La syntaxe pour les fichiers lircrc est très simple quand on veut simplement associer une action à un bouton. Il faut commencer son fichier par begin PROGRAMME et le terminer par end PROGRAMME en remplaçant ''PROGRAMME'' par le nom du programme voulu. Pour le bureau, il faut remplacer ''PROGRAMME'' par ''desktop''. Entre les lignes évoquées dans le paragraphe précédent, il faut utiliser le motif suivant pour chaque bouton : begin prog = PROGRAMME button = BOUTON config = ACTION end ''PROGRAMME'' désigne le programme qui va utiliser le bouton. On utilisera, par exemple, mythtv pour MythTV. ''BOUTON'' désigne le nom du bouton qui se trouve dans le fichier ''/etc/lirc/lircd.conf''. Enfin, ''ACTION'' correspond à l'action qui sera lancée. En utilisant irexec en remplacement de ''PROGRAMME'', on peut déclencher une action quelconque comme lancer un programme. Cela nécessite de lancer le démon de irexec avec la commande suivante : irexec -d À titre d'exemple, on pourra regarder deux fichiers lircrc [[http://lucdidry.free.fr/blog/public/lircrc.desktop|pour le bureau]]FIXME et [[http://lucdidry.free.fr/blog/public/lircrc.mplayer|pour MPlayer]].FIXME Depuis le fichier principal (''~/.lircrc''), il peut être utile de faire des liaisons vers des fichiers lircrc pour des applications spécifiques. Par exemple, pour le fichier lircrc de MythTV (''~/.mythtv/lircrc''), il faut ajouter la ligne include ~/.mythtv/lircrc ==== Avec un utilitaire pour le bureau KDE ==== Cet utilitaire permet de créer des fichiers de configuration pour des applications de KDE. Pour installer cet utilitaire, il faut [[:tutoriel:comment_installer_un_paquet|installer les paquets]] [[apt://lirc-x|lirc-x]] et [[apt://kdelirc|kdelirc]] (( Le paquet ''kdelirc'' n'est pas disponible dans les dépôts de Jaunty 9.04 )) : sudo apt-get install lirc-x kdelirc Pour le lancer, il faut utiliser l'entrée « IRKick » du menu « Utilitaires » ou bien par la commande suivante : irkick ===== Exemples de fichiers lircrc pour les principales applications multimédia ===== ==== VLC ==== Option de contrôle par LIRC désactivée par défaut. Pour l'activer : vlc → Settings → Interface → Control Interfaces et cocher Infrared remote control interface ## VLC ## begin prog = vlc button = play config = key-play repeat=32 end begin prog = vlc button = pause config = key-play-pause end begin prog = vlc button = stop config = key-stop end begin prog = vlc button = power config = key-quit repeat=1 end begin prog = vlc button = chan-up config = key-next end begin prog = vlc button = chan-down config = key-prev end begin prog = vlc button = max_window config = key-toggle-fullscreen end begin prog = vlc button = rewind config = key-slower end begin prog = vlc button = forward config = key-faster end #Audio controls begin prog = vlc button = vol-down config = key-vol-down repeat=0 end begin prog = vlc button = vol-up config = key-vol-up repeat=0 end begin prog = vlc button = mute config = key-vol-mute end #For dvd navigation begin prog = vlc button = 4 config = key-nav-left end begin prog = vlc button = 8 config = key-nav-down end begin prog = vlc button = 2 config = key-nav-up end begin prog = vlc button = 6 config = key-nav-right end begin prog = vlc button = 5 config = key-nav-activate end begin prog = vlc button = source config = key-disc-menu end Pour avoir la liste complète des fonctions que peut utiliser une télécommande avec VLC, lancer la commande suivante : vlc -H --advanced 2>&1 |sed -n '/--key/ {s/^\ *--//; s/^\(.*\) <[^>]*>\ *\(.*\)$/\2 -> \1/; h}; /^.*[^ ].*-> key/ p; /^ -> key/ { n; s/^[ \t\n]*//M; G; s/\n//; p}' ==== Totem ==== ## Totem ## begin totem begin prog = Totem button = power config = quit end begin prog = Totem button = play config = play end begin prog = Totem button = pause repeat = 0 config = pause end begin prog = Totem button = stop config = pause repeat = 0 end begin prog = Totem button = chan-up config = next repeat = 1 end begin prog = Totem button = chan-down config = previous repeat = 1 end begin prog = Totem button = forward config = seek_forward repeat = 1 end begin prog = Totem button = rewind config = seek_backward repeat = 1 end begin prog = Totem button = vol-up config = volume_up repeat = 1 end begin prog = Totem button = vol-down config = volume_down repeat = 1 end begin prog = Totem button = max-window config = fullscreen repeat = 1 end end totem ==== TVTime ==== ## TVTIME ## begin prog = irexec button = POWER config = tvtime-command QUIT end begin prog = irexec button = E config = tvtime-command TOGGLE_INPUT end begin prog = irexec button = launch_setup config = tvtime-command DISPLAY_INFO end begin prog = irexec button = MAXIMIZE config = tvtime-command TOGGLE_FULLSCREEN end begin prog = irexec button = MUTE config = tvtime-command TOGGLE_MUTE end begin prog = irexec button = UP config = tvtime-command UP end begin prog = irexec button = DOWN config = tvtime-command DOWN end begin prog = irexec button = RIGHT config = tvtime-command RIGHT end begin prog = irexec button = LEFT config = tvtime-command LEFT end begin prog = irexec button = vol-up config = tvtime-command MIXER_UP repeat = 1 end begin prog = irexec button = vol-down config = tvtime-command MIXER_DOWN repeat = 1 end begin prog = irexec button = chan-up config = tvtime-command CHANNEL_UP end begin prog = irexec button = chan-down config = tvtime-command CHANNEL_DOWN end begin prog = irexec button = dvd-root_menu config = tvtime-command CHANNEL_JUMP end begin prog = irexec button = 1 config = tvtime-command CHANNEL_1 end begin prog = irexec button = 2 config = tvtime-command CHANNEL_2 end begin prog = irexec button = 3 config = tvtime-command CHANNEL_3 end begin prog = irexec button = 4 config = tvtime-command CHANNEL_4 end begin prog = irexec button = 5 config = tvtime-command CHANNEL_5 end begin prog = irexec button = 6 config = tvtime-command CHANNEL_6 end begin prog = irexec button = 7 config = tvtime-command CHANNEL_7 end begin prog = irexec button = 8 config = tvtime-command CHANNEL_8 end begin prog = irexec button = 9 config = tvtime-command CHANNEL_9 end begin prog = irexec button = 0 config = tvtime-command CHANNEL_0 end begin prog = irexec button = OK config = tvtime-command ENTER end ==== Kaffeine ==== ## KAFFEINE ## begin prog = irexec button = play config = dcop kaffeine KaffeineIface playDvb end begin prog = irexec button = pause config = dcop kaffeine KaffeineIface pause end begin prog = irexec button = ok config = dcop kaffeine KaffeineIface dvbOSD end begin prog = irexec button = stop config = dcop kaffeine KaffeineIface stop end begin prog = irexec button = forward config = dcop kaffeine KaffeineIface posPlus end begin prog = irexec button = rewind config = dcop kaffeine KaffeineIface posMinus end begin prog = irexec button = chan-up config = dcop kaffeine KaffeineIface next end begin prog = irexec button = chan-down config = dcop kaffeine KaffeineIface previous end begin prog = irexec button = power config = dcop kaffeine KaffeineIface quit end begin prog = irexec button = vol-up config = dcop kaffeine KaffeineIface volUp end begin prog = irexec button = mute config = dcop kaffeine KaffeineIface mute end begin prog = irexec button = vol-down config = dcop kaffeine KaffeineIface volDown end begin prog = irexec button = max_window config = dcop kaffeine KaffeineIface fullscreen end begin prog = irexec button = up config = dcop kaffeine KaffeineIface zoomIn end begin prog = irexec button = down config = dcop kaffeine KaffeineIface zoomOut end begin prog = irexec button = 1 config = dcop kaffeine KaffeineIface setNumber 1 repeat = 0 end begin prog = irexec button = 2 config = dcop kaffeine KaffeineIface setNumber 2 repeat = 0 end begin prog = irexec button = 3 config = dcop kaffeine KaffeineIface setNumber 3 repeat = 0 end begin prog = irexec button = 4 config = dcop kaffeine KaffeineIface setNumber 4 repeat = 0 end begin prog = irexec button = 5 config = dcop kaffeine KaffeineIface setNumber 5 repeat = 0 end begin prog = irexec button = 6 config = dcop kaffeine KaffeineIface setNumber 6 repeat = 0 end begin prog = irexec button = 7 config = dcop kaffeine KaffeineIface setNumber 7 repeat = 0 end begin prog = irexec button = 8 config = dcop kaffeine KaffeineIface setNumber 8 repeat = 0 end begin prog = irexec button = 9 config = dcop kaffeine KaffeineIface setNumber 9 repeat = 0 end begin prog = irexec button = 0 config = dcop kaffeine KaffeineIface setNumber 0 repeat = 0 end ==== Amarok ==== #amarok begin prog = irexec button = menu config = amarok end begin prog = irexec button = power config = dcop amarok MainApplication-Interface quit end begin prog = irexec button = play config = dcop amarok player play end begin prog = irexec button = forward config = dcop amarok player seekRelative 10 end begin prog = irexec button = rewind config = dcop amarok player seekRelative -5 end begin prog = irexec button = pause config = dcop amarok player pause end begin prog = irexec button = stop config = dcop amarok player stop end begin prog = irexec button = next config = dcop amarok player next end begin prog = irexec button = last config = dcop amarok player prev end begin prog = irexec button = chup config = dcop amarok player next end begin prog = irexec button = chdown config = dcop amarok player prev end begin prog = irexec button = volup config = dcop amarok player volumeUp end begin prog = irexec button = mute config = dcop amarok player mute end begin prog = irexec button = voldown config = dcop amarok player volumeDown end begin prog = irexec button = epg config = dcop amarok playlist togglePlaylist end begin prog = irexec button = chrtn config = toggleRandomAmarok end begin prog = irexec button = max_window config = dcop amarok player showOSD end ==== MPlayer ==== # Mplayer begin button = vol-up prog = mplayer config = volume 10 repeat = 5 end begin button = vol-down prog = mplayer config = volume -10 repeat = 5 end begin button = mute prog = mplayer config = mute end begin button = pause prog = mplayer config = pause end begin button = play prog = mplayer config = pause end begin button = stop prog = mplayer config = seek 0 1\npause end begin button = power prog = mplayer config = quit end begin button = max_window prog = mplayer config = vo_fullscreen end begin button = record prog = mplayer config = osd end begin button = forward prog = mplayer config = seek 5 end begin button = rewind prog = mplayer config = seek -5 end begin button = right prog = mplayer config = seek 60 end begin button = left prog = mplayer config = seek -60 end begin button = up prog = mplayer config = seek 600 end begin button = down prog = mplayer config = seek -600 end begin button = chan-up prog = mplayer config = pt_step 1 end begin button = chan-down prog = mplayer config = pt_step -1 end ==== Elisa ==== À mettre dans ''~/.elisa/lircrc''. Il faut également modifier le fichier ''~/.elisa/elisa.conf'' en remplaçant ''lirc_rc'' par ''lircrc''. # Elisa begin prog = elisa button = power config = close_key end begin prog = elisa button = up config = move_up_key repeat = 1 end begin prog = elisa button = down config = move_down_key repeat = 1 end begin prog = elisa button = left config = move_left_key repeat = 1 end begin prog = elisa button = right config = move_right_key repeat = 1 end begin prog = elisa button = ok config = activate_key end begin prog = elisa button = tv_on_demand config = toggle_menu_key end begin prog = elisa button = play config = toggle_play_pause_key end begin prog = elisa button = PAUSE config = pause_key end begin prog = elisa button = stop config = stop_key end begin prog = elisa button = forward config = increment_playback_speed_key repeat = 1 end begin prog = elisa button = rewind config = decrement_playback_speed_key repeat = 1 end begin prog = elisa button = f config = seek_forward_key end begin prog = elisa button = e config = seek_backward_key end begin prog = elisa button = max_window config = toggle_fullscreen_key end begin prog = elisa button = mute config = toggle_mute_key end begin prog = elisa button = vol-up config = increment_volume_key repeat = 1 end begin prog = elisa button = vol-down config = decrement_volume_key repeat = 1 end ==== Script externe ==== #Ce fichier est censé permettre de lancer des scriptes externes : ici, des scripts placés dans un dossier « .compiz » dans « ~/.lirc  » #et qui permettent de faire tourner le cube de bureau compiz grâce à wmctrl. Les scripts contiennent un script formé dans cette syntaxe : #wmctrl -o 0,0 (pour le premier bureau) #wmctrl -o largeur_de_l_ecran_en_pixel,0 #wmctrl -o deux_fois_la_largeur_de_lecran_en_pixels,0 #etc... begin prog = irexec button = One config = /usr/bin/1.sh & end begin prog = irexec button = Two config = /usr/bin/2.sh & end begin prog = irexec button = Three config = /usr/bin/3.sh & end begin prog = irexec button = Four config = /usr/bin/4.sh & end Vous devez ensuite ajouter ''irexec'' dans vos applications au démarrage. Sinon, les scripts ne se lanceront pas. Veillez aussi à vérifier les permissions des fichiers appelés par ce fichier de configuration. Ils doivent êtres exécutables et appartenir à l'utilisateur et au groupe de l'utilisateur. Sinon, rien ne se passera non plus. Il est conseillé de mettre les scipts appelés dans ''/usr/bin'' (c'est là que les exécutables se trouvent par defaut sur Ubuntu. Ça vous permettra aussi, pendant les tests, de ne pas avoir à taper le chemin entier mais seulement ''1.sh'' dans votre invite de commandes. ==== Utiliser le clavier numérique de la télécommande pour taper des lettres ==== Ce fichier de configuration, à modifier en fonction de votre matériel grâce à [[https://www.lirc.org/html/configure.html|cette documentation]], annonce un mode « //backspace// » avec cette ligne : begin backspace puis la termine avec celle ci. end backspace Le mode est ensuite appelé à chaque fois que vous appuyez sur une touche numérique grâce à cette ligne : mode = backspace Pour l'instant, par exemple, pour écrire « le », il faut taper trois fois sur la touche 5 puis sur la touche 0 (espace) et enfin deux fois sur la touche 3. De la même façon, pour écrire « l e », il faut taper trois fois sur la touche 5 puis deux fois sur la touche 0 (espace) et enfin deux fois sur la touche 3. Si vous voulez vous y pencher, éditez le fichier. Ça n'est pas une raison pour écrire en langage SMS ! begin backspace begin button = Two prog = irxevent config = Key BackSpace CurrentWindow end begin button = Three prog = irxevent config = Key BackSpace CurrentWindow end begin button = Four prog = irxevent config = Key BackSpace CurrentWindow end begin button = Five prog = irxevent config = Key BackSpace CurrentWindow end begin button = Six prog = irxevent config = Key BackSpace CurrentWindow end begin button = Seven prog = irxevent config = Key BackSpace CurrentWindow end begin button = Eight prog = irxevent config = Key BackSpace CurrentWindow end begin button = Nine prog = irxevent config = Key BackSpace CurrentWindow end end backspace begin button = Two prog = irxevent config = Key a CurrentWindow config = Key b CurrentWindow config = Key c CurrentWindow flags = quit mode = backspace end begin button = Three prog = irxevent config = Key d CurrentWindow config = Key e CurrentWindow config = Key f CurrentWindow mode = backspace flags = toggle_reset end begin button = Four prog = irxevent config = Key g CurrentWindow config = Key h CurrentWindow config = Key i CurrentWindow mode = backspace flags = toggle_reset end begin button = Five prog = irxevent config = Key j CurrentWindow config = Key k CurrentWindow config = Key l CurrentWindow mode = backspace flags = toggle_reset end begin button = Six prog = irxevent config = Key m CurrentWindow config = Key n CurrentWindow config = Key o CurrentWindow mode = backspace flags = toggle_reset end begin button = Seven prog = irxevent config = Key p CurrentWindow config = Key q CurrentWindow config = Key r CurrentWindow config = Key s CurrentWindow mode = backspace flags = toggle_reset flags = toggle_reset end begin button = Eight prog = irxevent config = Key t CurrentWindow config = Key u CurrentWindow config = Key v CurrentWindow mode = backspace flags = toggle_reset end begin button = Nine prog = irxevent config = Key w CurrentWindow config = Key x CurrentWindow config = Key y CurrentWindow config = Key z CurrentWindow flags = toggle_reset mode = backspace end begin button = Zero prog = irxevent config = Key space CurrentWindow end begin button = One prog = irxevent config = Key BackSpace CurrentWindow mode = backspace flags = toggle_reset end ---- //Contributeurs : [[:utilisateurs:Julius22|Julius22]] et [[:utilisateurs:moebius_eye|moebius_eye]]// Sources : * [[http://lucdidry.free.fr/blog/index.php?post/2009/09/29/Installer-une-t%C3%A9l%C3%A9commande-ATI-Remote-Wonder-sous-Debian]] ; * [[https://www.lirc.org/html/configure.html]] ; * [[https://help.ubuntu.com/community/InstallLirc/Hardy]] ; * [[http://doc.kubuntu-fr.org/lircrc?rev=1263851056]].