From 5cfd2f1423f07869797f33db93e240fa39399114 Mon Sep 17 00:00:00 2001 From: flatsiedatsie Date: Tue, 24 May 2022 21:05:07 +0200 Subject: [PATCH] Add files via upload --- css/extension.css | 3 --- js/extension.js | 2 +- manifest.json | 12 +++++++----- pkg/voco_adapter.py | 45 +++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 51 insertions(+), 11 deletions(-) diff --git a/css/extension.css b/css/extension.css index f435f90d..5934176f 100644 --- a/css/extension.css +++ b/css/extension.css @@ -96,9 +96,6 @@ } -.extension-voco-select-satellites-question{ - -} .extension-voco-item{ padding: 0; diff --git a/js/extension.js b/js/extension.js index db2dc17f..27ff3d7d 100644 --- a/js/extension.js +++ b/js/extension.js @@ -455,7 +455,7 @@ if(this.busy_polling){ - console.log("was still polling, aborting new poll"); + console.log("voco: was still polling, aborting new poll"); return; } else{ diff --git a/manifest.json b/manifest.json index a41691c8..c26ef426 100644 --- a/manifest.json +++ b/manifest.json @@ -40,7 +40,7 @@ "Sound detection": false, "Hey Candle": true, "Mute the radio": false, - "Satellite device control": true, + "Satellite device control": false, "Disable security": false, "MQTT port": 1885, "Debugging": false @@ -48,7 +48,7 @@ "schema": { "properties": { "Authorization token": { - "description": "Advanced. To be allowed to get information on all your devices, you have to create an 'authorization' code. It's basically a very long password. You can generate it yourself under Settings -> Developer -> Create local authorization. Any code you add here will override the code set throug the interface.", + "description": "Advanced. To be allowed to get information on all your devices, you have to create an 'authorization' code. It's basically a very long password. You can generate it yourself under Settings -> Developer -> Create local authorization. Any code you add here will override the code set through the interface.", "type": "string" }, "Metric": { @@ -92,7 +92,7 @@ "type": "string" }, "Use Aplay instead of OMX Player": { - "description": "In some cases Voco will use OMX Player to play audio files. If this is causing issues you can choose to only use Aplay.", + "description": "Advanced. In some cases Voco will use OMX Player to play audio files. If this is causing issues you can choose to only use Aplay.", "type": "boolean" }, "Voice accent": { @@ -167,8 +167,10 @@ "type": "string" }, "System audio volume": { - "description": "Advanced. When provided, the system volume will be set to this volume percentage level when Voco starts. This is separate from Voco's own volume, which is relative to the system volume. Can be between 0 and 100 percent. The default is 95.", - "type": "integer" + "description": "Advanced. When provided, the system volume will be set to this volume percentage level when Voco starts. This is separate from Voco's own volume, which is relative to the system volume. Can be between 0 and 100 percent. The default is 90.", + "type": "integer", + "minimum": 10, + "maximum": 100 }, "Sound detection": { "description": "When enabled, an extra switch will be created in the voice control thing. That switch will be turned on for 10 seconds whenever speech or sound is detected.", diff --git a/pkg/voco_adapter.py b/pkg/voco_adapter.py index b2fa3367..dc89f9bf 100644 --- a/pkg/voco_adapter.py +++ b/pkg/voco_adapter.py @@ -1696,6 +1696,8 @@ def mute(self): if self.DEBUG: print("In mute. current_control_name: " + str(self.current_control_name)) run_command("amixer sset " + str(self.current_control_name) + " mute") + #self.pause_omxplayer() + @@ -1703,9 +1705,48 @@ def unmute(self): if self.DEBUG: print("In unmute. current_control_name: " + str(self.current_control_name)) run_command("amixer sset " + str(self.current_control_name) + " unmute") + #self.pause_omxplayer() + + # dangerous if it gets out of sync somehow.. + def pause_omxplayer(self): + if self.DEBUG: + print("Trying dbus mute of omxplayer") - + omxplayerdbus_user = run_command('cat /tmp/omxplayerdbus.${USER:-root}') + if self.DEBUG: + print("DBUS_SESSION_BUS_ADDRESS: " + str(omxplayerdbus_user)) + if omxplayerdbus_user != None: + if self.DEBUG: + print("trying dbus-send") + environment = os.environ.copy() + environment["DBUS_SESSION_BUS_ADDRESS"] = str(omxplayerdbus_user).strip() + environment["DISPLAY"] = ":0" + + if self.DEBUG: + print("environment: " + str(environment)) + + dbus_volume = volume / 100 + if self.DEBUG: + print("dbus_volume: " + str(dbus_volume)) + + dbus_command = 'dbus-send --print-reply --session --reply-timeout=500 --dest=org.mpris.MediaPlayer2.omxplayer /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Action int32:16' + #dbus_command = 'dbus-send --print-reply --session --reply-timeout=500 --dest=org.mpris.MediaPlayer2.omxplayer /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Set string:"org.mpris.MediaPlayer2.Player" string:"Volume" double:' + str(dbus_volume) + #export DBUS_SESSION_BUS_ADDRESS=$(cat /tmp/omxplayerdbus.${USER:-root}) + dbus_process = subprocess.Popen(dbus_command, + env=environment, + shell=True, # Streaming to bluetooth seems to only work if shell is true. The position of the volume string also seemed to matter + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + close_fds=True) + + stdout,stderr = dbus_process.communicate() + + if self.DEBUG: + print("dbus stdout: " + str(stdout)) + print("dbus stderr: " + str(stderr)) + # @@ -3437,7 +3478,7 @@ def on_message(self, client, userdata, msg): self.last_injection_time = time.time() # if a site is injecting, all sites should wait a while before attempting their own injections. self.injection_in_progress = True if self.DEBUG: - print("INJECTION PERFORM MESSAGE RECEIVED") + print("INJECTION PERFORM MESSAGE RECEIVED (injection is now in progress)") elif msg.topic.startswith('hermes/injection/complete'): if self.DEBUG: