@hnode/tidy 0.20.1 → 0.21.0
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.
- package/README.md +20 -4
- package/bin/tidy.js +7 -4
- package/desktop/core.js +6 -4
- package/desktop/layout-editor.js +171 -0
- package/desktop/main.js +47 -18
- package/desktop/manage.js +1 -1
- package/desktop/native/macos.swift +6 -0
- package/desktop/package-lock.json +2 -2
- package/desktop/package.json +1 -1
- package/desktop/renderer.js +14 -3
- package/desktop/style.css +15 -0
- package/dist/tidy@hnode.shell-extension.zip +0 -0
- package/docs/DEVELOPMENT.md +9 -3
- package/docs/MACOS.md +1 -1
- package/docs/README.en.md +13 -4
- package/docs/RELEASING.md +40 -14
- package/lib/layoutConfig.js +138 -0
- package/lib/layouts.js +21 -6
- package/lib/translations.json +65 -6
- package/metadata.json +2 -2
- package/package.json +3 -2
- package/scripts/manage.py +86 -13
- package/dist/winubun@winubun.local.shell-extension.zip +0 -0
package/scripts/manage.py
CHANGED
|
@@ -14,7 +14,8 @@ sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
|
14
14
|
from i18n import _
|
|
15
15
|
|
|
16
16
|
ROOT = Path(__file__).resolve().parent.parent
|
|
17
|
-
UUID = '
|
|
17
|
+
UUID = 'tidy@hnode'
|
|
18
|
+
LEGACY_UUIDS = ('winubun@winubun.local', 'tidy@hnode.dev')
|
|
18
19
|
DATA = Path(os.environ.get('XDG_DATA_HOME', Path.home() / '.local/share'))
|
|
19
20
|
STATE = Path(os.environ.get('XDG_STATE_HOME', Path.home() / '.local/state')) / 'winubun'
|
|
20
21
|
DEST = DATA / 'gnome-shell/extensions' / UUID
|
|
@@ -109,6 +110,55 @@ def finish_update():
|
|
|
109
110
|
AUTOSTART.unlink(missing_ok=True)
|
|
110
111
|
|
|
111
112
|
|
|
113
|
+
def print_update_notice(requires_login, stream=None):
|
|
114
|
+
stream = stream or sys.stdout
|
|
115
|
+
print(file=stream)
|
|
116
|
+
if requires_login:
|
|
117
|
+
print(_('[Login required] Log out and log back in to apply the update.'), file=stream)
|
|
118
|
+
print(_('Tidy will start automatically at the next login. Turning the extension off and on does not apply the new code.'), file=stream)
|
|
119
|
+
else:
|
|
120
|
+
print(_('[Update notice] GNOME extension code updates require logging out and back in.'), file=stream)
|
|
121
|
+
print(_('This extension code version is already loaded, so no logout is needed this time.'), file=stream)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def recover_settings(directory):
|
|
125
|
+
schema_dir = directory / 'schemas'
|
|
126
|
+
if schema_dir.exists():
|
|
127
|
+
env = dict(os.environ, GSETTINGS_SCHEMA_DIR=str(schema_dir))
|
|
128
|
+
subprocess.run(['gjs', '-m', str(directory / 'scripts/recover.js')], env=env, check=True)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def migrate_legacy():
|
|
132
|
+
installations = []
|
|
133
|
+
for uuid in LEGACY_UUIDS:
|
|
134
|
+
legacy = DATA / 'gnome-shell/extensions' / uuid
|
|
135
|
+
if legacy.is_symlink():
|
|
136
|
+
raise RuntimeError(_('Manage symlink installations manually: {path}', path=legacy))
|
|
137
|
+
registered = extension_info(uuid)
|
|
138
|
+
if not registered and not legacy.exists():
|
|
139
|
+
continue
|
|
140
|
+
if registered:
|
|
141
|
+
set_enabled(uuid, False)
|
|
142
|
+
wait_for_extension(uuid, False)
|
|
143
|
+
installations.append((uuid, legacy, registered))
|
|
144
|
+
if not installations:
|
|
145
|
+
return False
|
|
146
|
+
# Keep the original schema and state directory so custom shortcuts and the
|
|
147
|
+
# settings recovery journal survive the UUID change. Stop all old copies
|
|
148
|
+
# before recovering shared settings or restoring another tiler.
|
|
149
|
+
for _uuid, legacy, _registered in installations:
|
|
150
|
+
recover_settings(legacy)
|
|
151
|
+
restore_competitors()
|
|
152
|
+
for uuid, legacy, registered in installations:
|
|
153
|
+
if registered and registered.get('type') != 1:
|
|
154
|
+
if not shell_call('UninstallExtension', '(s)', (uuid,))[0]:
|
|
155
|
+
raise RuntimeError(_('GNOME could not remove the previous Tidy extension.'))
|
|
156
|
+
if legacy.exists():
|
|
157
|
+
shutil.rmtree(legacy)
|
|
158
|
+
print(_('Moved Tidy to {uuid}. Your settings and custom shortcuts have been kept.', uuid=UUID))
|
|
159
|
+
return True
|
|
160
|
+
|
|
161
|
+
|
|
112
162
|
def run(*args, check=True):
|
|
113
163
|
return subprocess.run(args, check=check, text=True, capture_output=True,
|
|
114
164
|
env=dict(os.environ, LC_ALL='C'))
|
|
@@ -181,6 +231,10 @@ def install(archive=None):
|
|
|
181
231
|
raise RuntimeError(_('The bundled extension does not match this installer. Download Tidy again.'))
|
|
182
232
|
if DEST.is_symlink():
|
|
183
233
|
raise RuntimeError(_('Manage symlink installations manually: {path}', path=DEST))
|
|
234
|
+
for uuid in LEGACY_UUIDS:
|
|
235
|
+
legacy = DATA / 'gnome-shell/extensions' / uuid
|
|
236
|
+
if legacy.is_symlink():
|
|
237
|
+
raise RuntimeError(_('Manage symlink installations manually: {path}', path=legacy))
|
|
184
238
|
# The session may need to discover a first installation at the next login.
|
|
185
239
|
# Keep the original tiler active until Tidy is actually available.
|
|
186
240
|
registered = extension_info()
|
|
@@ -197,14 +251,16 @@ def install(archive=None):
|
|
|
197
251
|
package.extractall(DEST)
|
|
198
252
|
if 'schemas/gschemas.compiled' not in package.namelist():
|
|
199
253
|
run('glib-compile-schemas', '--strict', str(DEST / 'schemas'))
|
|
254
|
+
migrated = migrate_legacy()
|
|
200
255
|
install_launcher()
|
|
201
256
|
if not registered or registered.get('version') != metadata['version']:
|
|
202
257
|
schedule_update(metadata['version'])
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
258
|
+
if registered or migrated:
|
|
259
|
+
print(_('The previous Tidy has been stopped for this session.'))
|
|
260
|
+
print_update_notice(True)
|
|
206
261
|
return
|
|
207
262
|
activate()
|
|
263
|
+
print_update_notice(False)
|
|
208
264
|
|
|
209
265
|
|
|
210
266
|
def activate():
|
|
@@ -214,6 +270,19 @@ def activate():
|
|
|
214
270
|
expected = json.loads((DEST / 'metadata.json').read_text())['version']
|
|
215
271
|
if registered.get('version') != expected:
|
|
216
272
|
raise RuntimeError(_('New Tidy code is installed. Please log out and log back in to apply it automatically.'))
|
|
273
|
+
# Shell exposes metadata before its asynchronous module import finishes.
|
|
274
|
+
# During that import it uses ERROR with an empty error message. Do not
|
|
275
|
+
# change enabled/disabled settings until loading has actually completed.
|
|
276
|
+
for attempt in range(50):
|
|
277
|
+
state = registered.get('state')
|
|
278
|
+
if state in (1, 2, 6):
|
|
279
|
+
break
|
|
280
|
+
if state in (3, 4, 99) and (state != 3 or registered.get('error')):
|
|
281
|
+
raise RuntimeError(_('Tidy extension error: ') + (registered.get('error') or _('Unknown error')))
|
|
282
|
+
time.sleep(0.2)
|
|
283
|
+
registered = extension_info()
|
|
284
|
+
else:
|
|
285
|
+
raise RuntimeError(_('Extension transition timed out: {uuid}', uuid=UUID))
|
|
217
286
|
STATE.mkdir(parents=True, exist_ok=True)
|
|
218
287
|
handover = STATE / 'handover.json'
|
|
219
288
|
previous = json.loads(handover.read_text()) if handover.exists() else []
|
|
@@ -229,8 +298,8 @@ def activate():
|
|
|
229
298
|
info = extension_info()
|
|
230
299
|
if info.get('state') == 1:
|
|
231
300
|
break
|
|
232
|
-
if info.get('state') == 3:
|
|
233
|
-
raise RuntimeError(_('Tidy extension error: ') + info
|
|
301
|
+
if info.get('state') == 3 and info.get('error'):
|
|
302
|
+
raise RuntimeError(_('Tidy extension error: ') + info['error'])
|
|
234
303
|
time.sleep(0.1)
|
|
235
304
|
else:
|
|
236
305
|
raise RuntimeError(_('Tidy activation failed. Restoring the previous tiling configuration.\n') + json.dumps(info, ensure_ascii=False))
|
|
@@ -252,6 +321,16 @@ def apply_update():
|
|
|
252
321
|
raise RuntimeError(_('GNOME has not registered Tidy yet. Launch Tidy from the app list.'))
|
|
253
322
|
|
|
254
323
|
|
|
324
|
+
def status():
|
|
325
|
+
info = extension_info()
|
|
326
|
+
print(json.dumps(info, ensure_ascii=False, indent=2) if info else _('The extension is not registered in the current session.'))
|
|
327
|
+
if (STATE / 'pending-update.json').exists():
|
|
328
|
+
expected = json.loads((DEST / 'metadata.json').read_text())['version']
|
|
329
|
+
if info.get('version') != expected:
|
|
330
|
+
# Keep stdout machine-readable when GNOME returned a JSON status.
|
|
331
|
+
print_update_notice(True, sys.stderr)
|
|
332
|
+
|
|
333
|
+
|
|
255
334
|
def uninstall():
|
|
256
335
|
if DEST.is_symlink():
|
|
257
336
|
raise RuntimeError(_('Remove symlink installations manually: {path}', path=DEST))
|
|
@@ -262,10 +341,7 @@ def uninstall():
|
|
|
262
341
|
elif DEST.exists():
|
|
263
342
|
print(_('The extension is not registered in this session. Checking settings recovery.'))
|
|
264
343
|
# Also recover settings if a Shell crash prevented disable() from running.
|
|
265
|
-
|
|
266
|
-
if schema_dir.exists():
|
|
267
|
-
env = dict(os.environ, GSETTINGS_SCHEMA_DIR=str(schema_dir))
|
|
268
|
-
subprocess.run(['gjs', '-m', str(DEST / 'scripts/recover.js')], env=env, check=True)
|
|
344
|
+
recover_settings(DEST)
|
|
269
345
|
restore_competitors()
|
|
270
346
|
finish_update()
|
|
271
347
|
if registered:
|
|
@@ -293,9 +369,6 @@ def main():
|
|
|
293
369
|
open_preferences()
|
|
294
370
|
elif args.command == 'prefs':
|
|
295
371
|
open_preferences()
|
|
296
|
-
elif args.command == 'status':
|
|
297
|
-
info = extension_info()
|
|
298
|
-
print(json.dumps(info, ensure_ascii=False, indent=2) if info else _('The extension is not registered in the current session.'))
|
|
299
372
|
else:
|
|
300
373
|
globals()[args.command]()
|
|
301
374
|
|
|
Binary file
|