twokey 1.0.9 → 1.0.10
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/bin/postinstall.js +17 -0
- package/bin/twokey.js +2 -2
- package/package.json +1 -1
package/bin/postinstall.js
CHANGED
|
@@ -16,6 +16,10 @@ const isRoot = typeof process.getuid === "function" && process.getuid() === 0;
|
|
|
16
16
|
const sudoUser = process.env.SUDO_USER;
|
|
17
17
|
|
|
18
18
|
if (isRoot && sudoUser && sudoUser !== "root") {
|
|
19
|
+
if (isDesktopRunningForUser(sudoUser)) {
|
|
20
|
+
process.exit(0);
|
|
21
|
+
}
|
|
22
|
+
|
|
19
23
|
const uid = resolveUid(sudoUser);
|
|
20
24
|
const homeDir = resolveHomeDir(sudoUser);
|
|
21
25
|
const env = { ...process.env };
|
|
@@ -41,6 +45,10 @@ if (isRoot && sudoUser && sudoUser !== "root") {
|
|
|
41
45
|
delegated.on("error", () => process.exit(0));
|
|
42
46
|
delegated.on("close", () => process.exit(0));
|
|
43
47
|
} else {
|
|
48
|
+
if (isDesktopRunningForUser(process.env.USER || "")) {
|
|
49
|
+
process.exit(0);
|
|
50
|
+
}
|
|
51
|
+
|
|
44
52
|
const child = spawn(process.execPath, [cliPath, "--desktop", "--enable-autostart"], {
|
|
45
53
|
stdio: "ignore",
|
|
46
54
|
shell: false,
|
|
@@ -68,3 +76,12 @@ function resolveHomeDir(username) {
|
|
|
68
76
|
const parts = entry.split(":");
|
|
69
77
|
return parts[5] || "";
|
|
70
78
|
}
|
|
79
|
+
|
|
80
|
+
function isDesktopRunningForUser(username) {
|
|
81
|
+
if (!username) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const out = spawnSync("pgrep", ["-u", username, "-f", "twokey-ai(\\.AppImage)?"], { encoding: "utf8" });
|
|
86
|
+
return out.status === 0;
|
|
87
|
+
}
|
package/bin/twokey.js
CHANGED
|
@@ -6,7 +6,7 @@ import os from "node:os";
|
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import readline from "node:readline";
|
|
8
8
|
|
|
9
|
-
const VERSION = process.env.npm_package_version || "1.0.
|
|
9
|
+
const VERSION = process.env.npm_package_version || "1.0.10";
|
|
10
10
|
const DEFAULT_MODEL = process.env.TWOKEY_OLLAMA_MODEL || "qwen2.5:3b";
|
|
11
11
|
const DEFAULT_OLLAMA_URL = process.env.TWOKEY_OLLAMA_URL || "http://127.0.0.1:11434";
|
|
12
12
|
const LATEST_RELEASE_API = "https://api.github.com/repos/meinzeug/twokey/releases/latest";
|
|
@@ -382,7 +382,7 @@ async function ensureUserService(command) {
|
|
|
382
382
|
|
|
383
383
|
try {
|
|
384
384
|
await runSystemctlUser(["daemon-reload"]);
|
|
385
|
-
await runSystemctlUser(["enable", "
|
|
385
|
+
await runSystemctlUser(["enable", "twokey.service"]);
|
|
386
386
|
} catch {
|
|
387
387
|
// Fallback for install contexts where user DBus is not reachable.
|
|
388
388
|
await enableServiceBySymlink(systemdDir, servicePath);
|