Skip to content

Commit e2fce27

Browse files
committedFeb 27, 2023
bug fixes
1 parent 10dce51 commit e2fce27

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed
 

‎kbd-cxn-monitor.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+

‎mediakey-remote.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# - spotify
2424
# - ...
2525

26-
import importlib
26+
#import importlib
2727
import time
2828
from threading import Thread
2929
import keyboard
@@ -67,6 +67,8 @@ def connect():
6767

6868
sonos = soco.discovery.any_soco()
6969
print("Connected to '" + str(sonos.player_name) + "'")
70+
# todo - error handling if unsuccessful
71+
7072
state = ""
7173
volume = 0
7274
volume_step = config['sonos']['vol_step']

0 commit comments

Comments
 (0)
Please sign in to comment.