chore: starting fixes (#60)

* feat: add temporary directory for tray icon to avoid permission issues

* fix: enhance uninstall process to remove all installation traces

* chore: prevents user overriding tray backend

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>

---------

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
This commit is contained in:
Gustavo Carvalho
2025-12-24 13:39:11 -03:00
committed by GitHub
parent 67c8cd4244
commit 1e9a54f5ab
3 changed files with 28 additions and 2 deletions

View File

@@ -290,16 +290,35 @@ uninstall:
@echo -e "$(CYAN)Uninstalling $(APP_NAME)...$(RESET)"
@# Stop any running instances first
@if [ -n "$$SUDO_USER" ]; then \
pkill -u $$SUDO_USER -f "$(APP_NAME)-bin" 2>/dev/null || true; \
pkill -u $$SUDO_USER -x "$(APP_NAME)-bin" 2>/dev/null || true; \
fi
@pkill -f "$(APP_NAME)-bin" 2>/dev/null || true
@pkill -x "$(APP_NAME)-bin" 2>/dev/null || true
@# Remove from specified PREFIX path
rm -f $(DESTDIR)$(BINDIR)/$(APP_NAME)
rm -rf $(DESTDIR)$(LIBDIR)/$(APP_NAME)
@# Also clean up common installation paths (in case installed with different PREFIX)
@if [ "$(BINDIR)" != "/usr/local/bin" ]; then \
rm -f $(DESTDIR)/usr/local/bin/$(APP_NAME) 2>/dev/null || true; \
rm -rf $(DESTDIR)/usr/local/lib/$(APP_NAME) 2>/dev/null || true; \
fi
@if [ "$(BINDIR)" != "/usr/bin" ]; then \
rm -f $(DESTDIR)/usr/bin/$(APP_NAME) 2>/dev/null || true; \
rm -rf $(DESTDIR)/usr/lib/$(APP_NAME) 2>/dev/null || true; \
fi
rm -f $(DESTDIR)$(DATADIR)/icons/hicolor/128x128/apps/$(APP_NAME).png
rm -f $(DESTDIR)$(DATADIR)/icons/hicolor/256x256/apps/$(APP_NAME).png
rm -f $(DESTDIR)$(DATADIR)/applications/$(APP_NAME).desktop
@# Clean icons from all common share paths
rm -f $(DESTDIR)/usr/local/share/icons/hicolor/128x128/apps/$(APP_NAME).png 2>/dev/null || true
rm -f $(DESTDIR)/usr/local/share/icons/hicolor/256x256/apps/$(APP_NAME).png 2>/dev/null || true
rm -f $(DESTDIR)/usr/share/icons/hicolor/128x128/apps/$(APP_NAME).png 2>/dev/null || true
rm -f $(DESTDIR)/usr/share/icons/hicolor/256x256/apps/$(APP_NAME).png 2>/dev/null || true
@# Clean desktop entries from all common paths
rm -f $(DESTDIR)/usr/local/share/applications/$(APP_NAME).desktop 2>/dev/null || true
rm -f $(DESTDIR)/usr/share/applications/$(APP_NAME).desktop 2>/dev/null || true
rm -f $(DESTDIR)/etc/udev/rules.d/99-win11-clipboard-input.rules
rm -f $(DESTDIR)/etc/modules-load.d/uinput.conf
rm -f $(DESTDIR)/etc/modules-load.d/win11-clipboard.conf
@# Remove autostart entry for the user
@if [ -n "$$SUDO_USER" ]; then \
AUTOSTART_FILE=$$(getent passwd $$SUDO_USER | cut -d: -f6)/.config/autostart/$(APP_NAME).desktop; \

View File

@@ -54,5 +54,6 @@ exec env -i \
GDK_BACKEND="x11" \
GDK_SCALE="${GDK_SCALE:-1}" \
GDK_DPI_SCALE="${GDK_DPI_SCALE:-1}" \
TAURI_TRAY="${TAURI_TRAY:-libayatana-appindicator3}" \
NO_AT_BRIDGE=1 \
"$BINARY" "$@"

View File

@@ -630,8 +630,14 @@ fn main() {
let icon = Image::from_bytes(include_bytes!("../icons/icon.png")).unwrap();
// Get temp directory for tray icon (avoids permission issues with XDG_RUNTIME_DIR)
let temp_dir = std::env::temp_dir().join("win11-clipboard-history");
std::fs::create_dir_all(&temp_dir).ok();
let _tray = TrayIconBuilder::new()
.icon(icon)
.tooltip("Clipboard History")
.temp_dir_path(temp_dir)
.menu(&menu)
.on_menu_event(move |app, event| match event.id.as_ref() {
"quit" => app.exit(0),