swaybeing 0.1.0__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.
@@ -0,0 +1,155 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+
6
+ Everyone is permitted to copy and distribute verbatim copies of this license
7
+ document, but changing it is not allowed.
8
+
9
+ This version of the GNU Lesser General Public License incorporates the terms
10
+ and conditions of version 3 of the GNU General Public License, supplemented
11
+ by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, “this License” refers to version 3 of the GNU Lesser General
16
+ Public License, and the “GNU GPL” refers to version 3 of the
17
+ GNU General Public License.
18
+
19
+ “The Library” refers to a covered work governed by this License, other than
20
+ an Application or a Combined Work as defined below.
21
+
22
+ An “Application” is any work that makes use of an interface provided by the
23
+ Library, but which is not otherwise based on the Library. Defining a subclass
24
+ of a class defined by the Library is deemed a mode of using an interface
25
+ provided by the Library.
26
+
27
+ A “Combined Work” is a work produced by combining or linking an Application
28
+ with the Library. The particular version of the Library with which the
29
+ Combined Work was made is also called the “Linked Version”.
30
+
31
+ The “Minimal Corresponding Source” for a Combined Work means the Corresponding
32
+ Source for the Combined Work, excluding any source code for portions of the
33
+ Combined Work that, considered in isolation, are based on the Application,
34
+ and not on the Linked Version.
35
+
36
+ The “Corresponding Application Code” for a Combined Work means the object code
37
+ and/or source code for the Application, including any data and utility programs
38
+ needed for reproducing the Combined Work from the Application, but excluding
39
+ the System Libraries of the Combined Work.
40
+
41
+ 1. Exception to Section 3 of the GNU GPL.
42
+
43
+ You may convey a covered work under sections 3 and 4 of this License without
44
+ being bound by section 3 of the GNU GPL.
45
+
46
+ 2. Conveying Modified Versions.
47
+
48
+ If you modify a copy of the Library, and, in your modifications, a facility
49
+ refers to a function or data to be supplied by an Application that uses the
50
+ facility (other than as an argument passed when the facility is invoked),
51
+ then you may convey a copy of the modified version:
52
+
53
+ a) under this License, provided that you make a good faith effort to
54
+ ensure that, in the event an Application does not supply the function or
55
+ data, the facility still operates, and performs whatever part of its
56
+ purpose remains meaningful, or
57
+
58
+ b) under the GNU GPL, with none of the additional permissions of this
59
+ License applicable to that copy.
60
+
61
+ 3. Object Code Incorporating Material from Library Header Files.
62
+
63
+ The object code form of an Application may incorporate material from a header
64
+ file that is part of the Library. You may convey such object code under terms
65
+ of your choice, provided that, if the incorporated material is not limited to
66
+ numerical parameters, data structure layouts and accessors, or small macros,
67
+ inline functions and templates (ten or fewer lines in length),
68
+ you do both of the following:
69
+
70
+ a) Give prominent notice with each copy of the object code that the Library
71
+ is used in it and that the Library and its use are covered by this License.
72
+
73
+ b) Accompany the object code with a copy of the GNU GPL
74
+ and this license document.
75
+
76
+ 4. Combined Works.
77
+
78
+ You may convey a Combined Work under terms of your choice that, taken together,
79
+ effectively do not restrict modification of the portions of the Library
80
+ contained in the Combined Work and reverse engineering for debugging such
81
+ modifications, if you also do each of the following:
82
+
83
+ a) Give prominent notice with each copy of the Combined Work that the
84
+ Library is used in it and that the Library and its use are covered
85
+ by this License.
86
+
87
+ b) Accompany the Combined Work with a copy of the GNU GPL and
88
+ this license document.
89
+
90
+ c) For a Combined Work that displays copyright notices during execution,
91
+ include the copyright notice for the Library among these notices, as well
92
+ as a reference directing the user to the copies of the GNU GPL
93
+ and this license document.
94
+
95
+ d) Do one of the following:
96
+
97
+ 0) Convey the Minimal Corresponding Source under the terms of this
98
+ License, and the Corresponding Application Code in a form suitable
99
+ for, and under terms that permit, the user to recombine or relink
100
+ the Application with a modified version of the Linked Version to
101
+ produce a modified Combined Work, in the manner specified by section 6
102
+ of the GNU GPL for conveying Corresponding Source.
103
+
104
+ 1) Use a suitable shared library mechanism for linking with the
105
+ Library. A suitable mechanism is one that (a) uses at run time a
106
+ copy of the Library already present on the user's computer system,
107
+ and (b) will operate properly with a modified version of the Library
108
+ that is interface-compatible with the Linked Version.
109
+
110
+ e) Provide Installation Information, but only if you would otherwise be
111
+ required to provide such information under section 6 of the GNU GPL, and
112
+ only to the extent that such information is necessary to install and
113
+ execute a modified version of the Combined Work produced by recombining
114
+ or relinking the Application with a modified version of the Linked Version.
115
+ (If you use option 4d0, the Installation Information must accompany the
116
+ Minimal Corresponding Source and Corresponding Application Code. If you
117
+ use option 4d1, you must provide the Installation Information in the
118
+ manner specified by section 6 of the GNU GPL for
119
+ conveying Corresponding Source.)
120
+
121
+ 5. Combined Libraries.
122
+
123
+ You may place library facilities that are a work based on the Library side by
124
+ side in a single library together with other library facilities that are not
125
+ Applications and are not covered by this License, and convey such a combined
126
+ library under terms of your choice, if you do both of the following:
127
+
128
+ a) Accompany the combined library with a copy of the same work based on
129
+ the Library, uncombined with any other library facilities, conveyed under
130
+ the terms of this License.
131
+
132
+ b) Give prominent notice with the combined library that part of it is a
133
+ work based on the Library, and explaining where to find the accompanying
134
+ uncombined form of the same work.
135
+
136
+ 6. Revised Versions of the GNU Lesser General Public License.
137
+
138
+ The Free Software Foundation may publish revised and/or new versions of the
139
+ GNU Lesser General Public License from time to time. Such new versions will
140
+ be similar in spirit to the present version, but may differ in detail to
141
+ address new problems or concerns.
142
+
143
+ Each version is given a distinguishing version number. If the Library as you
144
+ received it specifies that a certain numbered version of the GNU Lesser
145
+ General Public License “or any later version” applies to it, you have the
146
+ option of following the terms and conditions either of that published version
147
+ or of any later version published by the Free Software Foundation. If the
148
+ Library as you received it does not specify a version number of the GNU Lesser
149
+ General Public License, you may choose any version of the GNU Lesser General
150
+ Public License ever published by the Free Software Foundation.
151
+
152
+ If the Library as you received it specifies that a proxy can decide whether
153
+ future versions of the GNU Lesser General Public License shall apply, that
154
+ proxy's public statement of acceptance of any version is permanent
155
+ authorization for you to choose that version for the Library.
@@ -0,0 +1,219 @@
1
+ Metadata-Version: 2.4
2
+ Name: swaybeing
3
+ Version: 0.1.0
4
+ Summary: Screentime monitoring app for Sway/i3
5
+ Author-email: OliMoli <olimoli@disroot.org>
6
+ License-Expression: LGPL-3.0-or-later
7
+ Requires-Python: >=3.12
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: i3ipc>=2.2.0
11
+ Requires-Dist: pydantic>=2.13.0
12
+ Requires-Dist: aiosqlite>=0.21.0
13
+ Requires-Dist: platformdirs>=4.9.0
14
+ Requires-Dist: click>=8.3.0
15
+ Requires-Dist: tabulate>=0.10.0
16
+ Dynamic: license-file
17
+
18
+ <!--
19
+ vim: ft=markdown softtabstop=2 shiftwidth=2
20
+ -->
21
+
22
+ # Swaybeing
23
+ A simple daemon for Sway/i3 to track per-app screen time
24
+
25
+ > [!NOTE]
26
+ > This program is in an early development phase.
27
+ > The API and CLI is subject to changes.
28
+
29
+ # Screenshots
30
+ ![](https://codeberg.org/OliMoli/swaybeing/raw/branch/main/img/db-show.png)
31
+
32
+ # How it works
33
+ Swaybeing monitors the time you spend in each app. It subscribes to window changes through the i3/Sway IPC socket. When a window is closed or the focus changes to a different app, it compares current timestamp with the timestamp snapshotted when you started using the app and adds it to a write queue. The queue is then written to a database (each 5 minutes by default).
34
+
35
+ Usage stats are stored in an SQLite database. Each day is divided into equal time periods (of the length of 3 hours by default). App usage data is split between those periods. This is a balance between inefficient storing of linear app usage timestamps and not dividing them at all. Changing the period length will only take effect next day if current day already contains usage data.
36
+
37
+ Daylight savings are also handled clearly. Swaybeing internally uses the UTC timezone, which is later visually converted to your current timezone when running the `swaybeingctl db show` command.
38
+
39
+ # Installation
40
+
41
+ ## Nix
42
+ To test it out, you can enter a temporary nix shell:
43
+ ```nix
44
+ nix shell git+https://codeberg.org/OliMoli/swaybeing
45
+ ```
46
+
47
+ For a permanent installation, first add Swaybeing to your flake:
48
+ ```nix
49
+ {
50
+ inputs = {
51
+ # ... other inputs
52
+
53
+ swaybeing = {
54
+ url = "git+https://codeberg.org/OliMoli/swaybeing";
55
+ inputs.nixpkgs.follows = "nixpkgs";
56
+ };
57
+ };
58
+
59
+ # ... rest of your flake
60
+
61
+ outputs = inputs @ { self, nixpkgs, ... }: {
62
+ # example host, replace with your own!
63
+ nixosConfigurations.example = nixpkgs.lib.nixosSystem {
64
+ # ... rest of the system
65
+
66
+ specialArgs = {
67
+ # This is important!
68
+ inherit inputs;
69
+ }
70
+ };
71
+ };
72
+ }
73
+ ```
74
+
75
+ Then, import the module and set `services.swaybeing.enable = true;`. It will automatically install the package and configure the systemd user service.
76
+ ```nix
77
+ { inputs, ... }: {
78
+ modules = [
79
+ inputs.swaybeing.nixosModules.default # System module (appiles to all users)
80
+ inputs.swaybeing.homeModules.default # Home module (applies to a single user)
81
+ ];
82
+
83
+ services.swaybeing = {
84
+ enable = true; # install the package and enable the autostart service
85
+
86
+ # Optional values with examples:
87
+ package = inputs.swaybeing.packages.${pkgs.system}.default; # specify a custom Swaybeing package to use instead
88
+ extraOptions = [ "-l", "debug" ]; # extra command line arguments to be passed to the swaybeingd command
89
+ systemdTargets = [ "sway-session.target" ]; # systemd target which triggers the start of swaybeingd; highly recommended to set
90
+
91
+ # Home Manager only: generate config.json
92
+ config = {
93
+ period_length = 24;
94
+ commit_interval = 60;
95
+ };
96
+ };
97
+ }
98
+ ```
99
+
100
+ If you prefer not to use the module, you can install the packages manually instead:
101
+ ```nix
102
+ { pkgs, inputs, ... }:
103
+ {
104
+ environment.systemPackages = [ inputs.swaybeing.packages.${pkgs.system}.default ]; # NixOS
105
+ home.packages = [ inputs.swaybeing.packages.${pkgs.system}.default ]; # Home Manager
106
+ }
107
+ ```
108
+
109
+ Once Swaybeing gets more stable I'll PR it to Nixpkgs.
110
+
111
+ ## Virtual env
112
+ To test it out, clone the repo and source the `venv-setup` script, or `venv-setup.fish` if you use fish.
113
+
114
+ It will automatically create a temporary venv, drop you into it and source shell completions.
115
+
116
+ ## PyPI
117
+ A PyPI package is available [here](https://pypi.org/project/swaybeing)
118
+
119
+ # Setup
120
+ Put this line in your Sway/i3 config:
121
+ ```
122
+ exec --no-startup-id swaybeingd
123
+ ```
124
+ > [!NOTE]
125
+ > If you're a NixOS/Home Manager user, there's already a systemd unit prepared. See above for more info.
126
+
127
+ You can also add Swayidle hooks to pause monitoring screentime when you're idle:
128
+ ```
129
+ # Sample screen lock hook
130
+ lock 'swaybeingctl msg pause; your-locker; swaybeingctl msg resume'
131
+ unlock 'swaybeingctl msg resume; your-unlocker'
132
+ before-sleep 'loginctl lock-session'
133
+
134
+ # Stop monitoring after 1 minute of idling
135
+ timeout 60 'swaybeingctl msg pause' resume 'swaybeingctl msg resume'
136
+ ```
137
+ or if you use Home Manager:
138
+ ```nix
139
+ { config, pkgs, inputs, ... }:
140
+ let
141
+ swaybeing = "${inputs.swaybeing.packages.${pkgs.system}.default}";
142
+ # or
143
+ swaybeing = config.services.swaybeing.package;
144
+
145
+ swaybeingctl = "${swaybeing}/bin/swaybeingctl";
146
+ in
147
+ {
148
+ services.swayidle = {
149
+ enable = true;
150
+ events = {
151
+ # Sample screen lock hook
152
+ lock = "${swaybeingctl} msg pause; your-locker; ${swaybeingctl} msg resume";
153
+ unlock = "${swaybeingctl} msg resume; your-unlocker";
154
+ before-sleep = "${pkgs.systemd}/bin/loginctl lock-session";
155
+ };
156
+
157
+ timeouts = [
158
+ {
159
+ # Stop monitoring after 1 minute of idling
160
+ timeout = 60;
161
+ command = "${swaybeingctl} msg pause";
162
+ resumeCommand = "${swaybeingctl} msg resume";
163
+ }
164
+ ];
165
+ };
166
+ }
167
+ ```
168
+
169
+ # Usage
170
+ The `swaybeingd` command launches the main daemon.
171
+
172
+ Use `swaybeingctl` to query the database and communicate with the daemon.
173
+
174
+ Basic commands:
175
+ - `swaybeingctl db show`: show recorded usage information
176
+ - `swaybeingctl msg pause`: pause monitoring time
177
+ - `swaybeingctl msg resume`: resume monitoring time
178
+
179
+ More commands can be listed by passing the `--help` argument.
180
+
181
+ # Config
182
+ The config file is located at `$XDG_CONFIG_HOME/swaybeing/config.json`. Config location can be overridden with the `-c` flag
183
+ > [!NOTE]
184
+ > Home Manager users can define the config options in the Home module documented above.
185
+
186
+ | Key | Default value | Description |
187
+ | ----------------- | ---------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
188
+ | `autocommit` | `false` | Automatically write all changes after a window event (disables internal write queue). |
189
+ | `commit_interval` | `60` | How often in seconds to write the changes to the database. Set to `0` to disable this feature. |
190
+ | `database` | `"$XDG_DATA_HOME/swaybeing/database.db"` | Where to store the database. Can be overriden with the `-d` flag. |
191
+ | `period_length` | `3` | Time period length in hours. Must be divisible by 24. Lower = more accuracy. See "How it works" section above. |
192
+ | `socket` | `"$XDG_RUNTIME_DIR/swaybeing.socket"` | Socket path. Can be overriden with the `-s` flag. |
193
+
194
+ All paths in the config allow enviromnent variable and home directory (~) expansion.
195
+
196
+ > [!WARNING]
197
+ > It is not recommended to set both `"autocommit" = false` and `"commit_interval" = 0` at the same time, or the database will only be updated at exit or on `swaybeingctl msg commit`.
198
+
199
+ # Shell completions
200
+ > [!NOTE]
201
+ > Nix users can skip this section since the Nix package already generates proper shell completions.
202
+
203
+ Swaybeing uses [Click](https://click.palletsprojects.com) as its argument parsing engine. According to the [docs](https://click.palletsprojects.com/en/stable/) here are the commands to generate completions:
204
+ ```shell
205
+ _SWAYBEINGD_COMPLETE=shellname_source swaybeingd
206
+ _SWAYBEINGCTL_COMPLETE=shellname_source swaybeingctl
207
+ ```
208
+
209
+ Replace "`shellname`" with either `bash`, `zsh` or `fish`.
210
+
211
+ To permanently install a bash/zsh completion, save the completions to files by adding `> filename` to the end of the commands above and add `source filename` to your .bashrc/.zshrc (obviously replace "`filename`" with your own destination filename)
212
+
213
+ For fish, put the completions in `~/.config/fish/completions/command_name.fish`, replacing "`command_name`" with `swaybeingd` or `swaybeingctl`
214
+
215
+ # Contributing
216
+ See [CONTRIBUTING.md](https://codeberg.org/OliMoli/swaybeing/src/branch/main/CONTRIBUTING.md).
217
+
218
+ # License
219
+ This project is licensed under the [LGPL-3.0-or-later](https://codeberg.org/OliMoli/swaybeing/src/branch/main/LICENSE) license.
@@ -0,0 +1,202 @@
1
+ <!--
2
+ vim: ft=markdown softtabstop=2 shiftwidth=2
3
+ -->
4
+
5
+ # Swaybeing
6
+ A simple daemon for Sway/i3 to track per-app screen time
7
+
8
+ > [!NOTE]
9
+ > This program is in an early development phase.
10
+ > The API and CLI is subject to changes.
11
+
12
+ # Screenshots
13
+ ![](https://codeberg.org/OliMoli/swaybeing/raw/branch/main/img/db-show.png)
14
+
15
+ # How it works
16
+ Swaybeing monitors the time you spend in each app. It subscribes to window changes through the i3/Sway IPC socket. When a window is closed or the focus changes to a different app, it compares current timestamp with the timestamp snapshotted when you started using the app and adds it to a write queue. The queue is then written to a database (each 5 minutes by default).
17
+
18
+ Usage stats are stored in an SQLite database. Each day is divided into equal time periods (of the length of 3 hours by default). App usage data is split between those periods. This is a balance between inefficient storing of linear app usage timestamps and not dividing them at all. Changing the period length will only take effect next day if current day already contains usage data.
19
+
20
+ Daylight savings are also handled clearly. Swaybeing internally uses the UTC timezone, which is later visually converted to your current timezone when running the `swaybeingctl db show` command.
21
+
22
+ # Installation
23
+
24
+ ## Nix
25
+ To test it out, you can enter a temporary nix shell:
26
+ ```nix
27
+ nix shell git+https://codeberg.org/OliMoli/swaybeing
28
+ ```
29
+
30
+ For a permanent installation, first add Swaybeing to your flake:
31
+ ```nix
32
+ {
33
+ inputs = {
34
+ # ... other inputs
35
+
36
+ swaybeing = {
37
+ url = "git+https://codeberg.org/OliMoli/swaybeing";
38
+ inputs.nixpkgs.follows = "nixpkgs";
39
+ };
40
+ };
41
+
42
+ # ... rest of your flake
43
+
44
+ outputs = inputs @ { self, nixpkgs, ... }: {
45
+ # example host, replace with your own!
46
+ nixosConfigurations.example = nixpkgs.lib.nixosSystem {
47
+ # ... rest of the system
48
+
49
+ specialArgs = {
50
+ # This is important!
51
+ inherit inputs;
52
+ }
53
+ };
54
+ };
55
+ }
56
+ ```
57
+
58
+ Then, import the module and set `services.swaybeing.enable = true;`. It will automatically install the package and configure the systemd user service.
59
+ ```nix
60
+ { inputs, ... }: {
61
+ modules = [
62
+ inputs.swaybeing.nixosModules.default # System module (appiles to all users)
63
+ inputs.swaybeing.homeModules.default # Home module (applies to a single user)
64
+ ];
65
+
66
+ services.swaybeing = {
67
+ enable = true; # install the package and enable the autostart service
68
+
69
+ # Optional values with examples:
70
+ package = inputs.swaybeing.packages.${pkgs.system}.default; # specify a custom Swaybeing package to use instead
71
+ extraOptions = [ "-l", "debug" ]; # extra command line arguments to be passed to the swaybeingd command
72
+ systemdTargets = [ "sway-session.target" ]; # systemd target which triggers the start of swaybeingd; highly recommended to set
73
+
74
+ # Home Manager only: generate config.json
75
+ config = {
76
+ period_length = 24;
77
+ commit_interval = 60;
78
+ };
79
+ };
80
+ }
81
+ ```
82
+
83
+ If you prefer not to use the module, you can install the packages manually instead:
84
+ ```nix
85
+ { pkgs, inputs, ... }:
86
+ {
87
+ environment.systemPackages = [ inputs.swaybeing.packages.${pkgs.system}.default ]; # NixOS
88
+ home.packages = [ inputs.swaybeing.packages.${pkgs.system}.default ]; # Home Manager
89
+ }
90
+ ```
91
+
92
+ Once Swaybeing gets more stable I'll PR it to Nixpkgs.
93
+
94
+ ## Virtual env
95
+ To test it out, clone the repo and source the `venv-setup` script, or `venv-setup.fish` if you use fish.
96
+
97
+ It will automatically create a temporary venv, drop you into it and source shell completions.
98
+
99
+ ## PyPI
100
+ A PyPI package is available [here](https://pypi.org/project/swaybeing)
101
+
102
+ # Setup
103
+ Put this line in your Sway/i3 config:
104
+ ```
105
+ exec --no-startup-id swaybeingd
106
+ ```
107
+ > [!NOTE]
108
+ > If you're a NixOS/Home Manager user, there's already a systemd unit prepared. See above for more info.
109
+
110
+ You can also add Swayidle hooks to pause monitoring screentime when you're idle:
111
+ ```
112
+ # Sample screen lock hook
113
+ lock 'swaybeingctl msg pause; your-locker; swaybeingctl msg resume'
114
+ unlock 'swaybeingctl msg resume; your-unlocker'
115
+ before-sleep 'loginctl lock-session'
116
+
117
+ # Stop monitoring after 1 minute of idling
118
+ timeout 60 'swaybeingctl msg pause' resume 'swaybeingctl msg resume'
119
+ ```
120
+ or if you use Home Manager:
121
+ ```nix
122
+ { config, pkgs, inputs, ... }:
123
+ let
124
+ swaybeing = "${inputs.swaybeing.packages.${pkgs.system}.default}";
125
+ # or
126
+ swaybeing = config.services.swaybeing.package;
127
+
128
+ swaybeingctl = "${swaybeing}/bin/swaybeingctl";
129
+ in
130
+ {
131
+ services.swayidle = {
132
+ enable = true;
133
+ events = {
134
+ # Sample screen lock hook
135
+ lock = "${swaybeingctl} msg pause; your-locker; ${swaybeingctl} msg resume";
136
+ unlock = "${swaybeingctl} msg resume; your-unlocker";
137
+ before-sleep = "${pkgs.systemd}/bin/loginctl lock-session";
138
+ };
139
+
140
+ timeouts = [
141
+ {
142
+ # Stop monitoring after 1 minute of idling
143
+ timeout = 60;
144
+ command = "${swaybeingctl} msg pause";
145
+ resumeCommand = "${swaybeingctl} msg resume";
146
+ }
147
+ ];
148
+ };
149
+ }
150
+ ```
151
+
152
+ # Usage
153
+ The `swaybeingd` command launches the main daemon.
154
+
155
+ Use `swaybeingctl` to query the database and communicate with the daemon.
156
+
157
+ Basic commands:
158
+ - `swaybeingctl db show`: show recorded usage information
159
+ - `swaybeingctl msg pause`: pause monitoring time
160
+ - `swaybeingctl msg resume`: resume monitoring time
161
+
162
+ More commands can be listed by passing the `--help` argument.
163
+
164
+ # Config
165
+ The config file is located at `$XDG_CONFIG_HOME/swaybeing/config.json`. Config location can be overridden with the `-c` flag
166
+ > [!NOTE]
167
+ > Home Manager users can define the config options in the Home module documented above.
168
+
169
+ | Key | Default value | Description |
170
+ | ----------------- | ---------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
171
+ | `autocommit` | `false` | Automatically write all changes after a window event (disables internal write queue). |
172
+ | `commit_interval` | `60` | How often in seconds to write the changes to the database. Set to `0` to disable this feature. |
173
+ | `database` | `"$XDG_DATA_HOME/swaybeing/database.db"` | Where to store the database. Can be overriden with the `-d` flag. |
174
+ | `period_length` | `3` | Time period length in hours. Must be divisible by 24. Lower = more accuracy. See "How it works" section above. |
175
+ | `socket` | `"$XDG_RUNTIME_DIR/swaybeing.socket"` | Socket path. Can be overriden with the `-s` flag. |
176
+
177
+ All paths in the config allow enviromnent variable and home directory (~) expansion.
178
+
179
+ > [!WARNING]
180
+ > It is not recommended to set both `"autocommit" = false` and `"commit_interval" = 0` at the same time, or the database will only be updated at exit or on `swaybeingctl msg commit`.
181
+
182
+ # Shell completions
183
+ > [!NOTE]
184
+ > Nix users can skip this section since the Nix package already generates proper shell completions.
185
+
186
+ Swaybeing uses [Click](https://click.palletsprojects.com) as its argument parsing engine. According to the [docs](https://click.palletsprojects.com/en/stable/) here are the commands to generate completions:
187
+ ```shell
188
+ _SWAYBEINGD_COMPLETE=shellname_source swaybeingd
189
+ _SWAYBEINGCTL_COMPLETE=shellname_source swaybeingctl
190
+ ```
191
+
192
+ Replace "`shellname`" with either `bash`, `zsh` or `fish`.
193
+
194
+ To permanently install a bash/zsh completion, save the completions to files by adding `> filename` to the end of the commands above and add `source filename` to your .bashrc/.zshrc (obviously replace "`filename`" with your own destination filename)
195
+
196
+ For fish, put the completions in `~/.config/fish/completions/command_name.fish`, replacing "`command_name`" with `swaybeingd` or `swaybeingctl`
197
+
198
+ # Contributing
199
+ See [CONTRIBUTING.md](https://codeberg.org/OliMoli/swaybeing/src/branch/main/CONTRIBUTING.md).
200
+
201
+ # License
202
+ This project is licensed under the [LGPL-3.0-or-later](https://codeberg.org/OliMoli/swaybeing/src/branch/main/LICENSE) license.
@@ -0,0 +1,35 @@
1
+ [build-system]
2
+ requires = ["setuptools >= 68.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "swaybeing"
7
+ version = "0.1.0" # MAJOR.MINOR.PATCH
8
+ description = "Screentime monitoring app for Sway/i3"
9
+ authors = [{name = "OliMoli", email = "olimoli@disroot.org"}]
10
+
11
+ requires-python = ">= 3.12"
12
+
13
+ dependencies = [
14
+ "i3ipc >= 2.2.0",
15
+ "pydantic >= 2.13.0",
16
+ "aiosqlite >= 0.21.0",
17
+ "platformdirs >= 4.9.0",
18
+ "click >= 8.3.0",
19
+ "tabulate >= 0.10.0"
20
+ ]
21
+
22
+ readme = "README.md"
23
+ license = "LGPL-3.0-or-later"
24
+
25
+ [project.scripts]
26
+ swaybeingd = "swaybeing.daemon:daemon_cli"
27
+ swaybeingctl = "swaybeing.cli:cli"
28
+
29
+ [tool.ruff.format]
30
+ quote-style = "double"
31
+
32
+ [tool.ruff.lint]
33
+ select = [
34
+ "I" # organize imports
35
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,6 @@
1
+ # NOTE: this file exists as a fallback
2
+ # Prefer running the swaybeingd script defined in pyproject.toml instead
3
+
4
+ from swaybeing.daemon import daemon_cli
5
+
6
+ daemon_cli()