Files
Windows-11-Clipboard-Histor…/src-tauri/bundle/linux/wrapper.sh
Gustavo Carvalho 1e9a54f5ab 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>
2025-12-24 13:39:11 -03:00

60 lines
1.9 KiB
Bash
Executable File

#!/bin/bash
# Wrapper for win11-clipboard-history
# Purpose: Clean environment to avoid Snap/Flatpak library conflicts
# and force X11/XWayland for window positioning on Wayland
set -e
BINARY_LOCATIONS=(
"/usr/bin/win11-clipboard-history-bin"
"/usr/lib/win11-clipboard-history/win11-clipboard-history-bin"
"/usr/local/lib/win11-clipboard-history/win11-clipboard-history-bin"
)
# Find the binary
BINARY=""
for loc in "${BINARY_LOCATIONS[@]}"; do
if [ -x "$loc" ]; then
BINARY="$loc"
break
fi
done
# Verify binary was found
if [ -z "$BINARY" ]; then
echo "Error: win11-clipboard-history binary not found." >&2
echo "The wrapper searched for an executable in the following locations (in order):" >&2
for loc in "${BINARY_LOCATIONS[@]}"; do
echo " - $loc" >&2
done
echo "" >&2
echo "If you installed via package manager, try reinstalling the package." >&2
echo "If you installed manually with a custom PREFIX, ensure the binary is in one of the locations above." >&2
exit 1
fi
# Execute with clean environment
# env -i clears ALL environment variables, then we re-export only what's needed
exec env -i \
HOME="$HOME" \
USER="$USER" \
SHELL="$SHELL" \
TERM="$TERM" \
DISPLAY="${DISPLAY:-:0}" \
XAUTHORITY="$XAUTHORITY" \
WAYLAND_DISPLAY="$WAYLAND_DISPLAY" \
XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR" \
XDG_SESSION_TYPE="$XDG_SESSION_TYPE" \
XDG_SESSION_CLASS="$XDG_SESSION_CLASS" \
XDG_CURRENT_DESKTOP="$XDG_CURRENT_DESKTOP" \
XDG_DATA_DIRS="${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" \
DBUS_SESSION_BUS_ADDRESS="$DBUS_SESSION_BUS_ADDRESS" \
PATH="/usr/local/bin:/usr/bin:/bin" \
LANG="${LANG:-en_US.UTF-8}" \
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" "$@"