reckn 1.0.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.
- reckn-1.0.0/LICENSE +21 -0
- reckn-1.0.0/PKG-INFO +203 -0
- reckn-1.0.0/README.md +174 -0
- reckn-1.0.0/pyproject.toml +48 -0
- reckn-1.0.0/reckn/__init__.py +3 -0
- reckn-1.0.0/reckn/__main__.py +110 -0
- reckn-1.0.0/reckn/app.py +1679 -0
- reckn-1.0.0/reckn/assets/reckn.svg +28 -0
- reckn-1.0.0/reckn/clipboard.py +121 -0
- reckn-1.0.0/reckn/currencies.py +374 -0
- reckn-1.0.0/reckn/dates.py +806 -0
- reckn-1.0.0/reckn/evaluator.py +1150 -0
- reckn-1.0.0/reckn/highlighter.py +208 -0
- reckn-1.0.0/reckn/pad.py +123 -0
- reckn-1.0.0/reckn/parser.py +269 -0
- reckn-1.0.0/reckn/percentages.py +191 -0
- reckn-1.0.0/reckn/test_repl.py +78 -0
- reckn-1.0.0/reckn/units.py +647 -0
- reckn-1.0.0/reckn/value.py +218 -0
- reckn-1.0.0/reckn.egg-info/PKG-INFO +203 -0
- reckn-1.0.0/reckn.egg-info/SOURCES.txt +24 -0
- reckn-1.0.0/reckn.egg-info/dependency_links.txt +1 -0
- reckn-1.0.0/reckn.egg-info/entry_points.txt +2 -0
- reckn-1.0.0/reckn.egg-info/requires.txt +2 -0
- reckn-1.0.0/reckn.egg-info/top_level.txt +1 -0
- reckn-1.0.0/setup.cfg +4 -0
reckn-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 David Vignoni
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
reckn-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: reckn
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A Soulver-like calculator notepad for the terminal
|
|
5
|
+
Author: David Vignoni
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/davigno/reckn
|
|
8
|
+
Project-URL: Repository, https://github.com/davigno/reckn
|
|
9
|
+
Project-URL: Issues, https://github.com/davigno/reckn/issues
|
|
10
|
+
Keywords: calculator,notepad,terminal,tui,soulver,math,units,currency
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
14
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
15
|
+
Classifier: Operating System :: MacOS
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Office/Business
|
|
22
|
+
Classifier: Topic :: Utilities
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: textual>=0.40.0
|
|
27
|
+
Requires-Dist: requests>=2.25.0
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# Reckn
|
|
31
|
+
|
|
32
|
+
*Pronounced "reckon"*
|
|
33
|
+
|
|
34
|
+
A Soulver-like calculator notepad for the terminal. Type math expressions on the left, see results on the right - with variables, units, currencies, percentages, dates, and more.
|
|
35
|
+
|
|
36
|
+
## Install
|
|
37
|
+
|
|
38
|
+
Requires Python 3.10+.
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pipx install reckn
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
That's it. If you don't have pipx: `pip install pipx` or `sudo apt install pipx` (Debian/Ubuntu) or `brew install pipx` (macOS).
|
|
45
|
+
|
|
46
|
+
Alternatively, with pip:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install reckn
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Linux Desktop Integration
|
|
53
|
+
|
|
54
|
+
To add Reckn to your application menu:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
reckn --install-desktop
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### From Source
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
git clone https://github.com/davigno/reckn.git
|
|
64
|
+
cd reckn
|
|
65
|
+
pipx install .
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Usage
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
reckn # New empty pad
|
|
72
|
+
reckn mybudget # Open or create named pad
|
|
73
|
+
reckn --list # List saved pads
|
|
74
|
+
reckn --version # Show version
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Press `F2` inside the app for a full syntax reference and keyboard shortcuts.
|
|
78
|
+
|
|
79
|
+
## What Can It Do?
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
# Monthly Budget
|
|
83
|
+
salary = 5000 5,000
|
|
84
|
+
tax = 22% of salary 1,100
|
|
85
|
+
rent = 1200 EUR €1,200
|
|
86
|
+
rent in USD $1,415.28
|
|
87
|
+
--- 5,715.28
|
|
88
|
+
|
|
89
|
+
# Trip Planning
|
|
90
|
+
distance = 450 km 450 km
|
|
91
|
+
distance in miles 279.62 mi
|
|
92
|
+
speed = 100 km/h 100 km/h
|
|
93
|
+
distance / speed as timespan 4 hr 30 min
|
|
94
|
+
|
|
95
|
+
# Dates
|
|
96
|
+
today 25 March 2026
|
|
97
|
+
vacation = June 15 15 June 2026
|
|
98
|
+
vacation - today 2 months 21 days
|
|
99
|
+
|
|
100
|
+
# Time
|
|
101
|
+
meeting = 2:30pm 2:30 pm
|
|
102
|
+
meeting + 1 hr 45 min 4:15 pm
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Keyboard Shortcuts
|
|
106
|
+
|
|
107
|
+
| Key | Action |
|
|
108
|
+
|-----|--------|
|
|
109
|
+
| `F1` | File menu |
|
|
110
|
+
| `F2` | Help / syntax reference |
|
|
111
|
+
| `Ctrl+N` | New pad |
|
|
112
|
+
| `Ctrl+O` | Open pad |
|
|
113
|
+
| `Ctrl+S` | Save pad |
|
|
114
|
+
| `Ctrl+E` | Export as markdown |
|
|
115
|
+
| `Ctrl+T` | Toggle floating total |
|
|
116
|
+
| `Ctrl+K` | Toggle comment |
|
|
117
|
+
| `Ctrl+X` | Delete line |
|
|
118
|
+
| `Ctrl+C` | Copy result |
|
|
119
|
+
| `Ctrl+Shift+C` | Copy entire pad |
|
|
120
|
+
| `Ctrl+V` | Paste |
|
|
121
|
+
| `Ctrl+Q` | Quit |
|
|
122
|
+
| `Click result` | Insert line reference |
|
|
123
|
+
|
|
124
|
+
## Syntax Reference
|
|
125
|
+
|
|
126
|
+
### Arithmetic & Variables
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
2 + 3 * (10 - 4) → 20
|
|
130
|
+
2 ^ 10 → 1,024
|
|
131
|
+
100k + 50k → 150,000 (SI: k, M, B, G)
|
|
132
|
+
salary = 60k → 60,000 (variable assignment)
|
|
133
|
+
line1 + line2 → (line refs)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Units & Conversions
|
|
137
|
+
|
|
138
|
+
Convert with `in`, `to`, or `as`. Compatible units mix automatically.
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
10 inches in cm → 25.4 cm
|
|
142
|
+
5 km in miles → 3.11 mi
|
|
143
|
+
100 degC in degF → 212 °F
|
|
144
|
+
1000 MB in GB → 1 GB
|
|
145
|
+
100 km/h in mph → 62.14 mph
|
|
146
|
+
1 km + 500 m → 1,500 m
|
|
147
|
+
500 km / 2 hours → 250 km/h
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**Supported:** length (mm-mi), weight (mg-lb), time (ms-year), data (B-PB, bits), speed, temperature.
|
|
151
|
+
|
|
152
|
+
### Currencies
|
|
153
|
+
|
|
154
|
+
Live rates from frankfurter.app, cached locally for offline use.
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
$100 in EUR → €84.79
|
|
158
|
+
100 GBP to USD → $135.89
|
|
159
|
+
rent = 100 USD → $100 (unit preserved)
|
|
160
|
+
rent * 12 → $1,200
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Percentages
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
25% of 1000 → 250
|
|
167
|
+
10% off 200 → 180
|
|
168
|
+
200 + 10% → 220
|
|
169
|
+
50 as % of 200 → 25%
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Dates & Clock Time
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
today → 25 March 2026
|
|
176
|
+
today + 3 weeks → 15 April 2026
|
|
177
|
+
from March 1 to April 1 → 1 month
|
|
178
|
+
7:45am + 9 hours → 4:45 pm
|
|
179
|
+
3:35pm - 11:00am → 4 hr 35 min
|
|
180
|
+
5.5 hours as timespan → 5 hr 30 min
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Structure
|
|
184
|
+
|
|
185
|
+
```
|
|
186
|
+
# Heading (section header, resets subtotals)
|
|
187
|
+
// Comment (not evaluated)
|
|
188
|
+
label: 1200 (display only, no variable)
|
|
189
|
+
var = 1200 (variable assignment)
|
|
190
|
+
--- (subtotal)
|
|
191
|
+
=== (subtotal, alternate style)
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Data Storage
|
|
195
|
+
|
|
196
|
+
All data in `~/.config/reckn/`:
|
|
197
|
+
|
|
198
|
+
- `pads/<name>.json` - saved pads
|
|
199
|
+
- `currency_cache.json` - cached exchange rates
|
|
200
|
+
|
|
201
|
+
## License
|
|
202
|
+
|
|
203
|
+
MIT
|
reckn-1.0.0/README.md
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# Reckn
|
|
2
|
+
|
|
3
|
+
*Pronounced "reckon"*
|
|
4
|
+
|
|
5
|
+
A Soulver-like calculator notepad for the terminal. Type math expressions on the left, see results on the right - with variables, units, currencies, percentages, dates, and more.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
Requires Python 3.10+.
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pipx install reckn
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
That's it. If you don't have pipx: `pip install pipx` or `sudo apt install pipx` (Debian/Ubuntu) or `brew install pipx` (macOS).
|
|
16
|
+
|
|
17
|
+
Alternatively, with pip:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install reckn
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Linux Desktop Integration
|
|
24
|
+
|
|
25
|
+
To add Reckn to your application menu:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
reckn --install-desktop
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### From Source
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
git clone https://github.com/davigno/reckn.git
|
|
35
|
+
cd reckn
|
|
36
|
+
pipx install .
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
reckn # New empty pad
|
|
43
|
+
reckn mybudget # Open or create named pad
|
|
44
|
+
reckn --list # List saved pads
|
|
45
|
+
reckn --version # Show version
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Press `F2` inside the app for a full syntax reference and keyboard shortcuts.
|
|
49
|
+
|
|
50
|
+
## What Can It Do?
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
# Monthly Budget
|
|
54
|
+
salary = 5000 5,000
|
|
55
|
+
tax = 22% of salary 1,100
|
|
56
|
+
rent = 1200 EUR €1,200
|
|
57
|
+
rent in USD $1,415.28
|
|
58
|
+
--- 5,715.28
|
|
59
|
+
|
|
60
|
+
# Trip Planning
|
|
61
|
+
distance = 450 km 450 km
|
|
62
|
+
distance in miles 279.62 mi
|
|
63
|
+
speed = 100 km/h 100 km/h
|
|
64
|
+
distance / speed as timespan 4 hr 30 min
|
|
65
|
+
|
|
66
|
+
# Dates
|
|
67
|
+
today 25 March 2026
|
|
68
|
+
vacation = June 15 15 June 2026
|
|
69
|
+
vacation - today 2 months 21 days
|
|
70
|
+
|
|
71
|
+
# Time
|
|
72
|
+
meeting = 2:30pm 2:30 pm
|
|
73
|
+
meeting + 1 hr 45 min 4:15 pm
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Keyboard Shortcuts
|
|
77
|
+
|
|
78
|
+
| Key | Action |
|
|
79
|
+
|-----|--------|
|
|
80
|
+
| `F1` | File menu |
|
|
81
|
+
| `F2` | Help / syntax reference |
|
|
82
|
+
| `Ctrl+N` | New pad |
|
|
83
|
+
| `Ctrl+O` | Open pad |
|
|
84
|
+
| `Ctrl+S` | Save pad |
|
|
85
|
+
| `Ctrl+E` | Export as markdown |
|
|
86
|
+
| `Ctrl+T` | Toggle floating total |
|
|
87
|
+
| `Ctrl+K` | Toggle comment |
|
|
88
|
+
| `Ctrl+X` | Delete line |
|
|
89
|
+
| `Ctrl+C` | Copy result |
|
|
90
|
+
| `Ctrl+Shift+C` | Copy entire pad |
|
|
91
|
+
| `Ctrl+V` | Paste |
|
|
92
|
+
| `Ctrl+Q` | Quit |
|
|
93
|
+
| `Click result` | Insert line reference |
|
|
94
|
+
|
|
95
|
+
## Syntax Reference
|
|
96
|
+
|
|
97
|
+
### Arithmetic & Variables
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
2 + 3 * (10 - 4) → 20
|
|
101
|
+
2 ^ 10 → 1,024
|
|
102
|
+
100k + 50k → 150,000 (SI: k, M, B, G)
|
|
103
|
+
salary = 60k → 60,000 (variable assignment)
|
|
104
|
+
line1 + line2 → (line refs)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Units & Conversions
|
|
108
|
+
|
|
109
|
+
Convert with `in`, `to`, or `as`. Compatible units mix automatically.
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
10 inches in cm → 25.4 cm
|
|
113
|
+
5 km in miles → 3.11 mi
|
|
114
|
+
100 degC in degF → 212 °F
|
|
115
|
+
1000 MB in GB → 1 GB
|
|
116
|
+
100 km/h in mph → 62.14 mph
|
|
117
|
+
1 km + 500 m → 1,500 m
|
|
118
|
+
500 km / 2 hours → 250 km/h
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Supported:** length (mm-mi), weight (mg-lb), time (ms-year), data (B-PB, bits), speed, temperature.
|
|
122
|
+
|
|
123
|
+
### Currencies
|
|
124
|
+
|
|
125
|
+
Live rates from frankfurter.app, cached locally for offline use.
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
$100 in EUR → €84.79
|
|
129
|
+
100 GBP to USD → $135.89
|
|
130
|
+
rent = 100 USD → $100 (unit preserved)
|
|
131
|
+
rent * 12 → $1,200
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Percentages
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
25% of 1000 → 250
|
|
138
|
+
10% off 200 → 180
|
|
139
|
+
200 + 10% → 220
|
|
140
|
+
50 as % of 200 → 25%
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Dates & Clock Time
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
today → 25 March 2026
|
|
147
|
+
today + 3 weeks → 15 April 2026
|
|
148
|
+
from March 1 to April 1 → 1 month
|
|
149
|
+
7:45am + 9 hours → 4:45 pm
|
|
150
|
+
3:35pm - 11:00am → 4 hr 35 min
|
|
151
|
+
5.5 hours as timespan → 5 hr 30 min
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Structure
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
# Heading (section header, resets subtotals)
|
|
158
|
+
// Comment (not evaluated)
|
|
159
|
+
label: 1200 (display only, no variable)
|
|
160
|
+
var = 1200 (variable assignment)
|
|
161
|
+
--- (subtotal)
|
|
162
|
+
=== (subtotal, alternate style)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Data Storage
|
|
166
|
+
|
|
167
|
+
All data in `~/.config/reckn/`:
|
|
168
|
+
|
|
169
|
+
- `pads/<name>.json` - saved pads
|
|
170
|
+
- `currency_cache.json` - cached exchange rates
|
|
171
|
+
|
|
172
|
+
## License
|
|
173
|
+
|
|
174
|
+
MIT
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "reckn"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "A Soulver-like calculator notepad for the terminal"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "David Vignoni"}
|
|
14
|
+
]
|
|
15
|
+
keywords = ["calculator", "notepad", "terminal", "tui", "soulver", "math", "units", "currency"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Environment :: Console",
|
|
19
|
+
"Intended Audience :: End Users/Desktop",
|
|
20
|
+
"Operating System :: POSIX :: Linux",
|
|
21
|
+
"Operating System :: MacOS",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Programming Language :: Python :: 3.10",
|
|
24
|
+
"Programming Language :: Python :: 3.11",
|
|
25
|
+
"Programming Language :: Python :: 3.12",
|
|
26
|
+
"Programming Language :: Python :: 3.13",
|
|
27
|
+
"Topic :: Office/Business",
|
|
28
|
+
"Topic :: Utilities",
|
|
29
|
+
]
|
|
30
|
+
dependencies = [
|
|
31
|
+
"textual>=0.40.0",
|
|
32
|
+
"requests>=2.25.0",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[project.scripts]
|
|
36
|
+
reckn = "reckn.__main__:main"
|
|
37
|
+
|
|
38
|
+
[project.urls]
|
|
39
|
+
Homepage = "https://github.com/davigno/reckn"
|
|
40
|
+
Repository = "https://github.com/davigno/reckn"
|
|
41
|
+
Issues = "https://github.com/davigno/reckn/issues"
|
|
42
|
+
|
|
43
|
+
[tool.setuptools.packages.find]
|
|
44
|
+
where = ["."]
|
|
45
|
+
include = ["reckn*"]
|
|
46
|
+
|
|
47
|
+
[tool.setuptools.package-data]
|
|
48
|
+
reckn = ["assets/*.svg"]
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"""Entry point for running Reckn as a module."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
from . import __version__
|
|
7
|
+
from .pad import list_pads, load_pad, PADS_DIR
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def install_desktop():
|
|
11
|
+
"""Install desktop entry and icon for Linux desktop integration."""
|
|
12
|
+
import shutil
|
|
13
|
+
import subprocess
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
|
|
16
|
+
pkg_dir = Path(__file__).parent
|
|
17
|
+
icon_src = pkg_dir / "assets" / "reckn.svg"
|
|
18
|
+
|
|
19
|
+
if not icon_src.exists():
|
|
20
|
+
print(f"Error: icon not found at {icon_src}", file=sys.stderr)
|
|
21
|
+
sys.exit(1)
|
|
22
|
+
|
|
23
|
+
# Install icon
|
|
24
|
+
icon_dir = Path.home() / ".local" / "share" / "icons" / "hicolor" / "scalable" / "apps"
|
|
25
|
+
icon_dir.mkdir(parents=True, exist_ok=True)
|
|
26
|
+
shutil.copy2(icon_src, icon_dir / "reckn.svg")
|
|
27
|
+
print(f" Icon -> {icon_dir / 'reckn.svg'}")
|
|
28
|
+
|
|
29
|
+
# Generate and install .desktop file
|
|
30
|
+
reckn_exe = shutil.which("reckn") or "reckn"
|
|
31
|
+
desktop_content = (
|
|
32
|
+
"[Desktop Entry]\n"
|
|
33
|
+
"Name=Reckn\n"
|
|
34
|
+
"Comment=A calculator notepad for the terminal\n"
|
|
35
|
+
f"Exec={reckn_exe}\n"
|
|
36
|
+
"Icon=reckn\n"
|
|
37
|
+
"Terminal=true\n"
|
|
38
|
+
"Type=Application\n"
|
|
39
|
+
"Categories=Utility;Calculator;\n"
|
|
40
|
+
"Keywords=calculator;notepad;math;units;currency;\n"
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
desktop_dir = Path.home() / ".local" / "share" / "applications"
|
|
44
|
+
desktop_dir.mkdir(parents=True, exist_ok=True)
|
|
45
|
+
desktop_file = desktop_dir / "reckn.desktop"
|
|
46
|
+
desktop_file.write_text(desktop_content)
|
|
47
|
+
print(f" Desktop entry -> {desktop_file}")
|
|
48
|
+
|
|
49
|
+
# Update desktop database (best effort)
|
|
50
|
+
try:
|
|
51
|
+
subprocess.run(["update-desktop-database", str(desktop_dir)],
|
|
52
|
+
capture_output=True, check=False)
|
|
53
|
+
except FileNotFoundError:
|
|
54
|
+
pass
|
|
55
|
+
|
|
56
|
+
print("Done. Reckn should now appear in your application menu.")
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def main():
|
|
60
|
+
parser = argparse.ArgumentParser(
|
|
61
|
+
prog="reckn",
|
|
62
|
+
description="Reckn - A calculator notepad for the terminal"
|
|
63
|
+
)
|
|
64
|
+
parser.add_argument(
|
|
65
|
+
"pad_name",
|
|
66
|
+
nargs="?",
|
|
67
|
+
help="Name of pad to open"
|
|
68
|
+
)
|
|
69
|
+
parser.add_argument(
|
|
70
|
+
"--version", "-V",
|
|
71
|
+
action="version",
|
|
72
|
+
version=f"reckn {__version__}"
|
|
73
|
+
)
|
|
74
|
+
parser.add_argument(
|
|
75
|
+
"--list", "-l",
|
|
76
|
+
action="store_true",
|
|
77
|
+
help="List all saved pads"
|
|
78
|
+
)
|
|
79
|
+
parser.add_argument(
|
|
80
|
+
"--install-desktop",
|
|
81
|
+
action="store_true",
|
|
82
|
+
help="Install desktop entry and icon (Linux)"
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
args = parser.parse_args()
|
|
86
|
+
|
|
87
|
+
if args.install_desktop:
|
|
88
|
+
install_desktop()
|
|
89
|
+
return
|
|
90
|
+
|
|
91
|
+
if args.list:
|
|
92
|
+
pads = list_pads()
|
|
93
|
+
if not pads:
|
|
94
|
+
print(f"No saved pads found in {PADS_DIR}")
|
|
95
|
+
else:
|
|
96
|
+
print(f"Saved pads ({len(pads)}):")
|
|
97
|
+
for pad in pads:
|
|
98
|
+
modified = pad.get("modified", "")[:10] # Just the date part
|
|
99
|
+
print(f" {pad['name']:20} {modified}")
|
|
100
|
+
return
|
|
101
|
+
|
|
102
|
+
# Import app here to avoid loading Textual for --list
|
|
103
|
+
from .app import RecknApp
|
|
104
|
+
|
|
105
|
+
app = RecknApp(pad_name=args.pad_name)
|
|
106
|
+
app.run()
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
if __name__ == "__main__":
|
|
110
|
+
main()
|