forked from askmrsinh/touchpad-indicator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
synclient.js
101 lines (87 loc) · 3.03 KB
/
synclient.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/* TouchpadIndicator - Touchpad management GNOME Shell Extension.
* Orignal work Copyright (C) 2011-2013 Armin Köhler <orangeshirt at web.de>
* Modifcations Copyright (C) 2019 Ashesh Singh <user501254 at gmail.com>
*
* This file is part of TouchpadIndicator, a fork of Armin Köhler's
* 'gnome-shell-extension-touchpad-indicator' project which is licensed GPLv2.
* Orignal source code is available at https://git.io/fjVec.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to:
* The Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301, USA.
*/
const Me = imports.misc.extensionUtils.getCurrentExtension();
const Lib = Me.imports.lib;
// Disable Synclient manually to prevent errors
const USE_SYNCLIENT = true;
function logging(event) {
if (Lib.DEBUG) {
Lib.logger(`Synclient.${event}`);
}
}
var Synclient = class Synclient {
constructor() {
this._init();
}
_init() {
logging('_init()');
this.isUsable = this._isUsable();
this.tpdOff = false;
}
_isUsable() {
if (Lib.SESSION_TYPE.indexOf('wayland') !== -1) {
logging('_isUsable(): ignoring synclient on wayland');
return false;
}
if (!USE_SYNCLIENT) {
logging('_isUsable(): synclient manually disabled');
return false;
}
let comp = Lib.executeCmdSync('synclient -l');
if ((comp[1] === undefined) || (comp[0] === false)) {
logging('_isUsable(): synclient not found');
return false;
} else if (comp[1].includes("Couldn't find synaptics properties")) {
logging('_isUsable(): no properties found');
return false;
} else if (comp[1].includes('TouchpadOff')) {
logging('_isUsable(): synclient found');
return true;
}
logging('_isUsable(): unknown situation - Return false');
return false;
}
_disable() {
if (this.isUsable) {
logging('_disable()');
this.tpdOff = !!Lib.executeCmdAsync('synclient TouchpadOff=1');
}
}
_enable() {
if (this.isUsable) {
logging('_enable()');
this.tpdOff = !!Lib.executeCmdAsync('synclient TouchpadOff=0');
}
}
_switch(state) {
logging(`_switch: ${state}`);
if (state) {
return this._enable();
} else {
return this._disable();
}
}
};
/* exported Synclient */