diff options
author | dakkar <dakkar@thenautilus.net> | 2021-12-22 15:02:39 +0000 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2021-12-22 15:02:39 +0000 |
commit | f673ed7ed761635e5efe3bc393c9299a35e0a1a7 (patch) | |
tree | 46ffebf42880711faf2b5b9f5359b1a2a2daacdd /lib/Lirc/Commands.rakumod | |
parent | nicer error handling (diff) | |
download | media-control-f673ed7ed761635e5efe3bc393c9299a35e0a1a7.tar.gz media-control-f673ed7ed761635e5efe3bc393c9299a35e0a1a7.tar.bz2 media-control-f673ed7ed761635e5efe3bc393c9299a35e0a1a7.zip |
intergrated IR control
* PWA files
* lirc wrapper
* lircd config files
Diffstat (limited to 'lib/Lirc/Commands.rakumod')
-rw-r--r-- | lib/Lirc/Commands.rakumod | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/lib/Lirc/Commands.rakumod b/lib/Lirc/Commands.rakumod new file mode 100644 index 0000000..a274bdc --- /dev/null +++ b/lib/Lirc/Commands.rakumod @@ -0,0 +1,54 @@ +use v6.d; +use Lirc::Client; + +class Lirc::Commands { + has Lirc::Client $.client is required; + + sub hdmi-seq($input) { + return [ + <amplifier power>, + <projector power>, + ('amplifier', "hdmi{$input}"), + ] + } + sub stop-seq() { + return [ + <projector suspend>, + <amplifier hdmi1>, + <amplifier power>, + ]; + } + my %sequences = ( + 'start bluray' => [ + <amplifier power>, + <amplifier hdmi2>, + <projector power>, + <bluray power>, + ], + 'stop bluray' => [ + |stop-seq(), + <bluray power>, + ], + 'start hdmi1' => hdmi-seq(1), + 'start hdmi2' => hdmi-seq(2), + 'start hdmi3' => hdmi-seq(3), + 'stop hdmi' => stop-seq(), + ); + + method send($thing, $arg) { + if %sequences{"$thing $arg"} -> @seq { + for @seq -> @command { + await self.send(|@command); + sleep 1; + } + return Promise.kept(); + } + else { + note "irsend $thing $arg"; + return self.client.send( + remote => $thing, + keysym => "KEY_{$arg.uc}", + ); + } + } +} |