18 Commits

Author SHA1 Message Date
Sebastian Palencsar
40fda06dbd Update packaging PKGBUILD template for alpha.8 2026-02-25 20:00:38 +01:00
Sebastian Palencsar
694711ea07 Clarify chromium browser wrapper caveat applies to multiple browsers 2026-02-25 19:59:30 +01:00
Sebastian Palencsar
2efebfdce8 Document chromium backend browser-bin troubleshooting 2026-02-25 19:58:52 +01:00
Sebastian Palencsar
02942f421a Validate chromium browser binary before installing desktop entry 2026-02-25 19:52:59 +01:00
Sebastian Palencsar
fd2186b14b Handle legacy profile_scope=default in app config 2026-02-25 19:43:06 +01:00
Sebastian Palencsar
2a4e13c58d Document AUR deskify-bin install and alpha warning 2026-02-23 13:31:02 +01:00
Sebastian Palencsar
33d8d1b64b Fix AUR host key verification in publish workflow 2026-02-23 13:19:36 +01:00
Sebastian Palencsar
5b849f9820 Allow manual AUR publish reruns via workflow_dispatch 2026-02-23 13:13:53 +01:00
Sebastian Palencsar
1c3d0a5320 Run makepkg as non-root in AUR publish workflow 2026-02-23 13:10:48 +01:00
Sebastian Palencsar
97b0e0bf1e Wait for GitHub release asset before generating AUR PKGBUILD 2026-02-23 13:08:54 +01:00
Sebastian Palencsar
29ab78799c Add AUR publish workflow and PKGBUILD generator 2026-02-23 12:34:13 +01:00
Sebastian Palencsar
3b745dfba1 Update deskify-bin PKGBUILD for v0.1.0-alpha.7 2026-02-23 12:28:43 +01:00
Sebastian Palencsar
ba846aa2db Finalize AUR deskify-bin PKGBUILD checksums 2026-02-23 12:23:59 +01:00
Sebastian Palencsar
19a402be4d Improve quick start PATH hint and clarify install tracks 2026-02-23 12:20:37 +01:00
Sebastian Palencsar
b10db23311 Remove reviewer reply/roadmap drafts from repo 2026-02-23 12:17:20 +01:00
Sebastian Palencsar
1bc4ac4bc9 Persist app config, add list --verbose, and improve quick start/install 2026-02-23 12:15:10 +01:00
Sebastian Palencsar
4c1b350583 Clarify backend choice and chromium update usage in README 2026-02-23 11:32:20 +01:00
Sebastian Palencsar
57ab313150 Fix changelog version for alpha.6 tag 2026-02-23 11:30:29 +01:00
9 changed files with 660 additions and 42 deletions

91
.github/workflows/aur-publish.yml vendored Executable file
View File

@@ -0,0 +1,91 @@
name: Publish to AUR
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Tag to publish to AUR (e.g. v0.1.0-alpha.8)"
required: true
type: string
permissions:
contents: read
jobs:
aur-publish:
name: Publish deskify-bin
runs-on: ubuntu-latest
container: archlinux:latest
steps:
- name: Install dependencies
run: |
pacman -Syu --noconfirm
pacman -S --noconfirm --needed base-devel git openssh curl
useradd -m -u 1000 builder || true
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.tag || github.ref_name }}
- name: Generate PKGBUILD (deskify-bin)
run: bash packaging/generate-pkgbuild-bin.sh "${{ inputs.tag || github.ref_name }}"
- name: Generate .SRCINFO
run: |
rm -rf /home/builder/work
mkdir -p /home/builder/work
cp -R . /home/builder/work
chown -R builder:builder /home/builder/work
su - builder -c "cd /home/builder/work/packaging && makepkg --printsrcinfo > .SRCINFO"
cp /home/builder/work/packaging/.SRCINFO packaging/.SRCINFO
- name: Configure SSH for AUR
env:
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
run: |
test -n "${AUR_SSH_PRIVATE_KEY}" || { echo "Missing secret: AUR_SSH_PRIVATE_KEY" >&2; exit 1; }
mkdir -p ~/.ssh
chmod 700 ~/.ssh
printf "%s\n" "${AUR_SSH_PRIVATE_KEY}" > ~/.ssh/aur
chmod 600 ~/.ssh/aur
touch ~/.ssh/known_hosts
chmod 600 ~/.ssh/known_hosts
# Ensure host key is present for non-interactive git/ssh.
ssh-keyscan -t rsa,ecdsa,ed25519 aur.archlinux.org >> ~/.ssh/known_hosts 2>/dev/null
cat >> ~/.ssh/config <<'EOF'
Host aur.archlinux.org
User aur
IdentityFile ~/.ssh/aur
IdentitiesOnly yes
EOF
- name: Publish to AUR (deskify-bin)
env:
AUR_USERNAME: ${{ secrets.AUR_USERNAME }}
AUR_EMAIL: ${{ secrets.AUR_EMAIL }}
run: |
export GIT_SSH_COMMAND="ssh -i ~/.ssh/aur -o IdentitiesOnly=yes -o UserKnownHostsFile=$HOME/.ssh/known_hosts -o StrictHostKeyChecking=yes"
git config --global user.name "${AUR_USERNAME:-deskify-bot}"
git config --global user.email "${AUR_EMAIL:-noreply@example.invalid}"
rm -rf /tmp/aur-repo
git clone ssh://aur@aur.archlinux.org/deskify-bin.git /tmp/aur-repo
cp packaging/PKGBUILD /tmp/aur-repo/PKGBUILD
cp packaging/.SRCINFO /tmp/aur-repo/.SRCINFO
cd /tmp/aur-repo
if git diff --quiet; then
echo "No changes to publish."
exit 0
fi
git add PKGBUILD .SRCINFO
git commit -m "Update deskify-bin to ${{ inputs.tag || github.ref_name }}"
git push

