Update autocompile.sh

fixed the issue of x11 not starting in full screen. and now it also make the title in the template the file name of the .tex file.
This commit is contained in:
Demircan 2026-09-28 11:28:12 +03:00
parent d1c3006b7f
commit 84536718ce

View file

@ -14,7 +14,10 @@ cleanup_and_push() {
git add *.tex *.py *.ipynb 2>/dev/null git add *.tex *.py *.ipynb 2>/dev/null
[ -f "$PDF_DOSYASI" ] && git add "$PDF_DOSYASI" 2>/dev/null [ -f "$PDF_DOSYASI" ] && git add "$PDF_DOSYASI" 2>/dev/null
# O anki tarih ve saat ile otomatik commit mesajı oluştur # O anki tarih ve saat ile otomatik commit mesajı oluştur
git commit -m "Oto-Kayıt: $(date '+%Y-%m-%d %H:%M:%S')" if git commit -m "Oto-Kayıt: $(date '+%Y-%m-%d %H:%M:%S')"; then
echo "📦 Bu commit'e giren dosyalar:"
git show --stat HEAD
fi
if timeout 10 git push origin main; then if timeout 10 git push origin main; then
echo "✅ Kodlar ve PDF sunucuya başarıyla işlendi!" echo "✅ Kodlar ve PDF sunucuya başarıyla işlendi!"
else else
@ -64,7 +67,12 @@ fi
# 6. TEMPLATE CREATOR # 6. TEMPLATE CREATOR
if [ ! -f "$TEX_DOSYASI" ]; then if [ ! -f "$TEX_DOSYASI" ]; then
echo "📄 '$TEX_DOSYASI' not found. Creating template..." echo "📄 '$TEX_DOSYASI' not found. Creating template..."
cat << 'TEMPLATE' > "$TEX_DOSYASI" # Dosya adından başlık üret: yolu ve .tex uzantısını at, alt çizgiyi boşluğa çevir
BASLIK="${TEX_DOSYASI##*/}"
BASLIK="${BASLIK%.tex}"
BASLIK="${BASLIK//_/ }"
# NOT: Bu heredoc tırnaksız ($BASLIK genişlesin diye). İçine $, ` ya da \\ eklemeyin.
cat << TEMPLATE > "$TEX_DOSYASI"
\documentclass{article} \documentclass{article}
\usepackage{amsmath} \usepackage{amsmath}
\usepackage{amssymb} \usepackage{amssymb}
@ -73,7 +81,7 @@ if [ ! -f "$TEX_DOSYASI" ]; then
\usepackage{hyperref} \usepackage{hyperref}
\geometry{margin=0.1in} \geometry{margin=0.1in}
\title{new paper side notes} \title{$BASLIK paper side notes}
\author{Demircan Demirbağ} \author{Demircan Demirbağ}
\date{\today} \date{\today}
@ -99,16 +107,20 @@ if [ ! -f "$PDF_DOSYASI" ]; then
exit 1 exit 1
fi fi
# 8. OPEN PDF AND MAXIMIZE # 8. OPEN PDF (FULLSCREEN, GENİŞLİĞE SIĞDIR)
evince "$PWD/$PDF_DOSYASI" > /dev/null 2>&1 & # Evince tam ekranı kendisi istesin: wmctrl/xdotool kurulu olmasına ya da zamanlamaya bağlı değil.
sleep 2 # (Çıkmak için Esc veya F11)
if command -v wmctrl > /dev/null; then # Varsayılan zoom modunu %100 yerine "genişliğe sığdır" yap. dconf/dbus olmayan Termux'ta
wmctrl -r "evince" -b add,maximized_vert,maximized_horz # ayar kaybolmasın diye keyfile backend kullanılıyor (~/.config/glib-2.0/settings/keyfile).
elif command -v xdotool > /dev/null; then # NOT: Evince, daha önce açılmış bir PDF için kendi kaydettiği zoom'u kullanır (o dosyada bir kez
xdotool search --name "evince" windowsize --sync 100% 100% # yukarıdaki zoom menüsünden "Fit Width" seç, hatırlar).
fi GSETTINGS_BACKEND=keyfile gsettings set org.gnome.Evince.Default sizing-mode 'fit-width' 2>/dev/null
GSETTINGS_BACKEND=keyfile evince --fullscreen "$PWD/$PDF_DOSYASI" > /dev/null 2>&1 &
# 9. TRIGGER ACODE # 9. TRIGGER ACODE
# Evince penceresi açılsın, sonra Acode öne gelsin (yoksa X11 Acode'un üstüne çıkabiliyor).
# Yine Acode'un arkasında kalıyorsa süreyi artır.
sleep 2
termux-open --content-type "text/x-tex" "$TEX_DOSYASI" termux-open --content-type "text/x-tex" "$TEX_DOSYASI"
echo "==============================================" echo "=============================================="
@ -117,7 +129,10 @@ echo "📂 Working Directory: $PWD"
echo "==============================================" echo "=============================================="
# 10. WATCH LOOP (Aynı bıraktık) # 10. WATCH LOOP (Aynı bıraktık)
while inotifywait -q -e close_write --include '.*\.tex$' -r .; do HEDEF_YOL="$(realpath -m "$TEX_DOSYASI")"
while DEGISEN=$(inotifywait -q -e close_write --format '%w%f' --include '.*\.tex$' -r .); do
# Sadece izlenen dosya kaydedildiyse derle, diğer .tex dosyalarını yoksay
[ "$(realpath -m "$DEGISEN")" = "$HEDEF_YOL" ] || continue
echo "⏳ Saved. Compiling..." echo "⏳ Saved. Compiling..."
pdflatex -interaction=nonstopmode "$TEX_DOSYASI" > compile_log.txt 2>&1 pdflatex -interaction=nonstopmode "$TEX_DOSYASI" > compile_log.txt 2>&1
if grep -q "^!" compile_log.txt; then if grep -q "^!" compile_log.txt; then