import os
import subprocess
import ctypes
def create_folder(path: str):
try:
os.makedirs(path, exist_ok=True)
return {"status": "success", "message": f"Folder created: {path}"}
except Exception as e:
return {"status": "error", "message": str(e)}
def open_app(app_name: str):
try:
subprocess.Popen(app_name)
return {"status": "success", "message": f"Opened: {app_name}"}
except Exception as e:
return {"status": "error", "message": str(e)}
def set_wallpaper(image_path: str):
try:
ctypes.windll.user32.SystemParametersInfoW(20, 0, image_path, 3)
return {"status": "success", "message": "Wallpaper changed"}
except Exception as e:
return {"status": "error", "message": str(e)}
def list_wallpapers(folder_path: str):
try:
files = os.listdir(folder_path)
wallpapers = [f for f in files if f.lower().endswith((".jpg", ".png", ".bmp"))]
wallpapers.sort()
return {"status": "success", "wallpapers": wallpapers}
except Exception as e:
return {"status": "error", "message": str(e)}
def set_wallpaper_by_index(folder_path: str, index: int):
try:
wallpapers = [f for f in os.listdir(folder_path) if f.lower().endswith((".jpg", ".png", ".bmp"))]
wallpapers.sort()
if index < 1 or index > len(wallpapers):
return {"status": "error", "message": "Index out of range"}
image_path = os.path.join(folder_path, wallpapers[index - 1])
ctypes.windll.user32.SystemParametersInfoW(20, 0, image_path, 3)
return {"status": "success", "message": f"Wallpaper set: {wallpapers[index - 1]}"}
except Exception as e:
return {"status": "error", "message": str(e)}
def shutdown_pc():
try:
os.system("shutdown /s /t 5")
return {"status": "success", "message": "Shutdown initiated"}
except Exception as e:
return {"status": "error", "message": str(e)}