@walldock/agent 0.2.1 → 0.2.3

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 CHANGED
@@ -73,8 +73,19 @@ function log(msg) {
73
73
  // ─── Main ─────────────────────────────────────────────────────────────────────
74
74
  async function main() {
75
75
  const args = process.argv.slice(2);
76
- // --unlink: remove stored credentials and startup entry
77
- if (args.includes('--unlink')) {
76
+ // --unlink / --relink: remove stored credentials and startup entry
77
+ // --relink also falls through to the pairing flow below
78
+ if (args.includes('--unlink') || args.includes('--relink')) {
79
+ const isRelink = args.includes('--relink');
80
+ // Kill any running background instance first
81
+ const bgPid = await (0, pid_1.runningPid)();
82
+ if (bgPid) {
83
+ try {
84
+ process.kill(bgPid);
85
+ }
86
+ catch { /* already dead */ }
87
+ await new Promise(r => setTimeout(r, 600));
88
+ }
78
89
  const token = await storage.getDeviceToken();
79
90
  if (token) {
80
91
  const api = new api_1.AgentApi();
@@ -83,8 +94,11 @@ async function main() {
83
94
  await storage.deleteDeviceToken();
84
95
  await storage.clearDeviceIdentity();
85
96
  await (0, startup_1.unregisterStartup)().catch(() => undefined);
86
- console.log('Device unlinked and startup entry removed.');
87
- return;
97
+ if (!isRelink) {
98
+ console.log('Device unlinked and startup entry removed.');
99
+ return;
100
+ }
101
+ console.log('Device unlinked. Starting pairing…\n');
88
102
  }
89
103
  // --status: print current link status
90
104
  if (args.includes('--status')) {
@@ -105,6 +119,7 @@ async function main() {
105
119
  }
106
120
  catch (err) {
107
121
  console.error(`\n${err}`);
122
+ console.error('To re-link: right-click the tray icon → Quit, or run: walldock-agent --unlink');
108
123
  process.exit(1);
109
124
  }
110
125
  const api = new api_1.AgentApi(process.env['WALLDOCK_API_URL'] ?? undefined);
@@ -194,15 +209,16 @@ async function main() {
194
209
  await storage.setDeviceIdentity({ deviceId: existing.deviceId, deviceName: existing.deviceName });
195
210
  log(`Linked as "${existing.deviceName}". Starting sync…`);
196
211
  if (await maybeStartTray()) {
197
- console.log('Walldock Agent is running in the system tray.');
212
+ console.log(`Walldock Agent is running in the system tray (linked as "${existing.deviceName}").`);
213
+ console.log('To re-link this device: walldock-agent --unlink');
198
214
  process.exit(0);
199
215
  }
200
216
  sync.start({ token: existing.token, deviceId: existing.deviceId });
201
217
  return; // sync loop keeps process alive (isTray path)
202
218
  }
203
219
  // No valid token — need to pair
204
- if (isDaemon) {
205
- log('No valid device token found. Run without --daemon to pair this device.');
220
+ if (isDaemon || isTray) {
221
+ log('No valid device token found. Run "walldock-agent" to pair this device.');
206
222
  process.exit(1);
207
223
  }
208
224
  // Interactive pairing
@@ -47,7 +47,7 @@ public class MonitorHelper {
47
47
  [MonitorHelper]::Enumerate() | ForEach-Object { Write-Output $_ }
48
48
  `.trim();
49
49
  async function listScreensWindows() {
50
- const { stdout } = await exec('powershell.exe', ['-NoProfile', '-Command', PS_SCRIPT]);
50
+ const { stdout } = await exec('powershell.exe', ['-NoProfile', '-Command', PS_SCRIPT], { windowsHide: true, encoding: 'utf8' });
51
51
  const screens = [];
52
52
  for (const line of stdout.trim().split(/\r?\n/)) {
53
53
  if (!line.trim())
@@ -53,5 +53,5 @@ public class WallpaperHelper {
53
53
  "@
54
54
  [WallpaperHelper]::Set(${monitorIndex}, '${safePath}')
55
55
  `.trim();
56
- await exec('powershell.exe', ['-NoProfile', '-Command', script]);
56
+ await exec('powershell.exe', ['-NoProfile', '-Command', script], { windowsHide: true, encoding: 'utf8' });
57
57
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@walldock/agent",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Walldock desktop agent — sync wallpapers across all your screens",
5
5
  "license": "MIT",
6
6
  "main": "dist/main.js",