Add Linux support for apt-installed figma-linux - #18
Conversation
There was a problem hiding this comment.
Pull request overview
Adds Linux support for the unofficial Electron-based figma-linux desktop app (primarily apt-installed) by improving binary/app.asar discovery and updating CLI + launcher scripts to handle Linux-specific behaviors and Snap limitations.
Changes:
- Add Linux path detection for
app.asarand the Figma binary, plus Linux-specific process management. - Block/handle Snap-installed
figma-linuxfor Yolo Mode patching and improve related user messaging. - Update shell tooling (
setup-alias,fig-start) and documentation to reflect Linux support.
Reviewed changes
Copilot reviewed 4 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/platform.js | Adds Linux asar/binary detection, Linux process kill/run checks, and Linux version detection. |
| src/index.js | Improves Linux Snap-related setup messaging and makes figma-use detection platform-specific. |
| src/figma-patch.js | Explicitly blocks patching Snap-installed figma-linux and adds Linux-specific permission guidance. |
| bin/setup-alias.sh | Makes alias-update sed -i behavior compatible across GNU/BSD sed. |
| bin/fig-start | Adds Linux-aware Figma startup and broader “Figma running” detection. |
| README.md | Documents Linux support constraints (apt-installed figma-linux, not Snap). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| case 'linux': { | ||
| const binaryPath = getLinuxBinaryPath(); | ||
| return binaryPath ? `${binaryPath} --remote-debugging-port=${port}` : `figma-linux --remote-debugging-port=${port}`; | ||
| } |
There was a problem hiding this comment.
On Linux, getFigmaCommand returns an unquoted binaryPath. If FIGMA_CLI_BINARY_PATH contains spaces (or other shell-sensitive chars), the printed manual command will be incorrect. Consider shell-quoting the path or returning an argv-style array from getFigmaCommand and formatting it for display safely at the call site.
| } else if (PLATFORM === 'linux') { | ||
| const binaryPath = getLinuxBinaryPath(); | ||
| if (!binaryPath) return 'unknown'; | ||
| try { | ||
| return execSync(`${binaryPath} --version 2>/dev/null`, { encoding: 'utf8', stdio: 'pipe', timeout: 2000 }).trim() || 'unknown'; | ||
| } catch { |
There was a problem hiding this comment.
getFigmaVersion() builds a shell command with string interpolation: execSync(${binaryPath} --version ...). This breaks when binaryPath contains spaces and also needlessly invokes a shell. Use execFileSync(binaryPath, ['--version'], ...) (or spawnSync) to avoid quoting issues and shell interpretation.
| const ps = execSync('pgrep -f Figma 2>/dev/null || true', { encoding: 'utf8' }); | ||
| return ps.trim().length > 0; | ||
| } else if (PLATFORM === 'linux') { | ||
| const ps = execSync('pgrep -f "/figma-linux|/figma " 2>/dev/null || true', { encoding: 'utf8' }); |
There was a problem hiding this comment.
Linux isFigmaRunning() uses pgrep -f "/figma-linux|/figma ". This can fail when the process command line is just figma/figma-linux (no leading slash) or when the executable is running without arguments (no trailing space). Prefer pgrep -x figma-linux || pgrep -x figma or a regex that matches both path and bare names, e.g. (figma-linux|figma)( |$).
| const ps = execSync('pgrep -f "/figma-linux|/figma " 2>/dev/null || true', { encoding: 'utf8' }); | |
| const ps = execSync('pgrep -f "(figma-linux|figma)( |$)" 2>/dev/null || true', { encoding: 'utf8' }); |
| console.log(chalk.gray(' Or use Safe Mode: ') + chalk.cyan('node src/index.js connect --safe\n')); | ||
| } else if (process.platform === 'linux' && err.message.includes('Snap')) { | ||
| console.log(chalk.yellow('\n Snap-installed figma-linux is not supported.\n')); | ||
| console.log(chalk.gray(' Install the unofficial apt package instead if you want Linux support.\n')); |
There was a problem hiding this comment.
In this Snap-specific failure branch, the output omits the Safe Mode fallback hint that other setup-failure branches include. Adding the same "connect --safe" suggestion here would keep guidance consistent and help users proceed even when Snap installs are unsupported.
| console.log(chalk.gray(' Install the unofficial apt package instead if you want Linux support.\n')); | |
| console.log(chalk.gray(' Install the unofficial apt package instead if you want Linux support.\n')); | |
| console.log(chalk.gray(' Or use Safe Mode: ') + chalk.cyan('node src/index.js connect --safe\n')); |
Figma can be installed in linux via unofficial Electron-based desktop app (https://github.com/Figma-Linux/figma-linux)
I patched figma-cli for linux support
Please not:
Snap version of figma-linux cannot work in Yolo Mode because of sandbox.
Apt version is ok
For me Safe Mode is not usable because of missing working plugins in figma-linux