ilutex 0.0.0-stage → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -2
- package/bin/ilutex.js +41 -0
- package/install.js +184 -0
- package/package.json +42 -4
- package/systemd/ilutex-animation@.service +12 -0
- package/systemd/ilutex.service +17 -0
- package/sysusers.d/ilutex.conf +2 -0
- package/tmpfiles.d/ilutex.conf +5 -0
- package/udev/70-ilutex.rules +3 -0
package/README.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
-
#
|
|
1
|
+
# keybackcon (npm) — solo CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Keyboard Backlight Controls — control RGB del teclado AERO X16 vía HID
|
|
4
|
+
LampArray. Este paquete instala el **binario precompilado** (Linux
|
|
5
|
+
x86_64/arm64). **No** incluye la mesa de luz GTK ni sus recursos.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install -g keybackcon
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
El postinstalador, si el entorno lo permite:
|
|
12
|
+
|
|
13
|
+
- instala la regla udev de acceso al hidraw (vía `sudo`/`pkexec`; se omite con
|
|
14
|
+
`KEYBACKCON_SKIP_UDEV=1` o si ya existe);
|
|
15
|
+
- instala unidades systemd de usuario y ejecuta `daemon-reload`.
|
|
16
|
+
**No** habilita la restauración si el usuario la desactivó en el estado
|
|
17
|
+
persistido (`restore --on-login`).
|
|
18
|
+
|
|
19
|
+
Para la GUI: instala el `.deb` de la
|
|
20
|
+
[release](https://github.com/Soluciones-Alexendros/ilutex/releases) o usa
|
|
21
|
+
`./scripts/install.sh` (requiere GTK 4 y libadwaita ≥ 1.5).
|
|
22
|
+
|
|
23
|
+
Fuente y documentación: https://github.com/Soluciones-Alexendros/ilutex
|
package/bin/ilutex.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Lanzador del binario precompilado de la plataforma (modelo esbuild):
|
|
3
|
+
// el paquete meta `ilutex` declara los binarios como optionalDependencies
|
|
4
|
+
// por arquitectura; aquí se resuelve el que esté instalado.
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
const { spawn } = require('child_process');
|
|
8
|
+
|
|
9
|
+
function resolveBinary() {
|
|
10
|
+
for (const name of ['ilutex-linux-x64', 'ilutex-linux-arm64']) {
|
|
11
|
+
try {
|
|
12
|
+
const bin = require(name);
|
|
13
|
+
if (typeof bin === 'string') return bin;
|
|
14
|
+
} catch {
|
|
15
|
+
// paquete de plataforma no instalado (arquitectura distinta)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const bin = resolveBinary();
|
|
22
|
+
if (!bin) {
|
|
23
|
+
console.error(
|
|
24
|
+
'ilutex: no hay binario precompilado para esta plataforma.\n' +
|
|
25
|
+
'Soportado: Linux x86_64 y arm64. Instala desde código con scripts/install.sh.'
|
|
26
|
+
);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const child = spawn(bin, process.argv.slice(2), { stdio: 'inherit' });
|
|
31
|
+
child.on('error', (err) => {
|
|
32
|
+
console.error(`ilutex: no se pudo ejecutar ${bin}: ${err.message}`);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
});
|
|
35
|
+
child.on('exit', (code, signal) => {
|
|
36
|
+
if (signal) {
|
|
37
|
+
process.kill(process.pid, signal);
|
|
38
|
+
} else {
|
|
39
|
+
process.exit(code == null ? 1 : code);
|
|
40
|
+
}
|
|
41
|
+
});
|
package/install.js
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Postinstalación de ilutex: deja el paquete listo para funcionar.
|
|
3
|
+
// 1. Regla udev -> /etc/udev/rules.d (sudo/pkexec; opt-out con
|
|
4
|
+
// ILUTEX_SKIP_UDEV=1).
|
|
5
|
+
// 2. Unidades systemd de usuario -> ~/.config/systemd/user, con la ruta del
|
|
6
|
+
// binario resuelta, y recarga de systemd. No activa nada que el usuario
|
|
7
|
+
// hubiera desactivado; solo habilita la restauración al login si la unidad
|
|
8
|
+
// es nueva.
|
|
9
|
+
// Nada de esto aborta la instalación: sin udev/systemd el binario sigue
|
|
10
|
+
// disponible y avisa de lo que falta.
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
const { execFileSync, spawnSync } = require('child_process');
|
|
14
|
+
const fs = require('fs');
|
|
15
|
+
const os = require('os');
|
|
16
|
+
const path = require('path');
|
|
17
|
+
|
|
18
|
+
const ROOT = __dirname;
|
|
19
|
+
|
|
20
|
+
function log(msg) {
|
|
21
|
+
console.log(`ilutex: ${msg}`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function warn(msg) {
|
|
25
|
+
console.warn(`ilutex: aviso: ${msg}`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function resolveBinary() {
|
|
29
|
+
for (const name of ['ilutex-linux-x64', 'ilutex-linux-arm64']) {
|
|
30
|
+
try {
|
|
31
|
+
const bin = require(name);
|
|
32
|
+
if (typeof bin === 'string' && fs.existsSync(bin)) return bin;
|
|
33
|
+
} catch {
|
|
34
|
+
// paquete de plataforma no instalado
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function run(cmd, args, opts = {}) {
|
|
41
|
+
const r = spawnSync(cmd, args, { stdio: 'inherit', ...opts });
|
|
42
|
+
return r.status === 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function installUdev() {
|
|
46
|
+
if (process.env.ILUTEX_SKIP_UDEV === '1') {
|
|
47
|
+
log('regla udev omitida (ILUTEX_SKIP_UDEV=1)');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const dest = '/etc/udev/rules.d/70-ilutex.rules';
|
|
51
|
+
if (fs.existsSync(dest)) return;
|
|
52
|
+
const src = path.join(ROOT, 'udev', '70-ilutex.rules');
|
|
53
|
+
if (process.getuid && process.getuid() === 0) {
|
|
54
|
+
if (run('install', ['-m644', src, dest])) {
|
|
55
|
+
run('udevadm', ['control', '--reload']);
|
|
56
|
+
log('regla udev instalada (root)');
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
} else if (run('sudo', ['-n', 'install', '-m644', src, dest])) {
|
|
60
|
+
run('sudo', ['-n', 'udevadm', 'control', '--reload']);
|
|
61
|
+
log('regla udev instalada (sudo)');
|
|
62
|
+
return;
|
|
63
|
+
} else if (run('pkexec', ['install', '-m644', src, dest])) {
|
|
64
|
+
run('pkexec', ['udevadm', 'control', '--reload']);
|
|
65
|
+
log('regla udev instalada (pkexec)');
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
warn(
|
|
69
|
+
`no se pudo instalar la regla udev (hace falta para acceder al teclado).\n` +
|
|
70
|
+
` Instálala a mano: sudo install -m644 ${src} ${dest} && sudo udevadm control --reload`
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function installWriterLock() {
|
|
75
|
+
if (process.env.ILUTEX_SKIP_UDEV === '1') {
|
|
76
|
+
log('candado de escritura omitido (ILUTEX_SKIP_UDEV=1)');
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const sys = path.join(ROOT, 'sysusers.d', 'ilutex.conf');
|
|
80
|
+
const tmp = path.join(ROOT, 'tmpfiles.d', 'ilutex.conf');
|
|
81
|
+
const sysDest = '/usr/lib/sysusers.d/ilutex.conf';
|
|
82
|
+
const tmpDest = '/usr/lib/tmpfiles.d/ilutex.conf';
|
|
83
|
+
const cmds = process.getuid && process.getuid() === 0
|
|
84
|
+
? [
|
|
85
|
+
['install', ['-D', '-m644', sys, sysDest]],
|
|
86
|
+
['install', ['-D', '-m644', tmp, tmpDest]],
|
|
87
|
+
['systemd-sysusers', ['ilutex.conf']],
|
|
88
|
+
['systemd-tmpfiles', ['--create', 'ilutex.conf']],
|
|
89
|
+
]
|
|
90
|
+
: null;
|
|
91
|
+
if (cmds) {
|
|
92
|
+
cmds.forEach(([cmd, args]) => run(cmd, args));
|
|
93
|
+
log('candado de escritura instalado (root)');
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const sudo = [
|
|
97
|
+
['install', ['-D', '-m644', sys, sysDest]],
|
|
98
|
+
['install', ['-D', '-m644', tmp, tmpDest]],
|
|
99
|
+
['systemd-sysusers', ['ilutex.conf']],
|
|
100
|
+
['systemd-tmpfiles', ['--create', 'ilutex.conf']],
|
|
101
|
+
];
|
|
102
|
+
if (sudo.every(([cmd, args]) => run('sudo', ['-n', cmd, ...args]))) {
|
|
103
|
+
log('candado de escritura instalado (sudo)');
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
warn(
|
|
107
|
+
'no se pudo crear /run/ilutex/writer.lock. Sin ese candado el CLI no escribe.\n' +
|
|
108
|
+
` sudo install -D -m644 ${sys} ${sysDest}\n` +
|
|
109
|
+
` sudo install -D -m644 ${tmp} ${tmpDest}\n` +
|
|
110
|
+
' sudo systemd-sysusers ilutex.conf && sudo systemd-tmpfiles --create ilutex.conf'
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function installSystemdUnits(bin) {
|
|
115
|
+
if (spawnSync('systemctl', ['--user', 'show-environment'], { stdio: 'ignore' }).status !== 0) {
|
|
116
|
+
warn('systemd de usuario no disponible; se omite la instalación de servicios');
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const dir = path.join(os.homedir(), '.config', 'systemd', 'user');
|
|
120
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
121
|
+
// Preferencia previa: no reactivar si el usuario deshabilitó o enmascaró
|
|
122
|
+
// (mismo contrato que scripts/install.sh H-26/H-27 / KBC-10).
|
|
123
|
+
const prevEnableResult = spawnSync(
|
|
124
|
+
'systemctl',
|
|
125
|
+
['--user', 'is-enabled', 'ilutex.service'],
|
|
126
|
+
{ encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }
|
|
127
|
+
);
|
|
128
|
+
const prevEnable = (prevEnableResult.stdout || '').trim();
|
|
129
|
+
const hadUnit = fs.existsSync(path.join(dir, 'ilutex.service'));
|
|
130
|
+
const units = ['ilutex.service', 'ilutex-animation@.service'];
|
|
131
|
+
for (const unit of units) {
|
|
132
|
+
const tmpl = fs.readFileSync(path.join(ROOT, 'systemd', unit), 'utf8');
|
|
133
|
+
const rendered = tmpl.split('__KEYBACKCON_BIN__').join(bin);
|
|
134
|
+
const dest = path.join(dir, unit);
|
|
135
|
+
const existing = fs.existsSync(dest) ? fs.readFileSync(dest, 'utf8') : null;
|
|
136
|
+
if (existing !== rendered) {
|
|
137
|
+
fs.writeFileSync(dest, rendered);
|
|
138
|
+
log(`unidad ${unit} instalada en ~/.config/systemd/user`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
run('systemctl', ['--user', 'daemon-reload']);
|
|
142
|
+
const enable = path.join(dir, 'ilutex.service');
|
|
143
|
+
if (!fs.existsSync(enable)) return;
|
|
144
|
+
if (prevEnable === 'disabled' || prevEnable === 'masked') {
|
|
145
|
+
log(`restauración ${prevEnable}; no se reactiva`);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (prevEnable === 'enabled' || prevEnable === 'enabled-runtime') {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
// Alta nueva o estado no-disabled/masked: enable si no había unidad o se fuerza.
|
|
152
|
+
const forceEnable = process.env.ILUTEX_ENABLE_RESTORE === '1';
|
|
153
|
+
if (!hadUnit || forceEnable) {
|
|
154
|
+
run('systemctl', ['--user', 'enable', 'ilutex.service']);
|
|
155
|
+
log('restauración al login habilitada (systemctl --user enable ilutex.service)');
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function main() {
|
|
160
|
+
const bin = resolveBinary();
|
|
161
|
+
if (!bin) {
|
|
162
|
+
warn(
|
|
163
|
+
'no se encontró el binario de plataforma; solo se instala lo que sea posible'
|
|
164
|
+
);
|
|
165
|
+
} else {
|
|
166
|
+
log(`binario: ${bin}`);
|
|
167
|
+
}
|
|
168
|
+
installUdev();
|
|
169
|
+
installWriterLock();
|
|
170
|
+
if (bin) installSystemdUnits(bin);
|
|
171
|
+
log('listo. Prueba con: ilutex info');
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
module.exports = {
|
|
175
|
+
installSystemdUnits,
|
|
176
|
+
resolveBinary,
|
|
177
|
+
installUdev,
|
|
178
|
+
installWriterLock,
|
|
179
|
+
main,
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
if (require.main === module) {
|
|
183
|
+
main();
|
|
184
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ilutex",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "3.0.1",
|
|
4
|
+
"description": "iLutex — control cromático del teclado AERO X16 vía HID LampArray, sin dependencias (binario precompilado + instalación automática de servicios)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "commonjs",
|
|
7
|
+
"repository": "Soluciones-Alexendros/ilutex",
|
|
8
|
+
"homepage": "https://github.com/Soluciones-Alexendros/ilutex#readme",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"keyboard",
|
|
11
|
+
"rgb",
|
|
12
|
+
"hid",
|
|
13
|
+
"lamparray",
|
|
14
|
+
"backlight",
|
|
15
|
+
"lutex",
|
|
16
|
+
"aero-x16"
|
|
17
|
+
],
|
|
18
|
+
"os": [
|
|
19
|
+
"linux"
|
|
20
|
+
],
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=18"
|
|
23
|
+
},
|
|
24
|
+
"bin": {
|
|
25
|
+
"ilutex": "bin/ilutex.js"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"postinstall": "node install.js"
|
|
29
|
+
},
|
|
30
|
+
"optionalDependencies": {
|
|
31
|
+
"ilutex-linux-x64": "3.0.1",
|
|
32
|
+
"ilutex-linux-arm64": "3.0.1"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"bin/ilutex.js",
|
|
36
|
+
"install.js",
|
|
37
|
+
"udev/70-ilutex.rules",
|
|
38
|
+
"tmpfiles.d/ilutex.conf",
|
|
39
|
+
"sysusers.d/ilutex.conf",
|
|
40
|
+
"systemd/ilutex.service",
|
|
41
|
+
"systemd/ilutex-animation@.service",
|
|
42
|
+
"README.md"
|
|
43
|
+
]
|
|
44
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
[Unit]
|
|
2
|
+
Description=iLutex — restaura el color al iniciar sesión
|
|
3
|
+
# Tras la sesión gráfica; evita After=default.target + WantedBy=default.target.
|
|
4
|
+
After=graphical-session.target
|
|
5
|
+
PartOf=graphical-session.target
|
|
6
|
+
|
|
7
|
+
[Service]
|
|
8
|
+
Type=oneshot
|
|
9
|
+
# --on-login respeta restore_policy=never del estado persistido.
|
|
10
|
+
ExecStart=__KEYBACKCON_BIN__ restore --on-login
|
|
11
|
+
RemainAfterExit=yes
|
|
12
|
+
# Al iniciar sesión las ACL uaccess pueden no estar aplicadas todavía.
|
|
13
|
+
Restart=on-failure
|
|
14
|
+
RestartSec=3
|
|
15
|
+
|
|
16
|
+
[Install]
|
|
17
|
+
WantedBy=graphical-session.target
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Candado de escritura HID (ADR 13). Lo crea el paquete; el binario no lo inventa.
|
|
2
|
+
# Modos acoplados a src/writer.rs (validate_installed_parent + open 0660).
|
|
3
|
+
# Endurecer el dir a 0750 (grupo sin write) exige cambiar escritor + tests a la vez.
|
|
4
|
+
d /run/ilutex 0770 root ilutex -
|
|
5
|
+
f /run/ilutex/writer.lock 0660 root ilutex -
|