Read the statement by Michael Teeuw here.
Automatically wake bluetooth speaker from sleep/suspend
-
@stinger0815 well, you could add it to the boot sequence too…
make it a bash script, and call it from boot and GA recipe
-
@sdetweil said in Automatically wake bluetooth speaker from sleep/suspend:
@stinger0815 well, you could add it to the boot sequence too…
make it a bash script, and call it from boot and GA recipe
Hey - I actually did not dig into the PIR wake that much and have not implemented it yet, sorry for that. But I thought it is more about switching on the display and not rebooting the whole mirror or am I wrong? If it actually runs over boot this could definitely do the job! I’ll check the module real quick…
-
@stinger0815 u are the one that mentioned boot…
and I did not wanted to delay the response or miss parts simply due to the system still booting…
PIR is turn off/on monitor somehow… (none of them work on my monitors or tvs)
i don’t know if u can tag along on pir wakeup
well, YES, you can… on linux ANYTHING is an executable…
SO, you could make a script named the same as the pgm that GA will call on PIR wakeup
and inside that script do your thing and then call the original pgm (U will probably have to rename it, or move it a new location) passing the original parms…
I’ve done this a hundred times over the years…
-
@sdetweil said in Automatically wake bluetooth speaker from sleep/suspend:
SO, you could make a script named the same as the pgm that GA will call on PIR wakeup
and inside that script do your thing and then call the original pgm (U will probably have to rename it, or move it a new location) passing the original parms…
I’ve done this a hundred times over the years…
Sounds pretty good to me - however, here comes the next problem. I’m pretty bad with all kinds of script based + OO languages. My only background is embedded development, so translating what you said sounds a little bit like creating a new callback function and from there calling the original one. BUT how?! :beaming_face_with_smiling_eyes: No, for real, I’ve looked the forum real quick for stuff like “how to invoke small scripts” but was not successful. Do you have by any chance some sort of quick-start guide or any other tutorial to look at? I feel bad for asking as this is nothing really “magic mirror” related rather a basic programming thing - however, still want to give it a try in order to avoid mistakes that could come from the MM structure/architecture.
Best regards and thanks again
-
@stinger0815 start here
https://linuxcommand.org/lc3_wss0010.phpbut one point the filename does NOT NEED the .sh extension
The leap from this topic to my idea is that your ‘script’ can be named the same as the program u wish to run and no one could tell it was your script instead!
and your script can call the original program so you don’t have to recreate everything it doespath is an important topic here. covered in the linked topic
most of this works in windows too
-
@sdetweil said in Automatically wake bluetooth speaker from sleep/suspend:
@stinger0815 start here
https://linuxcommand.org/lc3_wss0010.phpbut one point the filename does NOT NEED the .sh extension
The leap from this topic to my idea is that your ‘script’ can be named the same as the program u wish to run and no one could tell it was your script instead!
and your script can call the original program so you don’t have to recreate everything it doespath is an important topic here. covered in the linked topic
most of this works in windows too
Hey thank you very much! I’ve in the meantime started to look for a hack to get it to work:
in the node_helper of the detector module I’ve changed the function that sends the notification once the trigger command is received and added a child_process (from nodejs) there:
onDetected: function (from, detected) { this.deactivate() let ble = require('child_process'); ble.exec('sh bluetooth_connector.sh', function (error, stdout, stderr) { console.log('stdout: ' + stdout); console.log('stderr: ' + stderr); if (error !== null) { console.log('exec error: ' + error); } }); this.sendSocketNotification("DETECTED", { from: from, key: detected } ) },
The script that is called by exec “bluetooth_connector” only contains:
#!/bin/bash bluetoothctl \ connect <<BLE ADDRESS>> exit
pretty hacky but does the job for now. I’ll now try to figure out whether this is actually decoupled enough so that the exec does not block the rest of the application. As I can tell from the logs it looks like the script is decoupled and runs in the background - what is good.
So as this is running now I’ll look into the solution you gave.
-
(if you think that is the better solution… I will engage you for coding :D)
-
@bugsounet said in Automatically wake bluetooth speaker from sleep/suspend:
(if you think that is the better solution… I will engage you for coding :D)
:face_with_hand_over_mouth:
It’s certainly not a perfect solution - I have to add that every time there is an update in the detector helper - ohh, surprise, there is an update in the detector module :D
-
humm…
i’m so kind today … so try v3.0.4 of GA with this recipe:var recipe = { commands: { "Bluetooth": { shellExec: { exec: (params) => { if (params.notification == "GA_ACTIVATE") return "bluetooth_connector.sh" else return null } } } }, plugins: { onNotificationReceived: "Bluetooth" }, } exports.recipe = recipe
Note maybe you have to add path in the return value example
/home/pi/bla/bla/bluetooth_connector.sh
-
@bugsounet said in Automatically wake bluetooth speaker from sleep/suspend:
humm…
i’m so kind today … so try v3.0.4 of GA with this recipe:var recipe = { commands: { [...] Note maybe you have to add path in the return value example `/home/pi/bla/bla/bluetooth_connector.sh`
That’s pretty sweet and works fine :) Thank you very much!