File tree 2 files changed +25
-1
lines changed
2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ # python keyboard library does not handle keyboard connection and disconnection events
4
+ # so this service monitors the keyboards and restarts the mediakey service when it detects
5
+ # a change in the number of connected keyboards
6
+
7
+ last_num_kbds=0
8
+
9
+ while true ; do
10
+ # get number of connected keyboards
11
+ curr_num_kbds=$( lsusb -v 2> /dev/null | grep -i keyboard | awk ' { print $2 }' )
12
+ [[ -z " ${num_keyboards} " ]] && num_keyboards=0
13
+
14
+ # if # of kbds has changed
15
+ if [[ ${curr_num_kbds} -ne ${last_num_kbds} ]]; then
16
+ # restart service
17
+ fi
18
+
19
+ last_num_kbds=curr_num_kbds
20
+
21
+ done
22
+
Original file line number Diff line number Diff line change 23
23
# - spotify
24
24
# - ...
25
25
26
- import importlib
26
+ # import importlib
27
27
import time
28
28
from threading import Thread
29
29
import keyboard
@@ -67,6 +67,8 @@ def connect():
67
67
68
68
sonos = soco .discovery .any_soco ()
69
69
print ("Connected to '" + str (sonos .player_name ) + "'" )
70
+ # todo - error handling if unsuccessful
71
+
70
72
state = ""
71
73
volume = 0
72
74
volume_step = config ['sonos' ]['vol_step' ]
You can’t perform that action at this time.
0 commit comments