Skip to content

sasatarbuk/lircagent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LircAgent

Build Status

LircAgent is a simple library for receiving LIRC events in your PHP application.

Installation

Composer is required to generate the autoloader. Go to your cloned directory and run:

composer install

Usage

Define your .lircrc file (use your remote's buttons):

begin
     prog = MyApplication
     button = Down
     config = VOL_DOWN
     repeat = 1
     delay = 3
end

begin
     prog = MyApplication
     button = Up
     config = VOL_UP
     repeat = 1
     delay = 3
end

Define your own handler:

<?php

class MyHandler implements Lirc\HandlerInterface
{
    public function handleConfig($config, $iteration, $remote)
    {
        echo "Config: {$config}, Iteration: {$iteration}, Remote: {$remote}\n";
    }
}

Initialize and listen for events:

<?php

require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/MyHandler.php';

// Unix socket of the LIRC daemon
$socket = 'unix:///var/run/lirc/lircd';

// Your .lircrc file
$lircrc = __DIR__ . '/.lircrc';

// Your application name used in .lircrc
$appName = 'MyApplication';

// Your handler
$myHandler = new MyHandler();

$agent = new Lirc\Agent($socket, $lircrc, $appName, $myHandler);
$agent->loop();

Non-blocking mode:

while(true) {
    $agent->iteration();
    usleep(20000);
}

About

LIRC wrapper for PHP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages