#!/usr/bin/env python3
#--------------------------------------------
# Description: Lite Widget - Enable
# Authors: Jerry Bezencon
# Website: https://www.linuxliteos.com
# License: GPLv2
#--------------------------------------------

import subprocess
import shutil
from pathlib import Path

AUTOSTART_SRC = Path('/etc/xdg/autostart/litewidget.desktop')
AUTOSTART_DIR = Path.home() / '.config' / 'autostart'
AUTOSTART_DST = AUTOSTART_DIR / 'litewidget.desktop'

# Start the widget overlay
subprocess.Popen(['/etc/lite-widget/start'])

# Set up autostart for login
AUTOSTART_DIR.mkdir(parents=True, exist_ok=True)
shutil.copy2(AUTOSTART_SRC, AUTOSTART_DST)

# Enable autostart (change Hidden=true to Hidden=false)
content = AUTOSTART_DST.read_text()
content = content.replace('Hidden=true', 'Hidden=false')
AUTOSTART_DST.write_text(content)
