aboutsummaryrefslogtreecommitdiff
path: root/media-control.raku
blob: 8110b18a41b1bafa0b9ba22b62a18d3c489879e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env rakudo 
use v6.d;
use lib 'inst#local','file#lib';
use Config::TOML;
use DB::SQLite;
use Vlc::Client;
use Lirc::Client;
use Lirc::Commands;
use App::MediaControl;
use App::MediaControl::DB;
 
my $config = from-toml(file=>'config.toml');
 
my Vlc::Client $vlc .= new(
    password => $config<vlc><password>,
    base-uri => $config<vlc><base-uri>,
);
 
my Lirc::Client $lirc-client .= new();
my Lirc::Commands $lirc .= new(client=>$lirc-client);
 
my App::MediaControl::DB $db .= new(
    pool => DB::SQLite.new(
        filename => $config<db><filename>,
    ),
);
$db.ensure-schema();
 
my App::MediaControl $app .= new(
    port => $config<server><port>,
    :$vlc:$lirc,
);
 
$app.start;
 
say "listening";
 
react whenever signal(SIGINT{
    $app.stop;
    exit;
}