summaryrefslogtreecommitdiff
path: root/overlays
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2025-05-25 15:18:50 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2025-05-25 15:18:50 +0200
commit013c29a57b8208186b99dc880250fd2029915349 (patch)
treed59849622914669847b3ccca330fbd671fce9270 /overlays
parent5e73837de8e294398565555d7e03d16027e29771 (diff)
downloadnixos-013c29a57b8208186b99dc880250fd2029915349.tar
nixos-013c29a57b8208186b99dc880250fd2029915349.tar.gz
nixos-013c29a57b8208186b99dc880250fd2029915349.tar.bz2
nixos-013c29a57b8208186b99dc880250fd2029915349.tar.xz
nixos-013c29a57b8208186b99dc880250fd2029915349.zip
...
Diffstat (limited to 'overlays')
-rw-r--r--overlays/worktime/pyproject.toml2
-rw-r--r--overlays/worktime/uv.lock23
-rwxr-xr-xoverlays/worktime/worktime/__main__.py19
3 files changed, 44 insertions, 0 deletions
diff --git a/overlays/worktime/pyproject.toml b/overlays/worktime/pyproject.toml
index 4b3605bd..42da51f5 100644
--- a/overlays/worktime/pyproject.toml
+++ b/overlays/worktime/pyproject.toml
@@ -12,11 +12,13 @@ dependencies = [
12 "jsonpickle>=4.0.5,<5", 12 "jsonpickle>=4.0.5,<5",
13 "frozendict>=2.4.6", 13 "frozendict>=2.4.6",
14 "atomicwriter>=0.2.5", 14 "atomicwriter>=0.2.5",
15 "desktop-notify>=1.3.3",
15] 16]
16 17
17[project.scripts] 18[project.scripts]
18worktime = "worktime.__main__:main" 19worktime = "worktime.__main__:main"
19worktime-ui = "worktime.__main__:ui" 20worktime-ui = "worktime.__main__:ui"
21worktime-stop = "worktime.__main__:stop"
20 22
21[build-system] 23[build-system]
22requires = ["hatchling"] 24requires = ["hatchling"]
diff --git a/overlays/worktime/uv.lock b/overlays/worktime/uv.lock
index d8a14937..39de4ccf 100644
--- a/overlays/worktime/uv.lock
+++ b/overlays/worktime/uv.lock
@@ -83,6 +83,27 @@ wheels = [
83] 83]
84 84
85[[package]] 85[[package]]
86name = "dbus-next"
87version = "0.2.3"
88source = { registry = "https://pypi.org/simple" }
89sdist = { url = "https://files.pythonhosted.org/packages/ce/45/6a40fbe886d60a8c26f480e7d12535502b5ba123814b3b9a0b002ebca198/dbus_next-0.2.3.tar.gz", hash = "sha256:f4eae26909332ada528c0a3549dda8d4f088f9b365153952a408e28023a626a5", size = 71112, upload-time = "2021-07-25T22:11:28.398Z" }
90wheels = [
91 { url = "https://files.pythonhosted.org/packages/d2/fc/c0a3f4c4eaa5a22fbef91713474666e13d0ea2a69c84532579490a9f2cc8/dbus_next-0.2.3-py3-none-any.whl", hash = "sha256:58948f9aff9db08316734c0be2a120f6dc502124d9642f55e90ac82ffb16a18b", size = 57885, upload-time = "2021-07-25T22:11:25.466Z" },
92]
93
94[[package]]
95name = "desktop-notify"
96version = "1.3.3"
97source = { registry = "https://pypi.org/simple" }
98dependencies = [
99 { name = "dbus-next" },
100]
101sdist = { url = "https://files.pythonhosted.org/packages/7a/d8/7ae5779257f5f1aa0a2d50c02d70b29522bd414692f3d3bd18ef119fe82d/desktop-notify-1.3.3.tar.gz", hash = "sha256:62934ad1f72f292f9a3af5ffe45af32814af18c396c00369385540c72bf08077", size = 7828, upload-time = "2021-01-03T16:46:36.483Z" }
102wheels = [
103 { url = "https://files.pythonhosted.org/packages/0a/cd/a7e3bd0262f3e8a9272fd24d0193e24dad7cb4e4edd27da48e74b5523e59/desktop_notify-1.3.3-py3-none-any.whl", hash = "sha256:8ad7ecc3a9a603dd5fa3cdc11cc6265cfbc7f6df9d8ed240f4663f43ef0de37a", size = 9937, upload-time = "2021-01-03T16:46:35.157Z" },
104]
105
106[[package]]
86name = "frozendict" 107name = "frozendict"
87version = "2.4.6" 108version = "2.4.6"
88source = { registry = "https://pypi.org/simple" } 109source = { registry = "https://pypi.org/simple" }
@@ -198,6 +219,7 @@ version = "1.0.0"
198source = { editable = "." } 219source = { editable = "." }
199dependencies = [ 220dependencies = [
200 { name = "atomicwriter" }, 221 { name = "atomicwriter" },
222 { name = "desktop-notify" },
201 { name = "frozendict" }, 223 { name = "frozendict" },
202 { name = "jsonpickle" }, 224 { name = "jsonpickle" },
203 { name = "python-dateutil" }, 225 { name = "python-dateutil" },
@@ -211,6 +233,7 @@ dependencies = [
211[package.metadata] 233[package.metadata]
212requires-dist = [ 234requires-dist = [
213 { name = "atomicwriter", specifier = ">=0.2.5" }, 235 { name = "atomicwriter", specifier = ">=0.2.5" },
236 { name = "desktop-notify", specifier = ">=1.3.3" },
214 { name = "frozendict", specifier = ">=2.4.6" }, 237 { name = "frozendict", specifier = ">=2.4.6" },
215 { name = "jsonpickle", specifier = ">=4.0.5,<5" }, 238 { name = "jsonpickle", specifier = ">=4.0.5,<5" },
216 { name = "python-dateutil", specifier = ">=2.9.0.post0,<3" }, 239 { name = "python-dateutil", specifier = ">=2.9.0.post0,<3" },
diff --git a/overlays/worktime/worktime/__main__.py b/overlays/worktime/worktime/__main__.py
index 79e1cbb7..fbd8fb0a 100755
--- a/overlays/worktime/worktime/__main__.py
+++ b/overlays/worktime/worktime/__main__.py
@@ -49,6 +49,7 @@ from contextlib import closing
49import os 49import os
50from time import clock_gettime_ns, CLOCK_MONOTONIC 50from time import clock_gettime_ns, CLOCK_MONOTONIC
51from atomicwriter import AtomicWriter 51from atomicwriter import AtomicWriter
52import desktop_notify.aio as notify
52 53
53class BearerAuth(requests.auth.AuthBase): 54class BearerAuth(requests.auth.AuthBase):
54 def __init__(self, token): 55 def __init__(self, token):
@@ -1018,6 +1019,7 @@ async def ui_main():
1018 return 1019 return
1019 elif running_entry and fuzzel_out == 0: 1020 elif running_entry and fuzzel_out == 0:
1020 api.stop_clock(running_entry['id']) 1021 api.stop_clock(running_entry['id'])
1022 await notify.Server('worktime').Notify("Stopped running timesheet").set_timeout(65000).show()
1021 else: 1023 else:
1022 if running_entry: 1024 if running_entry:
1023 fuzzel_out -= 1 1025 fuzzel_out -= 1
@@ -1029,10 +1031,27 @@ async def ui_main():
1029 tags = option['tags'], 1031 tags = option['tags'],
1030 billable = option['billable'], 1032 billable = option['billable'],
1031 ) 1033 )
1034 await notify.Server('worktime').Notify("Timesheet started…").set_timeout(65000).show()
1032 1035
1033 1036
1034def ui(): 1037def ui():
1035 asyncio.run(ui_main()) 1038 asyncio.run(ui_main())
1036 1039
1040async def stop_main():
1041 config = Worktime.config()
1042 api = KimaiAPI(
1043 base_url=config.get("KIMAI", {}).get("BaseUrl", None),
1044 api_token=config.get("KIMAI", {}).get("ApiToken", None),
1045 clients=config.get("KIMAI", {}).get("Clients", None)
1046 )
1047 if running_entry := api.get_running_entry():
1048 api.stop_clock(running_entry['id'])
1049 await notify.Server('worktime').Notify("Stopped running timesheet").set_timeout(65000).show()
1050 else:
1051 await notify.Server('worktime').Notify("No timesheet currently running").set_timeout(65000).show()
1052
1053def stop():
1054 asyncio.run(stop_main())
1055
1037if __name__ == "__main__": 1056if __name__ == "__main__":
1038 sys.exit(main()) 1057 sys.exit(main())