diff options
-rw-r--r-- | accounts/gkleen@sif/niri/default.nix | 1 | ||||
-rw-r--r-- | overlays/worktime/pyproject.toml | 2 | ||||
-rw-r--r-- | overlays/worktime/uv.lock | 23 | ||||
-rwxr-xr-x | overlays/worktime/worktime/__main__.py | 19 |
4 files changed, 45 insertions, 0 deletions
diff --git a/accounts/gkleen@sif/niri/default.nix b/accounts/gkleen@sif/niri/default.nix index 9bd6eafd..8c78738e 100644 --- a/accounts/gkleen@sif/niri/default.nix +++ b/accounts/gkleen@sif/niri/default.nix | |||
@@ -983,6 +983,7 @@ in { | |||
983 | "Mod+Shift+D".action = with-focused-window-action "{\"Action\":{\"UnsetUrgent\":{\"id\": .id}}}"; | 983 | "Mod+Shift+D".action = with-focused-window-action "{\"Action\":{\"UnsetUrgent\":{\"id\": .id}}}"; |
984 | 984 | ||
985 | "Mod+K".action = spawn (lib.getExe' pkgs.worktime "worktime-ui"); | 985 | "Mod+K".action = spawn (lib.getExe' pkgs.worktime "worktime-ui"); |
986 | "Mod+Shift+K".action = spawn (lib.getExe' pkgs.worktime "worktime-stop"); | ||
986 | })) | 987 | })) |
987 | (map ({ name, selector, spawn, key, ...}: if key != null && selector != null && spawn != null then bind key { action = focus-or-spawn-action selector name spawn; } else null) cfg.scratchspaces) | 988 | (map ({ name, selector, spawn, key, ...}: if key != null && selector != null && spawn != null then bind key { action = focus-or-spawn-action selector name spawn; } else null) cfg.scratchspaces) |
988 | (map ({ name, moveKey, ...}: if moveKey != null then bind moveKey { action = kdl.magic-leaf "move-column-to-workspace" name; } else null) cfg.scratchspaces) | 989 | (map ({ name, moveKey, ...}: if moveKey != null then bind moveKey { action = kdl.magic-leaf "move-column-to-workspace" name; } else null) cfg.scratchspaces) |
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] |
18 | worktime = "worktime.__main__:main" | 19 | worktime = "worktime.__main__:main" |
19 | worktime-ui = "worktime.__main__:ui" | 20 | worktime-ui = "worktime.__main__:ui" |
21 | worktime-stop = "worktime.__main__:stop" | ||
20 | 22 | ||
21 | [build-system] | 23 | [build-system] |
22 | requires = ["hatchling"] | 24 | requires = ["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]] |
86 | name = "dbus-next" | ||
87 | version = "0.2.3" | ||
88 | source = { registry = "https://pypi.org/simple" } | ||
89 | sdist = { 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" } | ||
90 | wheels = [ | ||
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]] | ||
95 | name = "desktop-notify" | ||
96 | version = "1.3.3" | ||
97 | source = { registry = "https://pypi.org/simple" } | ||
98 | dependencies = [ | ||
99 | { name = "dbus-next" }, | ||
100 | ] | ||
101 | sdist = { 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" } | ||
102 | wheels = [ | ||
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]] | ||
86 | name = "frozendict" | 107 | name = "frozendict" |
87 | version = "2.4.6" | 108 | version = "2.4.6" |
88 | source = { registry = "https://pypi.org/simple" } | 109 | source = { registry = "https://pypi.org/simple" } |
@@ -198,6 +219,7 @@ version = "1.0.0" | |||
198 | source = { editable = "." } | 219 | source = { editable = "." } |
199 | dependencies = [ | 220 | dependencies = [ |
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] |
212 | requires-dist = [ | 234 | requires-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 | |||
49 | import os | 49 | import os |
50 | from time import clock_gettime_ns, CLOCK_MONOTONIC | 50 | from time import clock_gettime_ns, CLOCK_MONOTONIC |
51 | from atomicwriter import AtomicWriter | 51 | from atomicwriter import AtomicWriter |
52 | import desktop_notify.aio as notify | ||
52 | 53 | ||
53 | class BearerAuth(requests.auth.AuthBase): | 54 | class 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 | ||
1034 | def ui(): | 1037 | def ui(): |
1035 | asyncio.run(ui_main()) | 1038 | asyncio.run(ui_main()) |
1036 | 1039 | ||
1040 | async 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 | |||
1053 | def stop(): | ||
1054 | asyncio.run(stop_main()) | ||
1055 | |||
1037 | if __name__ == "__main__": | 1056 | if __name__ == "__main__": |
1038 | sys.exit(main()) | 1057 | sys.exit(main()) |