function simple_move_to_trash
Moves all documents from the reMarkable tablet's root directory to trash by uploading an empty root.docSchema file and updating the roothash.
/tf/active/vicechatdev/e-ink-llm/cloudtest/simple_clean_root.py
23 - 104
moderate
Purpose
This function provides a simple way to clean up all remaining documents in the root directory of a reMarkable tablet by effectively moving them to trash. It authenticates with the reMarkable cloud service, retrieves the current root state, identifies all documents present, then uploads an empty root configuration to remove all items from the visible document tree. This is useful for bulk cleanup operations or resetting the tablet's document structure.
Source Code
def simple_move_to_trash():
print("šļø Simple Move to Trash - Clean Remaining Documents")
print("=" * 60)
# Get auth
auth = RemarkableAuth()
user_token = auth.authenticate()
session = auth.get_authenticated_session()
if not session or not user_token:
print("ā Authentication failed")
return
# Get current root state
root_response = session.get('https://eu.tectonic.remarkable.com/sync/v3/files/root.docSchema')
root_response.raise_for_status()
root_content = root_response.text
print(f"š Current root.docSchema:")
print(f" Size: {len(root_content)} bytes")
print(f" Content: {repr(root_content)}")
# Parse current root content
lines = root_content.strip().split('\n')
print(f"\nš Found {len(lines) - 1} items in root:")
remaining_uuids = []
for line in lines[1:]: # Skip version line
if ':' in line:
parts = line.split(':')
if len(parts) >= 3:
uuid = parts[2]
remaining_uuids.append(uuid)
print(f" š UUID: {uuid}")
if not remaining_uuids:
print("š Root is already empty!")
return
print(f"\nšļø Moving {len(remaining_uuids)} documents to trash...")
# Create empty root content (just version line)
empty_root_content = "3\n"
# Upload empty root
root_crc = calculate_crc32c(empty_root_content)
root_headers = {
'Authorization': f'Bearer {user_token}',
'User-Agent': 'reMarkable-desktop-win/3.11.1.1951',
'rm-filename': 'root.docSchema',
'rm-crc32c': root_crc,
'Content-Type': 'application/octet-stream'
}
try:
root_upload_response = session.put(
'https://eu.tectonic.remarkable.com/sync/v3/files',
headers=root_headers,
data=empty_root_content
)
root_upload_response.raise_for_status()
new_root_hash = root_upload_response.text.strip()
print(f"ā
Empty root uploaded: {new_root_hash[:16]}...")
# Update roothash
roothash_response = session.put(
'https://eu.tectonic.remarkable.com/sync/v3/roothash',
headers={
'Authorization': f'Bearer {user_token}',
'User-Agent': 'reMarkable-desktop-win/3.11.1.1951',
'Content-Type': 'text/plain'
},
data=new_root_hash
)
roothash_response.raise_for_status()
print(f"ā
Roothash updated successfully")
print(f"š All documents removed from root - effectively moved to trash!")
except Exception as e:
print(f"ā Error emptying root: {e}")
Return Value
This function does not return any value (implicitly returns None). It performs side effects by modifying the reMarkable cloud state and prints status messages to stdout indicating success or failure of the operation.
Dependencies
requestsjsonhashlibbase64binascii
Required Imports
from auth import RemarkableAuth
import json
import hashlib
import base64
import binascii
Usage Example
# Ensure auth.py with RemarkableAuth class is available
# Ensure calculate_crc32c function is defined
from auth import RemarkableAuth
import hashlib
import base64
import binascii
def calculate_crc32c(data):
# Implementation of CRC32C calculation
crc = binascii.crc32(data.encode('utf-8'))
return base64.b64encode(crc.to_bytes(4, 'big')).decode('utf-8')
# Call the function to move all documents to trash
simple_move_to_trash()
# Output will show:
# - Current root state
# - List of UUIDs being moved
# - Success/failure messages
Best Practices
- This function performs destructive operations - all documents in root will be moved to trash
- Ensure you have backups before running this function as it removes all visible documents
- The function assumes the EU region endpoint (eu.tectonic.remarkable.com) - may need modification for other regions
- Error handling is basic - consider adding more robust error recovery for production use
- The function prints status messages directly - consider using logging for better control in production
- Authentication credentials should be securely managed by the RemarkableAuth class
- The calculate_crc32c function must be properly implemented and available in scope
- Network connectivity to reMarkable cloud services is required
- The function does not provide an undo mechanism - documents can only be recovered from trash through the reMarkable interface
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function move_documents_to_trash 85.1% similar
-
function apply_working_trash_move 84.7% similar
-
function move_document_to_trash 84.7% similar
-
class DocumentToTrashMover 82.9% similar
-
function main_v45 77.7% similar