Files
imajviewer/install.sh
T

119 lines
4.4 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_BASE="${HOME}/.local/share/icons/hicolor"
ICON_SIZES="16 22 24 32 48 64 128 256"
# ── 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")"
# ── 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 (hicolor boyut seti: 16–256) ──
if [ -f "$SCRIPT_DIR/imajviewericon.png" ]; then
info "İkon boyutları üretiliyor (16–256)…"
for s in $ICON_SIZES; do
d="${ICON_BASE}/${s}x${s}/apps"
mkdir -p "$d"
python3 -c "
from PIL import Image
im = Image.open('$SCRIPT_DIR/imajviewericon.png')
(im if $s == 256 else im.resize(($s, $s), Image.LANCZOS)).save('$d/${APP}.png')
" || err "İkon dönüştürme başarısız! ($s)"
done
ok "İkon: ${ICON_BASE} (${ICON_SIZES} px)"
else
err "imajviewericon.png bulunamadı!"
fi
# ── Hicolor tema indeksi (GTK ikon temasını tanısın) ──
{
echo "[Icon Theme]"
echo "Name=Hicolor"
echo "Comment=Fallback icon theme"
dirs=""
for s in $ICON_SIZES; do dirs="${dirs:+$dirs,}${s}x${s}/apps"; done
echo "Directories=$dirs"
for s in $ICON_SIZES; do
echo ""
echo "[${s}x${s}/apps]"
echo "Size=$s"
echo "Context=Applications"
echo "Type=Fixed"
done
} > "${ICON_BASE}/index.theme"
# ── .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\" && rm -f ${ICON_BASE}/*x*/apps/${APP}.png"