paseo-open-with 0.2.0 → 0.2.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 CHANGED
@@ -43,6 +43,10 @@ Built-in apps:
43
43
 
44
44
  The menu shows only the apps it finds. Apps on `PATH` are found too.
45
45
 
46
+ On Linux, the Terminal app gives gnome-terminal `--working-directory` and Konsole
47
+ `--workdir`. Other terminals, through `x-terminal-emulator`, start in the folder
48
+ because the app runs with the folder as its working directory.
49
+
46
50
  ## Open a file link
47
51
 
48
52
  Right-click a local file link in an agent reply:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paseo-open-with",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "files": [
5
5
  "assets/",
6
6
  "paseo-plugin.json",
package/server/apps.ts CHANGED
@@ -118,12 +118,20 @@ export const PRESETS: Record<PresetId, Preset> = {
118
118
  },
119
119
  };
120
120
 
121
- /** Arguments that differ by platform for one preset, where `{path}` alone is not enough. */
122
- function presetArgs(preset: PresetId, runtime: Runtime): string {
121
+ /**
122
+ * Arguments that differ by platform for one preset, where `{path}` alone is not enough.
123
+ * `command` is the program that runs, because Linux terminals take different options.
124
+ */
125
+ function presetArgs(preset: PresetId, command: string | null, runtime: Runtime): string {
123
126
  if (preset === "terminal") {
124
127
  if (runtime.platform === "win32") return `-d "${PATH_TOKEN}"`;
125
128
  if (runtime.platform === "darwin") return `-a Terminal "${PATH_TOKEN}"`;
126
- return `--working-directory="${PATH_TOKEN}"`;
129
+ const program = command ? posix.basename(command) : "";
130
+ if (program === "konsole") return `--workdir "${PATH_TOKEN}"`;
131
+ if (program === "gnome-terminal") return `--working-directory="${PATH_TOKEN}"`;
132
+ // x-terminal-emulator can be any terminal. It starts in the folder because
133
+ // `launch` sets the working directory.
134
+ return "";
127
135
  }
128
136
  return `"${PATH_TOKEN}"`;
129
137
  }
@@ -171,13 +179,14 @@ export function expandEnv(value: string, runtime: Runtime): string {
171
179
  /** The menu entry after merging stored fields over the preset. */
172
180
  export function describeEntry(entry: Entry, runtime: Runtime): App {
173
181
  const preset = entry.preset ? PRESETS[entry.preset as PresetId] : undefined;
182
+ const defaultCommand = preset ? resolveCommand(preset.commands(runtime), runtime) : null;
183
+ const command = entry.command ? resolveCommand([entry.command], runtime) : defaultCommand;
174
184
  const defaults = {
175
185
  name: preset?.name ?? "",
176
186
  icon: preset?.icon ?? "AppWindow",
177
- command: preset ? resolveCommand(preset.commands(runtime), runtime) : null,
178
- args: preset ? presetArgs(entry.preset as PresetId, runtime) : `"${PATH_TOKEN}"`,
187
+ command: defaultCommand,
188
+ args: preset ? presetArgs(entry.preset as PresetId, command, runtime) : `"${PATH_TOKEN}"`,
179
189
  };
180
- const command = entry.command ? resolveCommand([entry.command], runtime) : defaults.command;
181
190
  return {
182
191
  id: entry.id,
183
192
  preset: entry.preset,