diff options
author | Bartosz Jaroszewski <b.jarosze@gmail.com> | 2018-11-01 15:42:46 +0100 |
---|---|---|
committer | Bartosz Jaroszewski <b.jarosze@gmail.com> | 2018-11-01 15:53:51 +0100 |
commit | 85b776eaaa9da6755264cfdefd9da2739b3b524d (patch) | |
tree | 35e768af35aaa91d3200ee92b470ecff122c3fd6 | |
parent | 8116a85a705ac96105c87c482fc3513e6cb4fa8d (diff) |
added bluetoothctl test
-rw-r--r-- | extension.js | 22 | ||||
-rw-r--r-- | metadata.json | 5 |
2 files changed, 20 insertions, 7 deletions
diff --git a/extension.js b/extension.js index 8db7417..8c04e7a 100644 --- a/extension.js +++ b/extension.js @@ -51,13 +51,16 @@ class BluetoothDevice { } _disconnect() { - let command = `echo -e "disconnect ${this.mac}\\n" | bluetoothctl`; - Util.spawn(['/bin/bash', '-c', command]); + this._call_bluetoothctl(`disconnect ${this.mac}`) } _connect() { - let command = `echo -e "connect ${this.mac}\\n" | bluetoothctl`; - Util.spawn(['/bin/bash', '-c', command]); + this._call_bluetoothctl(`connect ${this.mac}`) + } + + _call_bluetoothctl(command) { + let btctl_command = `echo -e "${command}\\n" | bluetoothctl`; + Util.spawn(['/bin/bash', '-c', btctl_command]); } } @@ -90,8 +93,16 @@ class BluetoothQuickConnect { this._destroy(); } + test() { + try { + GLib.spawn_command_line_sync("bluetoothctl --version"); + } catch(error) { + Main.notifyError(`Bluetooth quick connect: error trying to execute "bluetoothctl"`); + } + } + _idleMonitor() { - this._idleMonitorId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 60 * 1000, () => { + this._idleMonitorId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, this._autoPowerOffCheckingInterval() * 1000, () => { if (this._autoPowerOffEnabled() && this._getConnectedDevices().length === 0) this._proxy.BluetoothAirplaneMode = true; @@ -204,6 +215,7 @@ function init() { } function enable() { + bluetoothQuickConnect.test(); bluetoothQuickConnect.enable(); } diff --git a/metadata.json b/metadata.json index b4f7151..4508c6b 100644 --- a/metadata.json +++ b/metadata.json @@ -1,12 +1,13 @@ { "name": "Bluetooth quick connect", - "description": "Allow to connect to paired devices from gnome control panel.", + "description": "Allow to connect to paired devices from gnome control panel.\n", "uuid": "bluetooth-quick-connect@bjarosze.gmail.com", "url": "https://github.com/bjarosze/gnome-bluetooth-quick-connect", "settings-schema": "org.gnome.shell.extensions.bluetooth-quick-connect", "gettext-domain": "bluetooth-quick-connect", "shell-version": [ "3.26.2", - "3.28" + "3.28", + "3.30" ] } |