Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/desktop/scripts/dev-electron.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ await waitOn({

const childEnv = { ...process.env };
delete childEnv.ELECTRON_RUN_AS_NODE;
const linuxClassArg = process.platform === "linux" ? ["--class=t3code-dev"] : [];

let shuttingDown = false;
let restartTimer = null;
Expand Down Expand Up @@ -57,7 +58,7 @@ function startApp() {

const app = spawn(
resolveElectronPath(),
[`--t3code-dev-root=${desktopDir}`, "dist-electron/main.js"],
[...linuxClassArg, `--t3code-dev-root=${desktopDir}`, "dist-electron/main.js"],
{
cwd: desktopDir,
env: {
Expand Down
13 changes: 13 additions & 0 deletions apps/desktop/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ const ROOT_DIR = Path.resolve(__dirname, "../../..");
const isDevelopment = Boolean(process.env.VITE_DEV_SERVER_URL);
const APP_DISPLAY_NAME = isDevelopment ? "T3 Code (Dev)" : "T3 Code (Alpha)";
const APP_USER_MODEL_ID = "com.t3tools.t3code";
const LINUX_DESKTOP_ENTRY_NAME = isDevelopment ? "t3code-dev.desktop" : "t3code.desktop";
const LINUX_WM_CLASS = isDevelopment ? "t3code-dev" : "t3code";
const USER_DATA_DIR_NAME = isDevelopment ? "t3code-dev" : "t3code";
const LEGACY_USER_DATA_DIR_NAME = isDevelopment ? "T3 Code (Dev)" : "T3 Code (Alpha)";
const COMMIT_HASH_PATTERN = /^[0-9a-f]{7,40}$/i;
Expand All @@ -77,6 +79,9 @@ const DESKTOP_UPDATE_CHANNEL = "latest";
const DESKTOP_UPDATE_ALLOW_PRERELEASE = false;

type DesktopUpdateErrorContext = DesktopUpdateState["errorContext"];
type LinuxDesktopNamedApp = Electron.App & {
setDesktopName?: (desktopName: string) => void;
};

let mainWindow: BrowserWindow | null = null;
let backendProcess: ChildProcess.ChildProcess | null = null;
Expand Down Expand Up @@ -249,6 +254,10 @@ function captureBackendOutput(child: ChildProcess.ChildProcess): void {

initializePackagedLogging();

if (process.platform === "linux") {
app.commandLine.appendSwitch("class", LINUX_WM_CLASS);
}

function getDestructiveMenuIcon(): Electron.NativeImage | undefined {
if (process.platform !== "darwin") return undefined;
if (destructiveMenuIconCache !== undefined) {
Expand Down Expand Up @@ -699,6 +708,10 @@ function configureAppIdentity(): void {
app.setAppUserModelId(APP_USER_MODEL_ID);
}

if (process.platform === "linux") {
(app as LinuxDesktopNamedApp).setDesktopName?.(LINUX_DESKTOP_ENTRY_NAME);
}

if (process.platform === "darwin" && app.dock) {
const iconPath = resolveIconPath("png");
if (iconPath) {
Expand Down
17 changes: 16 additions & 1 deletion scripts/build-desktop-artifact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,14 @@ const createBuildConfig = Effect.fn("createBuildConfig")(function* (
if (platform === "linux") {
buildConfig.linux = {
target: [target],
executableName: "t3code",
icon: "icon.png",
category: "Development",
desktop: {
entry: {
StartupWMClass: "t3code",
},
},
};
}

Expand Down Expand Up @@ -616,9 +622,13 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (

// electron-builder is filtering out stageResourcesDir directory in the AppImage for production
yield* fs.copy(stageResourcesDir, path.join(stageAppDir, "apps/desktop/prod-resources"));
const stageBunTmpDir = path.join(stageRoot, ".bun-tmp");
const stageBunInstallDir = path.join(stageRoot, ".bun-install");
yield* fs.makeDirectory(stageBunTmpDir, { recursive: true });
yield* fs.makeDirectory(stageBunInstallDir, { recursive: true });

const stagePackageJson: StagePackageJson = {
name: "t3-code-desktop",
name: "t3code",
version: appVersion,
buildVersion: appVersion,
t3codeCommitHash: commitHash,
Expand Down Expand Up @@ -648,6 +658,11 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
yield* runCommand(
ChildProcess.make({
cwd: stageAppDir,
env: {
...process.env,
BUN_TMPDIR: stageBunTmpDir,
BUN_INSTALL: stageBunInstallDir,
},
...commandOutputOptions(options.verbose),
// Windows needs shell mode to resolve .cmd shims (e.g. bun.cmd).
shell: process.platform === "win32",
Expand Down
Loading