View File

@@ -7,7 +7,7 @@ and this project follows early MVP/alpha versioning with tags like `v0.1.0-alpha
## [Unreleased]
## [v0.1.0-alpha.5] - 2026-02-23
## [v0.1.0-alpha.6] - 2026-02-23
### Added
- `chromium` compatibility backend via `--backend chromium` using an installed Chromium-based browser in app mode (no local Tauri build for generated apps)

2
Cargo.lock generated
View File

@@ -351,6 +351,7 @@ dependencies = [
"directories",
"image",
"regex",
"serde",
"serde_json",
"tempfile",
"ureq",
@@ -1334,6 +1335,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
dependencies = [
"serde_core",
"serde_derive",
]
[[package]]

View File

@@ -9,6 +9,7 @@ clap = { version = "4.5.60", features = ["derive"] }
directories = "6.0.0"
image = "0.25.9"
regex = "1.12.3"
serde = { version = "1.0.218", features = ["derive"] }
serde_json = "1.0.149"
tempfile = "3.25.0"
ureq = "2.9"

View File

@@ -10,6 +10,8 @@
<img src="https://img.shields.io/badge/Language-Rust-orange?style=flat-square" alt="Written in Rust" />
<img src="https://img.shields.io/badge/Powered_by-Tauri_v2-grey?style=flat-square" alt="Tauri v2" />
<img src="https://img.shields.io/badge/Status-Alpha-yellow?style=flat-square" alt="Alpha status" />
<img src="https://img.shields.io/github/v/release/spalencsar/deskify?label=Latest%20Release&style=flat-square" alt="Latest release" />
<img src="https://img.shields.io/badge/License-MIT-green?style=flat-square" alt="MIT license" />
</p>
<p align="center">
@@ -25,6 +27,34 @@
---
## Quick Start
Two tracks, depending on what you want:
### Option A: Chromium mode (fastest, best compatibility)
Requirements: any Chromium-based browser installed (`chromium`, `google-chrome`, `brave`, etc.)
```bash
mkdir -p ~/.local/bin
curl -L -o ~/.local/bin/deskify \
https://github.com/spalencsar/deskify/releases/latest/download/deskify-linux-x86_64
chmod +x ~/.local/bin/deskify
# If `deskify` is not found, ensure ~/.local/bin is in PATH (common on Ubuntu/Debian):
command -v deskify >/dev/null || { echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc && source ~/.bashrc; }
deskify build --url "https://chat.com" --name "Chat" --backend chromium
```
### Option B: Native Tauri mode (system WebView, no Chromium dependency)
Follow the full install section below (Tauri/WebKitGTK prerequisites), then:
```bash
deskify build --url "https://chat.com" --name "Chat"
```
## Why Deskify Exists
Web apps are now core tools, but Linux desktops still treat them like second-class citizens.
@@ -145,6 +175,35 @@ The table above covers the technical tradeoffs in more detail. In practice, `des
## 🚀 Installation
### Option A: Install a prebuilt binary (recommended)
Deskify provides Linux release binaries. Download the latest release and install it into `~/.local/bin`:
```bash
mkdir -p ~/.local/bin
curl -L -o ~/.local/bin/deskify \
https://github.com/spalencsar/deskify/releases/latest/download/deskify-linux-x86_64
chmod +x ~/.local/bin/deskify
deskify --help
```
Notes:
- The `tauri` backend still requires Tauri/WebKitGTK system dependencies to build wrappers locally.
- The `chromium` backend does not require Tauri prerequisites (but it requires an installed Chromium-based browser).
### Arch Linux (AUR)
An AUR package is available (prebuilt binary package):
```bash
yay -S deskify-bin
```
⚠️ The AUR package tracks **alpha** tags (`v0.1.0-alpha.N`). Expect occasional breaking changes during early development.
### Option B: Build from source (Tauri mode)
### 1. System Dependencies
Because `deskify` compiles Tauri applications natively on your machine, you need the standard Tauri prerequisites installed before using it.
@@ -221,6 +280,11 @@ Deskify supports two backend modes:
If a site does not work in the default `tauri` backend, try `--backend chromium`.
Quick decision rule:
- Start with the default `tauri` backend for small wrappers and native Linux integration.
- If the site fails to load, behaves incorrectly, or needs a newer browser engine, rebuild/update with `--backend chromium`.
#### Advanced Build Options
```bash
deskify build \
@@ -298,18 +362,32 @@ Note for Chromium backend:
- `--no-decorations` is best-effort and may be ignored by the browser/window manager.
- `--width` and `--height` are applied together (`--window-size`) only when both are provided.
- Deskify auto-detects a Chromium-based browser from `PATH`, but some distros ship Chromium-based browser commands (Chrome/Chromium/Brave, etc.) as wrapper scripts or use different binary names/paths (for example on BigLinux). If launches fail, set `--browser-bin` to a real browser binary.
Troubleshooting (find the real browser binary):
```bash
command -v chrome chromium google-chrome google-chrome-stable brave-browser 2>/dev/null
ls -la /usr/bin/chrome /usr/bin/chromium /usr/bin/google-chrome /usr/bin/google-chrome-stable 2>/dev/null
```
### Managing Apps (`list` & `remove`)
You can view all applications generated by `deskify`:
```bash
deskify list
```
Verbose list (includes URL/backend when metadata is available):
```bash
deskify list --verbose
```
*Output:*
```text
Installed Deskify Apps:
- ChatGPT (Internal ID: chatgpt)
- Home Assistant (Internal ID: home-assistant)
- ChatGPT (Internal ID: chatgpt, Backend: tauri)
- Proton Mail (Internal ID: proton-mail, Backend: chromium)
```
To entirely uninstall an app (including the binary, desktop entry, and icons):
@@ -327,7 +405,8 @@ Rebuild and reinstall an existing app ID without manually running `remove` + `bu
deskify update chat --url "https://chat.com" --name "Chat" --no-decorations
```
Alpha note: `update` currently requires `--url` because Deskify does not persist app URLs/config metadata yet.
Deskify persists app metadata under `~/.local/share/deskify/apps/<id>.json`. With persisted metadata, `update` can be used without `--url`.
If an older app has no metadata yet, provide `--url` once (or rebuild once) to migrate it.
`update <id>` keeps the existing internal ID stable even if you change the display name.
You can also preview an update:
@@ -337,6 +416,12 @@ deskify update chat --url "https://chat.com" --dry-run
deskify update chat --url "https://chat.com" --print-config
```
Switch an existing app to Chromium compatibility mode while keeping the same internal ID:
```bash
deskify update chat --url "https://chat.com" --name "Chat" --backend chromium
```
### Diagnostics (`doctor`)
Check local prerequisites and common environment issues (Rust/Cargo, `cargo tauri`, `pkg-config`, directories):
@@ -371,10 +456,9 @@ Expected: clean validation error and no unintended file deletion.
## 🏷️ Versioning & GitHub Releases (MVP)
- Recommended tag format during MVP: `v0.1.0-alpha.N`
- Start with **source-first** releases (repository + tags)
- Add automated binary releases later via GitHub Actions
- GitHub Releases publish a Linux `deskify` CLI binary on tags (`v*`)
For the current public alpha, use `v0.1.0-alpha.2` (and continue with `v0.1.0-alpha.N` for follow-up releases).
For the latest alpha, see GitHub Releases (and continue with `v0.1.0-alpha.N` for follow-up releases).
---

