#!/usr/bin/env python3
"""
set_disable_background_apps.py

Disable Background Apps Globally.
Prevents Store apps from running in the background to save resources and battery.

Usage:
    python set_disable_background_apps.py
"""

import winreg


def main() -> None:
    key = winreg.CreateKeyEx(
        winreg.HKEY_CURRENT_USER, r"Software\Microsoft\Windows\CurrentVersion\BackgroundAccessApplications", 0, winreg.KEY_SET_VALUE
    )
    winreg.SetValueEx(key, "GlobalUserDisabled", 0, winreg.REG_DWORD, 1)
    winreg.CloseKey(key)
    print("Disable Background Apps Globally applied.")


if __name__ == "__main__":
    main()