Python

Before installing the tool, make sure Python 3 is installed on your computer.

To check, open your terminal and tun:

python –version

If Python is installed, the version number will appear.

 

Saving the Code

To use the tool, copy the code below and save it in a file named:

main.py

You can use any text editor (for example Visual Studio Code or a simple text editor).

For easier access, you may want to save the file in your user/home folder, but any location on your computer will work.

 

Starting the Tool

Open your terminal and navigate to the folder where you saved the file:

cd path/to/your/folder

Then run:

python3 main.py

If you saved the file in your user/home folder, you can simply run:

python3 main.py

code copy
import datetime
import os
import time
import select
import sys

DAILY_FILE = "daily.txt"
HABIT_FILE = "habits_2026.txt"
GOAL_FILE = "goals_2026.txt"

IDENTITY_HABITS = ["twg", "vis", "train", "prod", "social"]

# =========================
# DAILY LOAD / SAVE
# =========================

def load_daily():
    today = str(datetime.date.today())

    if not os.path.exists(DAILY_FILE):
        return new_daily(today)

    with open(DAILY_FILE) as f:
        parts = f.read().strip().split("|")

    if len(parts) != 7 or parts[0] != today:
        return new_daily(today)

    return {
        "date": parts[0],
        "t1": parts[1],
        "t2": parts[2],
        "t3": parts[3],
        "text1": parts[4],
        "text2": parts[5],
        "text3": parts[6],
    }

def new_daily(today):
    return {
        "date": today,
        "t1": "0",
        "t2": "0",
        "t3": "0",
        "text1": "",
        "text2": "",
        "text3": ""
    }

def save_daily(d):
    with open(DAILY_FILE, "w") as f:
        f.write(
            f"{d['date']}|{d['t1']}|{d['t2']}|{d['t3']}|"
            f"{d['text1']}|{d['text2']}|{d['text3']}"
        )

# =========================
# HABITS 2026
# =========================

def load_habits():
    data = {}
    if not os.path.exists(HABIT_FILE):
        return data

    with open(HABIT_FILE) as f:
        for line in f:
            parts = line.strip().split("|")
            if len(parts) == 6:
                data[parts[0]] = list(map(int, parts[1:]))
    return data

def save_habits(data):
    with open(HABIT_FILE, "w") as f:
        for date in sorted(data.keys()):
            f.write(date + "|" + "|".join(map(str, data[date])) + "\n")

# =========================
# GOAL DATES
# =========================

def load_goals():
    if not os.path.exists(GOAL_FILE):
        return set()
    with open(GOAL_FILE) as f:
        return set(f.read().splitlines())

def save_goals(goals):
    with open(GOAL_FILE, "w") as f:
        for g in goals:
            f.write(g + "\n")

# =========================
# HEATMAP
# =========================

def color_block(score, date_str, goals):
    if date_str in goals:
        return "\033[38;5;45m█\033[0m"

    if score == 0:
        return "\033[38;5;240m░\033[0m"
    elif score == 1:
        return "\033[38;5;160m▒\033[0m"
    elif score == 2:
        return "\033[38;5;208m▒\033[0m"
    elif score == 3:
        return "\033[38;5;220m▓\033[0m"
    elif score == 4:
        return "\033[38;5;118m▓\033[0m"
    else:
        return "\033[38;5;34m█\033[0m"

def print_heatmap(data, goals):
    start = datetime.date(2026, 1, 1)
    end = datetime.date(2026, 12, 31)

    while start.weekday() != 0:
        start -= datetime.timedelta(days=1)

    current = start
    weeks = []

    while current <= end:
        week = []
        for _ in range(7):
            week.append(current)
            current += datetime.timedelta(days=1)
        weeks.append(week)

    print("\n")

    for row in range(7):
        for week in weeks:
            day = week[row]
            if day.year == 2026:
                date_str = str(day)
                score = sum(data.get(date_str, [0]*5))
                print(color_block(score, date_str, goals), end=" ")
            else:
                print(" ", end=" ")
        print()

# =========================
# HEATMAP ONLY SCREEN
# =========================

def heatmap_screen(habits, goals):
    print("\033[2J\033[3J\033[H", end="")
    print_heatmap(habits, goals)
    input("\n")

# =========================
# FOCUS TIMER
# =========================

def focus_timer(minutes):
    end_time = time.time() + minutes * 60

    while True:
        remaining = int(end_time - time.time())

        if remaining <= 0:
            print("\033[2J\033[3J\033[H", end="")
            print("00:00 focus left")

            # Starkes Audio-Signal
            for _ in range(8):
                print("\a", end="", flush=True)
                time.sleep(0.3)

            time.sleep(1)
            return

        mins = remaining // 60
        secs = remaining % 60

        print("\033[2J\033[3J\033[H", end="")
        print(f"{mins:02d}:{secs:02d} focus left")

        if sys.stdin in select.select([sys.stdin], [], [], 1)[0]:
            command = sys.stdin.readline().strip()
            if command == "give up":
                return

# =========================
# MAIN LOOP
# =========================

while True:

    print("\033[2J\033[3J\033[H", end="")

    today = datetime.date.today()
    today_str = str(today)

    daily = load_daily()
    habits = load_habits()
    goals = load_goals()

    if today_str not in habits:
        habits[today_str] = [0,0,0,0,0]

    print("\033[1;93mBreak the pattern today or the loop will repeat tomorrow.\033[0m\n")

    training = [
        "INTERVALS BIKE/RUN",
        "FOUNDATION + STRIDES",
        "STRENGTH LEGS",
        "LONGRUN",
        "LOW STRESS",
        "BIKE INTERVALS",
        "FOUNDATION BIKE"
    ]

    print(f"\033[1;38;5;39m{training[today.weekday()]}\033[0m\n")

    for i, h in enumerate(IDENTITY_HABITS):
        if habits[today_str][i] == 1:
            print(f"\033[1;38;5;34m✔ {h}\033[0m")
        else:
            print(f"\033[95m• {h}\033[0m")

    print()

    for i in range(1,4):
        text = daily[f"text{i}"] or f"Key Task {i}"
        status = daily[f"t{i}"]

        if status == "1":
            print(f"\033[1;38;5;34m[{i}] {text}\033[0m")
        else:
            print(f"\033[95m[{i}] {text}\033[0m")

    print_heatmap(habits, goals)

    cmd = input("\n").strip()

    if cmd == "exit":
        break

    elif cmd.startswith("check "):
        arg = cmd.split()[1]

        if arg in IDENTITY_HABITS:
            idx = IDENTITY_HABITS.index(arg)
            habits[today_str][idx] ^= 1
            save_habits(habits)

        elif arg.isdigit():
            i = int(arg)
            if 1 <= i <= 3:
                daily[f"t{i}"] = "0" if daily[f"t{i}"]=="1" else "1"
                save_daily(daily)

    elif cmd.startswith("set "):
        parts = cmd.split(" ",2)
        if len(parts)==3 and parts[1].isdigit():
            i = int(parts[1])
            if 1<=i<=3:
                daily[f"text{i}"]=parts[2]
                save_daily(daily)

    elif cmd.startswith("mark "):
        try:
            date_part = cmd.split()[1]
            day, month = map(int, date_part.split("."))
            goal_date = datetime.date(2026, month, day)
            goals.add(str(goal_date))
            save_goals(goals)
        except:
            pass

    elif cmd.startswith("focus "):
        parts = cmd.split()
        if len(parts) == 2 and parts[1].isdigit():
            focus_timer(int(parts[1]))

    elif cmd == "heatmap":
        heatmap_screen(habits, goals)