23
packaging/PKGBUILD Normal file
View File

@@ -0,0 +1,23 @@
pkgname=deskify-bin
pkgver=0.1.0.alpha.8
pkgrel=1
pkgdesc="Turn websites into Linux desktop apps (prebuilt binary package)"
arch=('x86_64')
url="https://github.com/spalencsar/deskify"
license=('MIT')
depends=('glibc')
optdepends=('chromium: for --backend chromium')
provides=('deskify')
conflicts=('deskify')
_tag="v0.1.0-alpha.8"
source=("deskify::https://github.com/spalencsar/deskify/releases/download/${_tag}/deskify-linux-x86_64"
"LICENSE::https://raw.githubusercontent.com/spalencsar/deskify/${_tag}/LICENSE")
sha256sums=('7ab62ff193c2666983c72844c13f368a0ecc1fcd6da40fe95f544c9999e05f30'
'd4e53458cd2dd461f234186497b6d9b21566c477737a4d31fa6f018ef610486f')
package() {
install -Dm755 "${srcdir}/deskify" "${pkgdir}/usr/bin/deskify"
install -Dm644 "${srcdir}/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}

69
packaging/README.md Normal file
View File

@@ -0,0 +1,69 @@
## AUR package template (manual + CI)
This folder contains a minimal `PKGBUILD` template for a future AUR package:
- `deskify-bin` (prebuilt GitHub Releases binary)
Notes:
- Update `_tag` and `pkgver` when you publish a new release tag.
- Update `sha256sums` to match the release asset + LICENSE for that tag.
### Local build test
```bash
cd packaging
makepkg -sf
```
To compute sha256 sums for a tag:
```bash
TAG="v0.1.0-alpha.7"
curl -fL -o /tmp/deskify-linux-x86_64 "https://github.com/spalencsar/deskify/releases/download/${TAG}/deskify-linux-x86_64"
curl -fL -o /tmp/LICENSE "https://raw.githubusercontent.com/spalencsar/deskify/${TAG}/LICENSE"
sha256sum /tmp/deskify-linux-x86_64 /tmp/LICENSE
```
### Manual AUR publish (first time)
1. Create an AUR account and submit the `deskify-bin` package once via the AUR web UI.
2. Configure SSH for AUR and test connectivity.
3. Clone the AUR repo, copy `PKGBUILD` and `.SRCINFO`, then push.
Example:
```bash
ssh-keygen -t ed25519 -f ~/.ssh/aur -C "deskify-aur"
# Add ~/.ssh/aur.pub to: aur.archlinux.org -> My Account -> SSH Keys
cat >> ~/.ssh/config <<'EOF'
Host aur.archlinux.org
IdentityFile ~/.ssh/aur
User aur
EOF
ssh -T aur@aur.archlinux.org
git clone ssh://aur@aur.archlinux.org/deskify-bin.git
cd deskify-bin
cp /path/to/deskify/packaging/PKGBUILD .
makepkg --printsrcinfo > .SRCINFO
git add PKGBUILD .SRCINFO
git commit -m "Initial release: deskify-bin"
git push
```
### CI publish on tags
This repo includes a workflow that publishes `deskify-bin` on tag pushes (`v*`):
- `.github/workflows/aur-publish.yml`
Required GitHub secrets:
- `AUR_SSH_PRIVATE_KEY` (private key content for the AUR account)
- `AUR_USERNAME` (optional, used for git commits)
- `AUR_EMAIL` (optional, used for git commits)

View File

@@ -0,0 +1,73 @@
#!/usr/bin/env bash
set -euo pipefail
TAG="${1:-}"
if [[ -z "${TAG}" ]]; then
TAG="$(git describe --tags --abbrev=0)"
fi
if [[ "${TAG}" != v* ]]; then
echo "Error: expected tag like v0.1.0-alpha.7, got: ${TAG}" >&2
exit 1
fi
VERSION="${TAG#v}"
# Arch PKGBUILD pkgver must not contain '-'. Use dots instead.
PKGVER="${VERSION//-/.}"
ASSET_URL="https://github.com/spalencsar/deskify/releases/download/${TAG}/deskify-linux-x86_64"
LICENSE_URL="https://raw.githubusercontent.com/spalencsar/deskify/${TAG}/LICENSE"
tmp_dir="$(mktemp -d)"
trap 'rm -rf "${tmp_dir}"' EXIT
asset_path="${tmp_dir}/deskify-linux-x86_64"
license_path="${tmp_dir}/LICENSE"
wait_seconds="${WAIT_FOR_ASSET_SECONDS:-300}"
interval_seconds="${WAIT_FOR_ASSET_INTERVAL_SECONDS:-5}"
deadline=$((SECONDS + wait_seconds))
while ! curl -fsI "${ASSET_URL}" >/dev/null 2>&1; do
if (( SECONDS >= deadline )); then
echo "Error: release asset not available yet: ${ASSET_URL}" >&2
echo "Tip: the GitHub Release workflow may still be building. Re-run the AUR workflow once the asset exists." >&2
exit 1
fi
sleep "${interval_seconds}"
done
curl -fL -o "${asset_path}" "${ASSET_URL}"
curl -fL -o "${license_path}" "${LICENSE_URL}"
ASSET_SHA256="$(sha256sum "${asset_path}" | awk '{print $1}')"
LICENSE_SHA256="$(sha256sum "${license_path}" | awk '{print $1}')"
cat > packaging/PKGBUILD <<EOF
pkgname=deskify-bin
pkgver=${PKGVER}
pkgrel=1
pkgdesc="Turn websites into Linux desktop apps (prebuilt binary package)"
arch=('x86_64')
url="https://github.com/spalencsar/deskify"
license=('MIT')
depends=('glibc')
optdepends=('chromium: for --backend chromium')
provides=('deskify')
conflicts=('deskify')
_tag="${TAG}"
source=("deskify::https://github.com/spalencsar/deskify/releases/download/\${_tag}/deskify-linux-x86_64"
"LICENSE::https://raw.githubusercontent.com/spalencsar/deskify/\${_tag}/LICENSE")
sha256sums=('${ASSET_SHA256}'
'${LICENSE_SHA256}')
package() {
install -Dm755 "\${srcdir}/deskify" "\${pkgdir}/usr/bin/deskify"
install -Dm644 "\${srcdir}/LICENSE" "\${pkgdir}/usr/share/licenses/\${pkgname}/LICENSE"
}
EOF
echo "Wrote packaging/PKGBUILD for ${TAG}"

View File

@@ -12,14 +12,21 @@ use std::process::Command;
use tempfile::tempdir;
use url::Url;
#[derive(clap::ValueEnum, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(
clap::ValueEnum, serde::Serialize, serde::Deserialize, Debug, Clone, Copy, PartialEq, Eq,
)]
#[serde(rename_all = "lowercase")]
enum Backend {
Tauri,
Chromium,
}
#[derive(clap::ValueEnum, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(
clap::ValueEnum, serde::Serialize, serde::Deserialize, Debug, Clone, Copy, PartialEq, Eq,
)]
#[serde(rename_all = "lowercase")]
enum ProfileScope {
#[serde(alias = "default")]
Isolated,
Shared,
}
@@ -110,7 +117,11 @@ enum Commands {
dry_run: bool,
},
/// List all installed apps created by deskify
List,
List {
/// Show additional metadata (URL, backend) when available
#[arg(long)]
verbose: bool,
},
/// Check local prerequisites and environment diagnostics
Doctor,
/// Remove a specific app by its internal ID
@@ -118,14 +129,14 @@ enum Commands {
/// The safe name/ID of the app (e.g., "youtube")
id: String,
},
/// Rebuild and reinstall an existing app ID with new settings (alpha: URL is required)
/// Rebuild and reinstall an existing app ID with new settings (URL is optional when persisted)
Update {
/// The existing internal ID (e.g., "chatgpt")
id: String,
/// The URL to wrap (required in current alpha because URLs are not persisted yet)
/// The URL to wrap (optional if Deskify has persisted app metadata for this ID)
#[arg(short, long)]
url: String,
url: Option<String>,
/// Optional new display name (defaults to current desktop entry name or the ID)
#[arg(short, long)]
@@ -136,12 +147,12 @@ enum Commands {
icon: Option<String>,
/// Launch the application in fullscreen (Kiosk) mode
#[arg(short, long)]
fullscreen: bool,
#[arg(short, long, action = clap::ArgAction::SetTrue)]
fullscreen: Option<bool>,
/// Disable native window decorations (frameless window)
#[arg(long)]
no_decorations: bool,
#[arg(long, action = clap::ArgAction::SetTrue)]
no_decorations: Option<bool>,
/// Set a custom User-Agent string for the webview
#[arg(short = 'A', long)]
@@ -156,20 +167,20 @@ enum Commands {
height: Option<f64>,
/// Force the webview into Dark Mode
#[arg(short, long)]
dark_mode: bool,
#[arg(short, long, action = clap::ArgAction::SetTrue)]
dark_mode: Option<bool>,
/// Backend to use for the updated app
#[arg(long, value_enum, default_value_t = Backend::Tauri)]
backend: Backend,
#[arg(long, value_enum)]
backend: Option<Backend>,
/// Path to a Chromium-based browser binary (only for `--backend chromium`)
#[arg(long)]
browser_bin: Option<String>,
/// Profile isolation for Chromium backend (only for `--backend chromium`)
#[arg(long, value_enum, default_value_t = ProfileScope::Isolated)]
profile_scope: ProfileScope,
#[arg(long, value_enum)]
profile_scope: Option<ProfileScope>,
/// Show planned update actions without rebuilding/installing
#[arg(long)]
@@ -181,6 +192,23 @@ enum Commands {
},
}
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
struct DeskifyAppConfig {
schema_version: u32,
id: String,
name: String,
url: String,
backend: Backend,
browser_bin: Option<String>,
profile_scope: ProfileScope,
fullscreen: bool,
no_decorations: bool,
user_agent: Option<String>,
width: Option<f64>,
height: Option<f64>,
dark_mode: bool,
}
fn sanitize_app_id(name: &str) -> String {
let re = Regex::new(r"[^a-z0-9-]").unwrap();
let lower_name = name.to_lowercase().replace(' ', "-");
@@ -211,6 +239,83 @@ fn profile_scope_str(scope: ProfileScope) -> &'static str {
}
}
fn backend_str(backend: Backend) -> &'static str {
match backend {
Backend::Tauri => "tauri",
Backend::Chromium => "chromium",
}
}
fn deskify_data_dir() -> Result<PathBuf> {
let base_dirs = BaseDirs::new().ok_or_else(|| anyhow!("Could not find system BaseDirs"))?;
Ok(base_dirs.data_local_dir().join("deskify"))
}
fn app_config_path(id: &str) -> Result<PathBuf> {
validate_remove_id(id)?;
Ok(deskify_data_dir()?
.join("apps")
.join(format!("{}.json", id)))
}
fn read_app_config(id: &str) -> Result<Option<DeskifyAppConfig>> {
let path = app_config_path(id)?;
if !path.exists() {
return Ok(None);
}
let content = fs::read_to_string(&path)
.with_context(|| format!("Failed to read app config {}", path.display()))?;
match serde_json::from_str::<DeskifyAppConfig>(&content) {
Ok(cfg) => Ok(Some(cfg)),
Err(err) => {
eprintln!(
"Warning: Failed to parse app config {} ({}). Falling back to desktop entry metadata.",
path.display(),
err
);
Ok(None)
}
}
}
fn write_app_config_from_args(args: &BuildArgs) -> Result<()> {
validate_remove_id(&args.internal_id)?;
let path = app_config_path(&args.internal_id)?;
if let Some(dir) = path.parent() {
fs::create_dir_all(dir).context("Failed to create app config directory")?;
}
let cfg = DeskifyAppConfig {
schema_version: 1,
id: args.internal_id.clone(),
name: args.name.clone(),
url: args.url.clone(),
backend: args.backend,
browser_bin: args.browser_bin.clone(),
profile_scope: args.profile_scope,
fullscreen: args.fullscreen,
no_decorations: args.no_decorations,
user_agent: args.user_agent.clone(),
width: args.width,
height: args.height,
dark_mode: args.dark_mode,
};
fs::write(
&path,
serde_json::to_string_pretty(&cfg).context("Failed to serialize app config")?,
)
.with_context(|| format!("Failed to write app config {}", path.display()))?;
Ok(())
}
fn remove_app_config(id: &str) -> Result<()> {
let path = app_config_path(id)?;
if path.exists() {
fs::remove_file(&path).with_context(|| format!("Failed to remove {}", path.display()))?;
println!("Removed app config: {:?}", path);
}
Ok(())
}
fn build_tauri_config_value(args: &BuildArgs, safe_identifier: &str, bundle_active: bool) -> Value {
let mut window_config = Map::<String, Value>::new();
window_config.insert("title".to_string(), json!(args.name));
@@ -300,10 +405,37 @@ fn find_binary_in_path(name: &str) -> Option<PathBuf> {
None
}
fn chromium_binary_works(path: &Path) -> Result<()> {
let output = Command::new(path)
.arg("--version")
.output()
.with_context(|| format!("Failed to execute browser binary {}", path.display()))?;
if output.status.success() {
return Ok(());
}
let stderr = String::from_utf8_lossy(&output.stderr).trim().to_string();
let stdout = String::from_utf8_lossy(&output.stdout).trim().to_string();
let details = if !stderr.is_empty() {
stderr
} else if !stdout.is_empty() {
stdout
} else {
format!("exit code {}", output.status)
};
Err(anyhow!(
"Browser binary exists but failed to run: {} ({})",
path.display(),
details
))
}
fn resolve_chromium_binary(explicit: Option<&str>) -> Result<PathBuf> {
if let Some(path) = explicit {
let candidate = PathBuf::from(path);
if candidate.is_file() {
chromium_binary_works(&candidate).with_context(|| {
"The specified browser binary does not appear to be usable. If it's a wrapper script, ensure the underlying browser exists."
})?;
return Ok(candidate);
}
return Err(anyhow!(
@@ -313,7 +445,9 @@ fn resolve_chromium_binary(explicit: Option<&str>) -> Result<PathBuf> {
}
for candidate in chromium_candidates() {
if let Some(path) = find_binary_in_path(candidate) {
if let Some(path) = find_binary_in_path(candidate)
&& chromium_binary_works(&path).is_ok()
{
return Ok(path);
}
}
@@ -838,7 +972,7 @@ X-Deskify-Browser={}
Ok(())
}
fn list_apps() -> Result<()> {
fn list_apps_with_options(verbose: bool) -> Result<()> {
let base_dirs = BaseDirs::new().ok_or_else(|| anyhow!("Could not find system BaseDirs"))?;
let applications_dir = base_dirs.data_local_dir().join("applications");
@@ -871,10 +1005,38 @@ fn list_apps() -> Result<()> {
.and_then(|l| l.strip_prefix("X-Deskify-Backend="))
.unwrap_or("legacy");
println!(
"- {} (Internal ID: {}, Backend: {})",
name, internal_id, backend
);
if verbose && validate_remove_id(internal_id).is_ok() {
if let Some(cfg) = read_app_config(internal_id)? {
println!(
"- {} (Internal ID: {}, Backend: {}, URL: {})",
name,
internal_id,
backend_str(cfg.backend),
cfg.url
);
} else {
let url = content
.lines()
.find(|l| l.starts_with("X-Deskify-URL="))
.and_then(|l| l.strip_prefix("X-Deskify-URL="));
if let Some(url) = url {
println!(
"- {} (Internal ID: {}, Backend: {}, URL: {})",
name, internal_id, backend, url
);
} else {
println!(
"- {} (Internal ID: {}, Backend: {})",
name, internal_id, backend
);
}
}
} else {
println!(
"- {} (Internal ID: {}, Backend: {})",
name, internal_id, backend
);
}
found = true;
}
}
@@ -887,6 +1049,29 @@ fn list_apps() -> Result<()> {
Ok(())
}
fn read_desktop_entry_value(id: &str, key: &str) -> Result<Option<String>> {
validate_remove_id(id)?;
let base_dirs = BaseDirs::new().ok_or_else(|| anyhow!("Could not find system BaseDirs"))?;
let desktop_path = base_dirs
.data_local_dir()
.join("applications")
.join(format!("{}.desktop", id));
if !desktop_path.exists() {
return Ok(None);
}
let content = fs::read_to_string(&desktop_path)
.with_context(|| format!("Failed to read desktop entry {}", desktop_path.display()))?;
if !is_deskify_desktop_entry(&content) {
return Ok(None);
}
let prefix = format!("{}=", key);
Ok(content
.lines()
.find(|line| line.starts_with(&prefix))
.and_then(|line| line.strip_prefix(&prefix))
.map(str::to_string))
}
fn read_installed_app_display_name(id: &str) -> Result<Option<String>> {
validate_remove_id(id)?;
let base_dirs = BaseDirs::new().ok_or_else(|| anyhow!("Could not find system BaseDirs"))?;
@@ -984,6 +1169,9 @@ fn run_doctor() -> Result<()> {
println!("[info] executable dir: {}", executable_dir.display());
println!("[info] applications dir: {}", applications_dir.display());
println!("[info] icons dir: {}", icons_dir.display());
if let Ok(exe) = env::current_exe() {
println!("[info] deskify path: {}", exe.display());
}
if failed {
Err(anyhow!("Doctor found critical issues"))
@@ -1053,6 +1241,7 @@ fn remove_app_with_options(safe_name: &str, remove_profile: bool) -> Result<()>
}
println!("Successfully removed app '{}'.", safe_name);
let _ = remove_app_config(safe_name);
Ok(())
}
@@ -1087,6 +1276,7 @@ fn execute_build(args: &BuildArgs, dry_run: bool, print_config: bool) -> Result<
};
install_tauri_app(args, &bin_path, dir.path())?;
write_app_config_from_args(args)?;
Ok(())
}
Backend::Chromium => {
@@ -1094,7 +1284,9 @@ fn execute_build(args: &BuildArgs, dry_run: bool, print_config: bool) -> Result<
"Installing Chromium app '{}' for URL: {}",
args.name, args.url
);
install_chromium_app(args)
install_chromium_app(args)?;
write_app_config_from_args(args)?;
Ok(())
}
}
}
@@ -1162,8 +1354,8 @@ fn main() -> Result<()> {
};
execute_build(&args, dry_run, print_config)?;
}
Commands::List => {
list_apps()?;
Commands::List { verbose } => {
list_apps_with_options(verbose)?;
}
Commands::Doctor => {
run_doctor()?;
@@ -1188,25 +1380,84 @@ fn main() -> Result<()> {
dry_run,
print_config,
} => {
let existing_cfg = read_app_config(&id)?;
let resolved_url = if let Some(url) = url {
url
} else if let Some(cfg) = &existing_cfg {
cfg.url.clone()
} else if let Some(url) = read_desktop_entry_value(&id, "X-Deskify-URL")? {
url
} else {
return Err(anyhow!(
"Missing --url for update. Provide --url or rebuild once with a recent Deskify version so metadata can be persisted."
));
};
let resolved_name = if let Some(name) = name {
name
} else if let Some(cfg) = &existing_cfg {
cfg.name.clone()
} else {
read_installed_app_display_name(&id)?.unwrap_or_else(|| id.clone())
};
let resolved_backend = if let Some(backend) = backend {
backend
} else if let Some(cfg) = &existing_cfg {
cfg.backend
} else if let Some(b) = read_desktop_entry_value(&id, "X-Deskify-Backend")? {
match b.as_str() {
"chromium" => Backend::Chromium,
"tauri" => Backend::Tauri,
_ => Backend::Tauri,
}
} else {
Backend::Tauri
};
let resolved_profile_scope = if let Some(scope) = profile_scope {
scope
} else if let Some(cfg) = &existing_cfg {
cfg.profile_scope
} else {
ProfileScope::Isolated
};
let resolved_user_agent = if user_agent.is_some() {
user_agent
} else {
existing_cfg.as_ref().and_then(|c| c.user_agent.clone())
};
let resolved_width = width.or_else(|| existing_cfg.as_ref().and_then(|c| c.width));
let resolved_height = height.or_else(|| existing_cfg.as_ref().and_then(|c| c.height));
let resolved_browser_bin =
browser_bin.or_else(|| existing_cfg.as_ref().and_then(|c| c.browser_bin.clone()));
let resolved_fullscreen =
fullscreen.unwrap_or(existing_cfg.as_ref().map(|c| c.fullscreen).unwrap_or(false));
let resolved_no_decorations = no_decorations.unwrap_or(
existing_cfg
.as_ref()
.map(|c| c.no_decorations)
.unwrap_or(false),
);
let resolved_dark_mode =
dark_mode.unwrap_or(existing_cfg.as_ref().map(|c| c.dark_mode).unwrap_or(false));
let args = BuildArgs {
url,
url: resolved_url,
name: resolved_name,
internal_id: id.clone(),
icon,
fullscreen,
no_decorations,
user_agent,
width,
height,
dark_mode,
backend,
browser_bin,
profile_scope,
fullscreen: resolved_fullscreen,
no_decorations: resolved_no_decorations,
user_agent: resolved_user_agent,
width: resolved_width,
height: resolved_height,
dark_mode: resolved_dark_mode,
backend: resolved_backend,
browser_bin: resolved_browser_bin,
profile_scope: resolved_profile_scope,
};
execute_update(&id, &args, dry_run, print_config)?;
}
@@ -1222,6 +1473,8 @@ mod tests {
is_deskify_desktop_entry, sanitize_app_id, validate_remove_id,
};
use std::path::Path;
use std::{fs, os::unix::fs::PermissionsExt};
use tempfile::tempdir;
#[test]
fn sanitize_app_id_replaces_spaces_and_strips_symbols() {
@@ -1312,4 +1565,26 @@ mod tests {
assert!(exec.contains("--force-dark-mode"));
assert!(exec.contains("--user-agent="));
}
#[test]
fn profile_scope_accepts_default_alias() {
let scope: ProfileScope = serde_json::from_str("\"default\"").unwrap();
assert_eq!(scope, ProfileScope::Isolated);
}
#[test]
fn resolve_chromium_binary_rejects_broken_explicit_path() {
let dir = tempdir().unwrap();
let script = dir.path().join("broken-browser");
fs::write(&script, "#!/bin/sh\nexit 1\n").unwrap();
let mut perms = fs::metadata(&script).unwrap().permissions();
perms.set_mode(0o755);
fs::set_permissions(&script, perms).unwrap();
let err = super::resolve_chromium_binary(Some(script.to_str().unwrap()))
.err()
.unwrap()
.to_string();
assert!(err.contains("failed to run") || err.contains("does not appear to be usable"));
}
}