spothomelight 1.0.1__tar.gz → 1.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (20) hide show
  1. {spothomelight-1.0.1/spothomelight.egg-info → spothomelight-1.0.2}/PKG-INFO +1 -1
  2. {spothomelight-1.0.1 → spothomelight-1.0.2}/pyproject.toml +1 -1
  3. spothomelight-1.0.2/spothomelight/service.py +88 -0
  4. {spothomelight-1.0.1 → spothomelight-1.0.2/spothomelight.egg-info}/PKG-INFO +1 -1
  5. spothomelight-1.0.1/spothomelight/service.py +0 -52
  6. {spothomelight-1.0.1 → spothomelight-1.0.2}/LICENSE +0 -0
  7. {spothomelight-1.0.1 → spothomelight-1.0.2}/README.md +0 -0
  8. {spothomelight-1.0.1 → spothomelight-1.0.2}/setup.cfg +0 -0
  9. {spothomelight-1.0.1 → spothomelight-1.0.2}/spothomelight/__init__.py +0 -0
  10. {spothomelight-1.0.1 → spothomelight-1.0.2}/spothomelight/auth.py +0 -0
  11. {spothomelight-1.0.1 → spothomelight-1.0.2}/spothomelight/config.py +0 -0
  12. {spothomelight-1.0.1 → spothomelight-1.0.2}/spothomelight/core.py +0 -0
  13. {spothomelight-1.0.1 → spothomelight-1.0.2}/spothomelight/main.py +0 -0
  14. {spothomelight-1.0.1 → spothomelight-1.0.2}/spothomelight/utils.py +0 -0
  15. {spothomelight-1.0.1 → spothomelight-1.0.2}/spothomelight/utils_median_cut.py +0 -0
  16. {spothomelight-1.0.1 → spothomelight-1.0.2}/spothomelight.egg-info/SOURCES.txt +0 -0
  17. {spothomelight-1.0.1 → spothomelight-1.0.2}/spothomelight.egg-info/dependency_links.txt +0 -0
  18. {spothomelight-1.0.1 → spothomelight-1.0.2}/spothomelight.egg-info/entry_points.txt +0 -0
  19. {spothomelight-1.0.1 → spothomelight-1.0.2}/spothomelight.egg-info/requires.txt +0 -0
  20. {spothomelight-1.0.1 → spothomelight-1.0.2}/spothomelight.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: spothomelight
3
- Version: 1.0.1
3
+ Version: 1.0.2
4
4
  Summary: Sync Spotify cover color to Home Assistant via Webhook
5
5
  Author-email: "ZGQ Inc." <zgqinc@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/ZGQ-inc/SpotHomeLight
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "spothomelight"
7
- version = "1.0.1"
7
+ version = "1.0.2"
8
8
  description = "Sync Spotify cover color to Home Assistant via Webhook"
