aboutsummaryrefslogtreecommitdiff
path: root/lib/Lirc/Commands.rakumod
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Lirc/Commands.rakumod')
-rw-r--r--lib/Lirc/Commands.rakumod54
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}",
+ );
+ }
+ }
+}