Optimize tray startup disk write and clean up settings UI targets in Makefile

This commit is contained in:
vndangkhoa 2026-06-24 20:45:23 +07:00
parent 9f09af63e0
commit 0e79c05df3
2 changed files with 10 additions and 18 deletions

View file

@ -1,4 +1,4 @@
.PHONY: build build-x11 build-wayland build-all build-ui build-tray test test-cli run run-x11 run-wayland clean install install-x11 install-wayland install-ui install-tray install-all-ui install-config appimage fmt lint tree .PHONY: build build-x11 build-wayland build-all build-ui test test-cli run run-x11 run-wayland clean install install-x11 install-wayland install-ui install-config appimage fmt lint tree
# Build core crates # Build core crates
build: build:
@ -16,13 +16,9 @@ build-wayland:
build-all: build-all:
cargo build --release --features "x11,wayland" cargo build --release --features "x11,wayland"
# Build settings UI (requires GTK4 + libadwaita) # Build tray icon UI (requires libdbus-1-dev)
build-ui: build-ui:
cd ui && cargo build --release --bin vietc-settings cd ui && cargo build --release
# Build tray icon app (requires libdbus-1-dev)
build-tray:
cd ui && cargo build --release --bin vietc-tray
# Build debug # Build debug
build-dev: build-dev:
@ -69,19 +65,11 @@ install-wayland: build-wayland
sudo cp target/release/vietc /usr/local/bin/vietc sudo cp target/release/vietc /usr/local/bin/vietc
@echo "Installed vietc (with Wayland IM) to /usr/local/bin/" @echo "Installed vietc (with Wayland IM) to /usr/local/bin/"
# Install settings UI # Install tray icon UI
install-ui: build-ui install-ui: build-ui
sudo cp ui/target/release/vietc-settings /usr/local/bin/vietc-settings
@echo "Installed vietc-settings to /usr/local/bin/"
# Install tray icon app
install-tray: build-tray
sudo cp ui/target/release/vietc-tray /usr/local/bin/vietc-tray sudo cp ui/target/release/vietc-tray /usr/local/bin/vietc-tray
@echo "Installed vietc-tray to /usr/local/bin/" @echo "Installed vietc-tray to /usr/local/bin/"
# Install all UI binaries
install-all-ui: install-ui install-tray
# Install config to user dir # Install config to user dir
install-config: install-config:
mkdir -p ~/.config/vietc mkdir -p ~/.config/vietc

View file

@ -32,15 +32,19 @@ fn ensure_icons() {
let vn_path = icons_dir.join("vietc-vn.svg"); let vn_path = icons_dir.join("vietc-vn.svg");
let en_path = icons_dir.join("vietc-en.svg"); let en_path = icons_dir.join("vietc-en.svg");
if !vn_path.exists() {
let _ = std::fs::write(&vn_path, r##"<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32"> let _ = std::fs::write(&vn_path, r##"<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32">
<rect x="2" y="2" width="28" height="28" rx="6" fill="#e02424"/> <rect x="2" y="2" width="28" height="28" rx="6" fill="#e02424"/>
<text x="16" y="22" text-anchor="middle" fill="#ffffff" font-size="14" font-weight="900" font-family="system-ui, sans-serif">VN</text> <text x="16" y="22" text-anchor="middle" fill="#ffffff" font-size="14" font-weight="900" font-family="system-ui, sans-serif">VN</text>
</svg>"##); </svg>"##);
}
if !en_path.exists() {
let _ = std::fs::write(&en_path, r##"<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32"> let _ = std::fs::write(&en_path, r##"<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32">
<rect x="2" y="2" width="28" height="28" rx="6" fill="#4b5563"/> <rect x="2" y="2" width="28" height="28" rx="6" fill="#4b5563"/>
<text x="16" y="22" text-anchor="middle" fill="#ffffff" font-size="14" font-weight="900" font-family="system-ui, sans-serif">EN</text> <text x="16" y="22" text-anchor="middle" fill="#ffffff" font-size="14" font-weight="900" font-family="system-ui, sans-serif">EN</text>
</svg>"##); </svg>"##);
}
} }
struct VietTray { struct VietTray {