9
9
  authors = [
10
10
  { name = "ZGQ Inc.", email = "zgqinc@gmail.com" },
@@ -0,0 +1,88 @@
1
+ import os
2
+ import sys
3
+ import platform
4
+ import subprocess
5
+
6
+ def setup_autostart():
7
+ system = platform.system()
8
+ python_exec = sys.executable
9
+ script_cmd = f'"{python_exec}" -m spothomelight.main'
10
+
11
+ if system == "Linux":
12
+ is_root = (os.geteuid() == 0)
13
+
14
+ if is_root:
15
+ service_dir = "/etc/systemd/system"
16
+ service_file = "spothomelight.service"
17
+ service_path = os.path.join(service_dir, service_file)
18
+ service_content = f"""[Unit]
19
+ Description=SpotHomeLight Service (System)
20
+ After=network.target
21
+
22
+ [Service]
23
+ ExecStart={script_cmd}
24
+ Restart=always
25
+ RestartSec=10
26
+ User=root
27
+ Environment=PYTHONUNBUFFERED=1
28
+
29
+ [Install]
30
+ WantedBy=multi-user.target
31
+ """
32
+ with open(service_path, "w") as f:
33
+ f.write(service_content)
34
+
35
+ print(f"检测到 Root 用户,已生成系统级服务文件: {service_path}")
36
+ print("正在启用服务...")
37
+
38
+ os.system("systemctl daemon-reload")
39
+ os.system("systemctl enable --now spothomelight")
40
+ print("完成。请使用 'systemctl status spothomelight' 查看状态。")
41
+
42
+ else:
43
+ service_dir = os.path.expanduser("~/.config/systemd/user")
44
+ if not os.path.exists(service_dir):
45
+ os.makedirs(service_dir)
46
+
47
+ service_content = f"""[Unit]
48
+ Description=SpotHomeLight Service (User)
49
+ After=network.target
50
+
51
+ [Service]
52
+ ExecStart={script_cmd}
53
+ Restart=always
54
+ RestartSec=10
55
+ Environment=PYTHONUNBUFFERED=1
56
+
57
+ [Install]
58
+ WantedBy=default.target
59
+ """
60
+ service_path = os.path.join(service_dir, "spothomelight.service")
61
+ with open(service_path, "w") as f:
62
+ f.write(service_content)
63
+
64
+ print(f"检测到普通用户,已生成用户级服务文件: {service_path}")
65
+ print("正在启用服务...")
66
+
67
+ ret = os.system("systemctl --user daemon-reload")
68
+ if ret != 0:
69
+ print("警告: 无法重载 daemon,可能是 DBus 环境变量缺失。尝试手动运行: systemctl --user daemon-reload")
70
+
71
+ os.system("systemctl --user enable --now spothomelight")
72
+ print("完成。请使用 'systemctl --user status spothomelight' 查看状态。")
73
+
74
+ elif system == "Windows":
75
+ task_name = "SpotHomeLightAutoStart"
76
+ cmd = [
77
+ "schtasks", "/Create", "/F",
78
+ "/TN", task_name,
79
+ "/TR", script_cmd,
80
+ "/SC", "ONLOGON",
81
+ "/RL", "HIGHEST"
82
+ ]
83
+ try:
84
+ subprocess.run(cmd, check=True)
85
+ print(f"已创建 Windows 计划任务: {task_name}")
86
+ print("下次登录时将自动运行。")
87
+ except subprocess.CalledProcessError as e:
88
+ print(f"创建计划任务失败: {e}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: spothomelight
3
- Version: 1.0.1
3
+ Version: 1.0.2
4
4
  Summary: Sync Spotify cover color to Home Assistant via Webhook
5
5
  Author-email: "ZGQ Inc." <zgqinc@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/ZGQ-inc/SpotHomeLight
@@ -1,52 +0,0 @@
1
- import os
2
- import sys
3
- import platform
4
- import subprocess
5
-
6
- def setup_autostart():
7
- system = platform.system()
8
- python_exec = sys.executable
9
- script_cmd = f'"{python_exec}" -m spothomelight.main'
10
-
11
- if system == "Linux":
12
- service_dir = os.path.expanduser("~/.config/systemd/user")
13
- if not os.path.exists(service_dir):
14
- os.makedirs(service_dir)
15
-
16
- service_content = f"""[Unit]
17
- Description=SpotHomeLight Service
18
- After=network.target
19
-
20
- [Service]
21
- ExecStart={script_cmd}
22
- Restart=always
23
- RestartSec=10
24
-
25
- [Install]
26
- WantedBy=default.target
27
- """
28
- service_path = os.path.join(service_dir, "spothomelight.service")
29
- with open(service_path, "w") as f:
30
- f.write(service_content)
31
-
32
- print(f"已生成 Systemd 服务文件: {service_path}")
33
- print("正在启用服务...")
34
- os.system("systemctl --user daemon-reload")
35
- os.system("systemctl --user enable --now spothomelight")
36
- print("完成。请使用 'systemctl --user status spothomelight' 查看状态。")
37
-
38
- elif system == "Windows":
39
- task_name = "SpotHomeLightAutoStart"
40
- cmd = [
41
- "schtasks", "/Create", "/F",
42
- "/TN", task_name,
43
- "/TR", script_cmd,
44
- "/SC", "ONLOGON",
45
- "/RL", "HIGHEST"
46
- ]
47
- try:
48
- subprocess.run(cmd, check=True)
49
- print(f"已创建 Windows 计划任务: {task_name}")
50
- print("下次登录时将自动运行。")
51
- except subprocess.CalledProcessError as e:
52
- print(f"创建计划任务失败: {e}")
File without changes
File without changes
File without changes