@walldock/agent 0.2.4 → 0.2.5
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/dist/main.js +17 -0
- package/dist/startup.js +13 -4
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -100,6 +100,23 @@ async function main() {
|
|
|
100
100
|
}
|
|
101
101
|
console.log('Device unlinked. Starting pairing…\n');
|
|
102
102
|
}
|
|
103
|
+
// --register-startup: (re-)register the startup entry without going through pairing
|
|
104
|
+
if (args.includes('--register-startup')) {
|
|
105
|
+
const globalBin = await (0, startup_1.getGlobalBin)();
|
|
106
|
+
if (!globalBin) {
|
|
107
|
+
console.error('walldock-agent is not globally installed. Run: npm install -g @walldock/agent');
|
|
108
|
+
process.exit(1);
|
|
109
|
+
}
|
|
110
|
+
try {
|
|
111
|
+
await (0, startup_1.registerStartup)();
|
|
112
|
+
console.log(`✓ Registered for startup (${(0, startup_1.startupDescription)()})`);
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
console.error(`Failed to register startup: ${err}`);
|
|
116
|
+
process.exit(1);
|
|
117
|
+
}
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
103
120
|
// --status: print current link status
|
|
104
121
|
if (args.includes('--status')) {
|
|
105
122
|
const identity = await storage.getDeviceIdentity();
|
package/dist/startup.js
CHANGED
|
@@ -110,13 +110,22 @@ async function unregisterMacOS() {
|
|
|
110
110
|
// ─── Windows ─────────────────────────────────────────────────────────────────
|
|
111
111
|
const REG_KEY = 'HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run';
|
|
112
112
|
const REG_VALUE = 'WalldockAgent';
|
|
113
|
+
// VBScript launcher: runs walldock-agent.cmd silently (windowStyle=0 = hidden).
|
|
114
|
+
// Stored in %APPDATA%\walldock\ so it survives package updates — the .cmd
|
|
115
|
+
// wrapper always resolves to whichever version is currently installed.
|
|
116
|
+
const VBS_PATH = path.join(process.env['APPDATA'] ?? os.homedir(), 'walldock', 'launch-agent.vbs');
|
|
113
117
|
async function registerWindows() {
|
|
114
118
|
const binPath = await resolveGlobalBin();
|
|
115
|
-
|
|
116
|
-
|
|
119
|
+
await fs.mkdir(path.dirname(VBS_PATH), { recursive: true });
|
|
120
|
+
// windowStyle=0 = hidden, WaitOnReturn=False
|
|
121
|
+
await fs.writeFile(VBS_PATH, `CreateObject("WScript.Shell").Run """${binPath}"" --tray", 0, False\n`, 'utf8');
|
|
122
|
+
const wscript = path.join(process.env['SystemRoot'] ?? 'C:\\Windows', 'System32', 'wscript.exe');
|
|
123
|
+
const cmd = `"${wscript}" "${VBS_PATH}"`;
|
|
124
|
+
await exec('reg', ['add', REG_KEY, '/v', REG_VALUE, '/t', 'REG_SZ', '/d', cmd, '/f'], { windowsHide: true, encoding: 'utf8' });
|
|
117
125
|
}
|
|
118
126
|
async function unregisterWindows() {
|
|
119
|
-
await exec('reg', ['delete', REG_KEY, '/v', REG_VALUE, '/f']).catch(() => undefined);
|
|
127
|
+
await exec('reg', ['delete', REG_KEY, '/v', REG_VALUE, '/f'], { windowsHide: true, encoding: 'utf8' }).catch(() => undefined);
|
|
128
|
+
await fs.unlink(VBS_PATH).catch(() => undefined);
|
|
120
129
|
}
|
|
121
130
|
// ─── Linux ───────────────────────────────────────────────────────────────────
|
|
122
131
|
const SYSTEMD_USER_DIR = path.join(os.homedir(), '.config', 'systemd', 'user');
|
|
@@ -195,7 +204,7 @@ function startupDescription() {
|
|
|
195
204
|
if (process.platform === 'darwin')
|
|
196
205
|
return `LaunchAgent at ${PLIST_PATH}`;
|
|
197
206
|
if (process.platform === 'win32')
|
|
198
|
-
return `Registry
|
|
207
|
+
return `Registry Run key → wscript launcher at ${VBS_PATH}`;
|
|
199
208
|
return `systemd user service (or ${DESKTOP_PATH})`;
|
|
200
209
|
}
|
|
201
210
|
/** Returns the resolved global bin path, or null if not globally installed. */
|