Browse Source

install script, new ringtone, absolute path to ringtone

master
Dirk Alders 2 years ago
parent
commit
50ecad5a4a
4 changed files with 43 additions and 2 deletions
  1. 41
    0
      __install__.py
  2. 1
    1
      example_config/config.py
  3. 1
    1
      ring.wav
  4. BIN
      sounds/door-bell.wav

+ 41
- 0
__install__.py View File

@@ -0,0 +1,41 @@
1
+#!/bin/python
2
+#
3
+import os
4
+import sys
5
+
6
+SERVICE_FILE = """
7
+[Unit]
8
+Description=Exec Command Service
9
+After=network-online.target
10
+Wants=network-online.target
11
+[Service]
12
+User=%(UID)d
13
+Group=%(GID)d
14
+ExecStart=%(MY_PATH)s/exec_command.sh
15
+Type=simple
16
+[Install]
17
+WantedBy=default.target
18
+"""
19
+
20
+
21
+def help():
22
+    print("Usage: prog <UID> <GID> <TARGET_PATH>")
23
+
24
+if __name__ == "__main__":
25
+    if len(sys.argv) == 4:
26
+        try:
27
+            uid = int(sys.argv[1])
28
+            gid = int(sys.argv[2])
29
+        except ValueError:
30
+            help()
31
+        else:
32
+            if os.path.isdir(sys.argv[3]):
33
+                with open(os.path.join(sys.argv[3], 'exec_command.service'), "w") as fh:
34
+                    fh.write(SERVICE_FILE % {
35
+                        "MY_PATH": os.path.dirname(os.path.abspath(__file__)),
36
+                        "UID": uid,
37
+                        "GID": gid})
38
+            else:
39
+                help()
40
+    else:
41
+        help()

+ 1
- 1
example_config/config.py View File

@@ -11,7 +11,7 @@ MQTT_SERVER = "host"
11 11
 
12 12
 TOPIC = 'topic'
13 13
 PAYLOAD = b'payload'
14
-COMMAND = "aplay ring.wav -D plughw:UACDemoV10,0"
14
+COMMAND = "aplay %s/ring.wav -D plughw:UACDemoV10,0" % __BASEPATH__
15 15
 
16 16
 #
17 17
 # Logging

+ 1
- 1
ring.wav View File

@@ -1 +1 @@
1
-sounds/phone-incoming-call.wav
1
+sounds/door-bell.wav

BIN
sounds/door-bell.wav View File


Loading…
Cancel
Save