-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetup.py
58 lines (42 loc) · 1.22 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from setuptools import setup, find_packages
from pathlib import Path
import json
import subprocess
with Path("manifest.json").open("r") as file:
manifest = json.load(file)
title = manifest["title"]
program = manifest["program"]
version = manifest["version"]
package_data = {}
def _post_install():
_create_service_file()
def _create_service_file():
path_to_bin = Path(f"~/.local/bin/{program}").expanduser().resolve()
content = f"""[Unit]
Description=Daemon for Clipton (Clipboard Manager)
[Service]
Type=simple
ExecStart={path_to_bin} watcher
[Install]
WantedBy=graphical.target
"""
service_dir = Path("~/.config/systemd/user").expanduser().resolve()
service_dir.mkdir(parents=True, exist_ok=True)
service_file = Path(service_dir, f"{program}.service").expanduser().resolve()
with service_file.open("w") as f:
f.write(content)
subprocess.run(["systemctl", "--user", "daemon-reload"], check=False)
setup(
name=title,
version=version,
packages=find_packages(where="."),
package_dir={"": "."},
package_data=package_data,
py_modules=[program],
entry_points={
"console_scripts": [
f"{program}={program}:main",
],
},
)
_post_install()