Files
imajviewer/install.sh
Alhan 504d84f6f6
Some checks failed
Build & Release / build-linux (push) Has been cancelled
Build & Release / build-windows (push) Has been cancelled
Build & Release / create-release (push) Has been cancelled
feat: i18n (en/tr), zoom orijinal cozunurluk + max 20x + gaplessPlayback, app id com.softmediadesign.imajviewer, CI analyze+test
2026-08-07 00:16:48 +03:00

117 lines
4.2 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
set -euo pipefail
APP=imajviewer
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
BUNDLE_DIR="${SCRIPT_DIR}/build/linux/x64/debug/bundle"
# Debug yoksa release dene
if [ ! -f "$BUNDLE_DIR/${APP}" ]; then
BUNDLE_DIR="${SCRIPT_DIR}/build/linux/x64/release/bundle"
fi
INSTALL_DIR="${HOME}/.local/lib/${APP}"
BIN_LINK="${HOME}/.local/bin/${APP}"
DESKTOP_FILE="${HOME}/.local/share/applications/${APP}.desktop"
ICON_DIR="${HOME}/.local/share/icons/hicolor/64x64/apps"
ICON_FILE="${ICON_DIR}/${APP}.png"
# ── Renkler ──
RED='\033[0;31m'; GREEN='\033[0;32m'; CYAN='\033[0;36m'; NC='\033[0m'
info() { echo -e "${CYAN}${NC} $1"; }
ok() { echo -e "${GREEN}${NC} $1"; }
err() { echo -e "${RED}${NC} $1"; exit 1; }
# ── Ön koşul kontrol ──
command -v xdg-mime >/dev/null 2>&1 || err "xdg-mime bulunamadı (xdg-utils paketi gerekli)"
command -v xdg-desktop-menu >/dev/null 2>&1 || err "xdg-desktop-menu bulunamadı (xdg-utils paketi gerekli)"
if [ ! -f "$BUNDLE_DIR/${APP}" ]; then
info "Binary bulunamadı, Flutter build başlatılıyor…"
cd "$SCRIPT_DIR"
flutter build linux 2>&1 | tail -1 || err "Flutter build başarısız! Sistemde Flutter SDK kurulu olmalı veya dist/imajviewer_*.deb paketini kullanın."
BUNDLE_DIR="${SCRIPT_DIR}/build/linux/x64/debug/bundle"
if [ ! -f "$BUNDLE_DIR/${APP}" ]; then
BUNDLE_DIR="${SCRIPT_DIR}/build/linux/x64/release/bundle"
fi
[ -f "$BUNDLE_DIR/${APP}" ] || err "Build başarısız!"
fi
# ── Kurulum dizinleri ──
mkdir -p "$INSTALL_DIR" "$(dirname "$BIN_LINK")" "$(dirname "$DESKTOP_FILE")" "$ICON_DIR"
# ── Binary + kütüphaneler ──
info "Binary ve kütüphaneler kopyalanıyor…"
cp -r "$BUNDLE_DIR"/* "$INSTALL_DIR/"
chmod +x "$INSTALL_DIR/${APP}"
# ── Symlink ──
ln -sf "$INSTALL_DIR/${APP}" "$BIN_LINK"
ok "Symlink: $BIN_LINK$INSTALL_DIR/${APP}"
# ── İkon (64×64 PNG) ──
if [ ! -f "$ICON_FILE" ]; then
if [ -f "$SCRIPT_DIR/imajviewericon.png" ]; then
info "İkon kopyalanıyor (64x64)…"
python3 -c "
from PIL import Image
im = Image.open('$SCRIPT_DIR/imajviewericon.png')
im.resize((64,64), Image.LANCZOS).save('$ICON_FILE')
" && ok "İkon: $ICON_FILE" || err "İkon dönüştürme başarısız!"
else
err "imajviewericon.png bulunamadı!"
fi
else
ok "İkon zaten mevcut"
fi
# ── Hicolor tema indeksi (GTK ikon temasını tanısın) ──
if [ ! -f "${HOME}/.local/share/icons/hicolor/index.theme" ]; then
mkdir -p "${HOME}/.local/share/icons/hicolor/64x64/apps"
cat > "${HOME}/.local/share/icons/hicolor/index.theme" << 'EOF'
[Icon Theme]
Name=Hicolor
Comment=Fallback icon theme
Directories=64x64/apps
[64x64/apps]
Size=64
Context=Applications
Type=Fixed
EOF
fi
# ── .desktop dosyası ──
info ".desktop dosyası oluşturuluyor…"
cat > "$DESKTOP_FILE" << EOF
[Desktop Entry]
Type=Application
Name=${APP}
Comment=Ultra hafif görüntü izleyici
Exec=${BIN_LINK} %F
Icon=${APP}
Terminal=false
Categories=Graphics;Viewer;RasterGraphics;
MimeType=image/png;image/jpeg;image/webp;image/bmp;image/gif;image/jpg;image/vnd.wap.wbmp;
StartupNotify=false
StartupWMClass=Com.softmediadesign.imajviewer
EOF
ok "${DESKTOP_FILE}"
# ── MIME default ──
info "Varsayılan görüntü izleyici olarak ayarlanıyor…"
for mime in image/png image/jpeg image/jpg image/webp image/bmp image/gif; do
xdg-mime default "${APP}.desktop" "$mime" 2>/dev/null || true
done
# ── Masaüstü veritabanını güncelle ──
which update-desktop-database &>/dev/null && update-desktop-database "${HOME}/.local/share/applications/" 2>/dev/null || true
which gtk-update-icon-cache &>/dev/null && gtk-update-icon-cache "${HOME}/.local/share/icons/hicolor/" 2>/dev/null || true
echo ""
echo -e "${GREEN}══════════════════════════════════════════${NC}"
echo -e "${GREEN} ${APP} kuruldu!${NC}"
echo -e "${GREEN} Bir PNG/JPG/WebP dosyasına çift tıklayın${NC}"
echo -e "${GREEN} veya 'xdg-open <dosya>' ile test edin${NC}"
echo -e "${GREEN}══════════════════════════════════════════${NC}"
echo ""
echo "Kaldırmak için: rm -rf ${INSTALL_DIR} ${BIN_LINK} ${DESKTOP_FILE} ${ICON_FILE}"