From 77e7c55b878b35a41aace3d688ac9082f1795266 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Sun, 16 Apr 2017 07:00:35 +0200
Subject: [PATCH] Add hotkeys to w530 config.

---
 ansible/config.yml                                         | 7 +++++++
 ansible/files/apt-mark/hotkeys                             | 1 +
 ansible/files/dirs                                         | 1 +
 .../system/___etc___acpi___events___plom-brightness-down   | 2 ++
 .../system/___etc___acpi___events___plom-brightness-up     | 2 ++
 ansible/files/system/___etc___acpi___events___plom-micmute | 2 ++
 ansible/files/system/___etc___acpi___events___plom-mute    | 2 ++
 .../files/system/___etc___acpi___events___plom-volume-down | 2 ++
 .../files/system/___etc___acpi___events___plom-volume-up   | 2 ++
 9 files changed, 21 insertions(+)
 create mode 100644 ansible/files/apt-mark/hotkeys
 create mode 100644 ansible/files/system/___etc___acpi___events___plom-brightness-down
 create mode 100644 ansible/files/system/___etc___acpi___events___plom-brightness-up
 create mode 100644 ansible/files/system/___etc___acpi___events___plom-micmute
 create mode 100644 ansible/files/system/___etc___acpi___events___plom-mute
 create mode 100644 ansible/files/system/___etc___acpi___events___plom-volume-down
 create mode 100644 ansible/files/system/___etc___acpi___events___plom-volume-up

diff --git a/ansible/config.yml b/ansible/config.yml
index fa4fadf..cdfec12 100644
--- a/ansible/config.yml
+++ b/ansible/config.yml
@@ -93,6 +93,13 @@
     apt: name={{item}} state=present
     with_lines: cat ~/config/ansible/files/apt-mark/multimedia | sed -e 's/ *#.*$//'
 
+  # Ensure hotkeys.
+  #
+  # For some reason, the brightness hotkeys still won't be available unless acpid is restarted (yes, after reboot).
+  - name: ensure hotkeys 
+    apt: name={{item}} state=present
+    with_lines: cat ~/config/ansible/files/apt-mark/hotkeys | sed -e 's/ *#.*$//'
+
   # Remove undesired packages
   - name: collect desired packages
     shell: cat files/apt-mark/*  | sed -e 's/ *#.*$//' > /tmp/white_list_unsorted && sort /tmp/white_list_unsorted > /tmp/white_list_sorted
diff --git a/ansible/files/apt-mark/hotkeys b/ansible/files/apt-mark/hotkeys
new file mode 100644
index 0000000..f11bdfa
--- /dev/null
+++ b/ansible/files/apt-mark/hotkeys
@@ -0,0 +1 @@
+acpid  # captures hotkey presses and triggers respective /etc/acpi/events/*
diff --git a/ansible/files/dirs b/ansible/files/dirs
index 0739bb8..269b746 100644
--- a/ansible/files/dirs
+++ b/ansible/files/dirs
@@ -1 +1,2 @@
 /etc/wicd
+/etc/acpi/events
diff --git a/ansible/files/system/___etc___acpi___events___plom-brightness-down b/ansible/files/system/___etc___acpi___events___plom-brightness-down
new file mode 100644
index 0000000..8d718d2
--- /dev/null
+++ b/ansible/files/system/___etc___acpi___events___plom-brightness-down
@@ -0,0 +1,2 @@
+event=video/brightnessdown
+action=/root/config/bin/w530_backlight.sh -
diff --git a/ansible/files/system/___etc___acpi___events___plom-brightness-up b/ansible/files/system/___etc___acpi___events___plom-brightness-up
new file mode 100644
index 0000000..864ce5f
--- /dev/null
+++ b/ansible/files/system/___etc___acpi___events___plom-brightness-up
@@ -0,0 +1,2 @@
+event=video/brightnessup
+action=/root/config/bin/w530_backlight.sh +
diff --git a/ansible/files/system/___etc___acpi___events___plom-micmute b/ansible/files/system/___etc___acpi___events___plom-micmute
new file mode 100644
index 0000000..2aab48e
--- /dev/null
+++ b/ansible/files/system/___etc___acpi___events___plom-micmute
@@ -0,0 +1,2 @@
+event=button/f20
+action=amixer set Mic toggle
diff --git a/ansible/files/system/___etc___acpi___events___plom-mute b/ansible/files/system/___etc___acpi___events___plom-mute
new file mode 100644
index 0000000..3c40988
--- /dev/null
+++ b/ansible/files/system/___etc___acpi___events___plom-mute
@@ -0,0 +1,2 @@
+event=button/mute
+action=amixer set Master toggle
diff --git a/ansible/files/system/___etc___acpi___events___plom-volume-down b/ansible/files/system/___etc___acpi___events___plom-volume-down
new file mode 100644
index 0000000..7658b1c
--- /dev/null
+++ b/ansible/files/system/___etc___acpi___events___plom-volume-down
@@ -0,0 +1,2 @@
+event=button/volumedown
+action=amixer set Master 10-
diff --git a/ansible/files/system/___etc___acpi___events___plom-volume-up b/ansible/files/system/___etc___acpi___events___plom-volume-up
new file mode 100644
index 0000000..9ba779f
--- /dev/null
+++ b/ansible/files/system/___etc___acpi___events___plom-volume-up
@@ -0,0 +1,2 @@
+event=button/volumeup
+action=amixer set Master 10+
-- 
2.30.2