DEV Community

Chinmay Danodiya
Chinmay Danodiya

Posted on

I made freedos but on terminal, for android users , termux

To run my freedos 1.1 copy this and past it in terminal:-
cat << 'EOF' > start-dos.sh

!/bin/bash

--- 1. Clean up old runs ---

pkill -f qemu-system-i386
pkill -f python
clear

--- 2. Menu ---

echo "================================================"
echo " FREEDOS SUPREME BOOT SELECTOR"
echo "================================================"
echo " 1) HD Character Engine (Half-Blocks + Color)"
echo " 2) Ncurses (Native Terminal Mode)"
echo " 3) VNC Server (Port 5900)"
echo " 4) NoVNC (Web Browser Mode)"
echo " 5) X11 Mode (Requires Termux:X11)"
echo "------------------------------------------------"
printf "Select Display Mode [1-5]: "
read mode

Ensure mode is trimmed

mode=$(echo $mode | tr -d '[:space:]')

--- 3. The HD Engine with Mouse & Touch Mapping ---

cat << 'PY_EOF' > hd_engine.py
import os, sys, time, io, subprocess
from PIL import Image

def get_ansi(r, g, b):
return 16 + (36 * (r // 51)) + (6 * (g // 51)) + (b // 51)

def start_engine():
# Hide cursor, enter alt buffer
sys.stdout.write("\033[?1049h\033[?25l")
sys.stdout.flush()

# Simple Mouse Input Handling (Captures touch/click via ANSI sequences)
# Note: QEMU tablet mode maps touch to absolute coordinates
sys.stdout.write("\033[?1000h\033[?1006h") 
sys.stdout.flush()

while True:
    try:
        # Capture VNC to Memory (QEMU background process)
        subprocess.run(["vncdotool", "-s", "127.0.0.1:0", "capture", "vga.png"], 
                       capture_output=True)

        if not os.path.exists("vga.png"):
            time.sleep(0.5)
            continue

        img = Image.open("vga.png").convert('RGB')
        cols, rows = os.get_terminal_size()

        # HD Scaling: 2 pixels per character height
        img = img.resize((cols, rows * 2), Image.NEAREST)
        pix = img.load()

        buf = io.StringIO()
        buf.write("\033[H") 

        for y in range(0, img.size[1] - 1, 2):
            line = []
            for x in range(img.size[0]):
                r1, g1, b1 = pix[x, y]
                r2, g2, b2 = pix[x, y+1]
                c1 = get_ansi(r1, g1, b1)
                c2 = get_ansi(r2, g2, b2)
                line.append(f"\033[38;5;{c1};48;5;{c2}mâ–€")
            buf.write("".join(line))

        sys.stdout.write(buf.getvalue())
        sys.stdout.flush()
    except Exception:
        time.sleep(1)
Enter fullscreen mode Exit fullscreen mode

if name == "main":
try:
start_engine()
except KeyboardInterrupt:
# Cleanup: Show cursor, exit alt buffer, disable mouse
sys.stdout.write("\033[?1000l\033[?1006l\033[?1049l\033[?25h\033[0m")
sys.stdout.flush()
PY_EOF

--- 4. Execution Logic ---

echo "[*] Checking Engine Components..."
pkg install qemu-system-x86-headless python -y > /dev/null 2>&1
pip install vncdotool pillow > /dev/null 2>&1

Common QEMU flags for better mobile experience

Q_OPTS="-m 256M -hda freedos.img -cdrom FD13LIVE.iso -rtc base=localtime -usb -device usb-tablet"

case "$mode" in
1)
echo "[+] Booting HD Engine..."
qemu-system-i386 $Q_OPTS -vga std -vnc :0 &
sleep 3
python hd_engine.py
;;
2)
echo "[+] Booting Ncurses Mode..."
qemu-system-i386 $Q_OPTS -display curses
;;
3)
echo "[+] VNC Server active on :5900"
qemu-system-i386 $Q_OPTS -vnc :0
;;
4)
echo "[+] Launching NoVNC..."
pkg install novnc -y > /dev/null 2>&1
qemu-system-i386 $Q_OPTS -vnc :0 &
sleep 2
novnc_proxy --vnc localhost:5900
;;
5)
echo "[+] Booting X11..."
qemu-system-i386 $Q_OPTS -vga virtio -display x11
;;
*)
echo "[!] Error: Invalid selection ($mode). Please enter 1-5."
;;
esac
EOF
chmod +x start-dos.sh
./start-dos.sh

To again start it , run
./start-dos.sh

Top comments (0)