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

import subprocess
import signal
from pathlib import Path

AUTOSTART_DST = Path.home() / '.config' / 'autostart' / 'litewidget.desktop'

# Kill the widget overlay process
try:
    result = subprocess.run(
        ['pgrep', '-f', 'lite-widget-overlay'],
        capture_output=True, text=True
    )
    for pid in result.stdout.strip().split('\n'):
        if pid:
            try:
                subprocess.run(['kill', pid])
            except Exception:
                pass
except Exception:
    pass

# Remove autostart file
try:
    AUTOSTART_DST.unlink(missing_ok=True)
except Exception:
    pass
