#!/bin/sh
# mhmt-config-fastfetch: Konsole'da metin logosu yerine resim logosu.
# fastfetch yapılandırması terminale göre koşul taşımaz; asıl program
# /usr/bin/fastfetch.distrib'e dpkg-divert ile alınmıştır.
real=/usr/bin/fastfetch.distrib
image=/usr/share/mhmt/fastfetch/logo.kitty

# Konsole dışı, tmux/screen içi (resim protokolü iletilmez), çıktı terminal değil
# ya da kullanıcının kendi yapılandırması varsa dokunulmaz.
[ -n "${KONSOLE_VERSION:-}" ] && [ -z "${TMUX:-}" ] && [ -z "${STY:-}" ] && [ -t 1 ] \
    && [ -r "$image" ] \
    && [ ! -e "${XDG_CONFIG_HOME:-$HOME/.config}/fastfetch/config.jsonc" ] \
    && [ ! -e "${XDG_CONFIG_HOME:-$HOME/.config}/fastfetch/config.json" ] \
    || exec "$real" "$@"

# Logoyu ya da yapılandırmayı komut satırında seçen çağrılar olduğu gibi geçer.
for arg in "$@"; do
    case "$arg" in
        -l|--logo*|-c|--config|--load-config|--file*|--data*|--raw|--sixel|--kitty*|--iterm|--chafa|--pipe*|-h|--help*|-v|--version|--gen-config*|--list-*|--print-*)
            exec "$real" "$@" ;;
    esac
done

# PNG gömülü kitty grafik dizisi (build'de üretilir). Hücre 1:2 oranında, 24x12 logoyu
# kare tutar; boyut dizideki c/r ile aynı olmalı (debian/rules).
exec "$real" --logo-type raw --logo "$image" --logo-width 24 --logo-height 12 "$@"
