Skip to content

Commit a598cd8

Browse files
committed
Use XDG_RUNTIME_DIR instead of tmp
1 parent 0762a72 commit a598cd8

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

src/Previewer/DBusPreviewer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import Gio from "gi://Gio";
22

33
import previewer_xml from "./previewer.xml" with { type: "string" };
4+
import { buildRuntimePath } from "../util.js";
45

56
const nodeInfo = Gio.DBusNodeInfo.new_for_xml(previewer_xml);
67
const interface_info = nodeInfo.interfaces[0];
78

89
const guid = Gio.dbus_generate_guid();
10+
const path = buildRuntimePath(`workbench_preview_dbus_socket_${Date.now()}`);
911
const server = Gio.DBusServer.new_sync(
10-
"unix:path=/var/tmp/workbench_preview_dbus_socket",
12+
`unix:path=${path}`,
1113
Gio.DBusServerFlags.AUTHENTICATION_REQUIRE_SAME_USER,
1214
guid,
1315
null,

src/TermConsole.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import GLib from "gi://GLib";
33
import Gio from "gi://Gio";
44
import Gdk from "gi://Gdk";
55
import Adw from "gi://Adw";
6+
import { buildRuntimePath } from "./util.js";
67

78
// https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797
89
const ERASE_ENTIRE_SCREEN = "\u001b[2J";
@@ -24,10 +25,13 @@ export default function TermConsole({
2425
// terminal.set_cursor_blink_mode(Vte.CursorBlinkMode.ON);
2526
// terminal.set_input_enabled(true);
2627

28+
// See src/workbench
29+
const path = buildRuntimePath("typescript");
30+
2731
terminal.spawn_async(
2832
Vte.PtyFlags.DEFAULT, // pty_flags
2933
null, // working_directory
30-
["/bin/tail", "--line=0", "--follow", "/var/tmp/workbench"], // argv
34+
["/bin/tail", "--line=0", "--follow", path], // argv
3135
[], // envv
3236
GLib.SpawnFlags.DEFAULT, // spawn_flags
3337
null,

src/util.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,11 @@ export function getNowForFilename() {
179179
export function makeDropdownFlat(dropdown) {
180180
dropdown.get_first_child().add_css_class("flat");
181181
}
182+
183+
export function buildRuntimePath(...args) {
184+
return GLib.build_filenamev([
185+
GLib.getenv("XDG_RUNTIME_DIR"),
186+
GLib.getenv("FLATPAK_ID"),
187+
...args,
188+
]);
189+
}

src/window.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Adw from "gi://Adw";
66
import Vte from "gi://Vte";
77

88
import * as xml from "./langs/xml/xml.js";
9-
import { languages } from "./util.js";
9+
import { buildRuntimePath, languages } from "./util.js";
1010
import Document from "./Document.js";
1111
import PanelUI from "./PanelUI.js";
1212
import PanelCode from "./PanelCode.js";
@@ -317,7 +317,8 @@ export default function Window({ application, session }) {
317317
// because gjs doesn't appear to use etag for module caching
318318
// ?foo=Date.now() also does not work as expected
319319
// TODO: File a bug
320-
const [file_javascript] = Gio.File.new_tmp("workbench-XXXXXX.js");
320+
const path = buildRuntimePath(`workbench-${Date.now()}`);
321+
const file_javascript = Gio.File.new_for_path(path);
321322
await file_javascript.replace_contents_async(
322323
new GLib.Bytes(text),
323324
null,

src/workbench

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS="-C link-arg=-fuse-ld=/us
1616
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=clang
1717
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUSTFLAGS="-C link-arg=-fuse-ld=/usr/lib/sdk/rust-stable/bin/mold"
1818

19-
SHELL=/bin/sh script --flush --quiet --return /var/tmp/workbench --command "@app_id@ $@"
19+
mkdir -p $XDG_RUNTIME_DIR/$FLATPAK_ID
20+
SHELL=/bin/sh script --flush --quiet --return $XDG_RUNTIME_DIR/$FLATPAK_ID/typescript --command "@app_id@ $@"

0 commit comments

Comments
 (0)