apt-get install dbus-x11 kmod weston
-
Sets up user linger and units: The script enables
lingerfor the current user so their user-level systemd instance can run without an active login, and installs theuser-network-online@.serviceunit at the system level plus anetwork-online.targetmarker unit in the user-level systemd directory. -
Bridges system network-online to user instance: The
user-network-online@.serviceruns as a system service afternetwork-online.target, and usessystemctl --user start network-online.target(with the appropriateXDG_RUNTIME_DIR) to trigger a correspondingnetwork-online.targetin the user’s systemd instance. -
Enables automatic startup on boot: By enabling
user-network-online@<UID>.servicewithsystemctl enable --now, the system ensures that whenever the system reachesmulti-user.targetand the network is online, the user-levelnetwork-online.targetis started automatically for that user.
Rebuilding and Recompressing a PDF with pdfimages, jbig2enc, jbig2topdf.py, and a Python Image-Replacement Script
This article explains a full workflow to:
- Extract images from an existing PDF (PDF A) using
pdfimagesfrom the Poppler suite, - Convert all extracted images to JBIG2 format using
jbig2enc, - Assemble those JBIG2 images into a temporary JBIG2-only PDF (PDF B) with
jbig2topdf.py, and - Replace all raster images in the original PDF A with the JBIG2 images from PDF B using a Python script based on
pypdf.
The end result is an output PDF that keeps the original structure of PDF A (bookmarks, annotations, vector graphics, etc.) while replacing its raster images with JBIG2-compressed images taken from PDF B, giving you both smaller size and better preservation of the original PDF’s logical structure.
- Color selection and storage: Users choose a color via an
<input type="color">control and click “Add” to append that color to a history list. - Rich visual samples per history item: Each history entry displays a 50×50 color box, text styled in the color, and three line samples (1px, 3px, 5px) to preview how the color looks in different uses.
- Clickable history for re-selection: Clicking any history item sets the picker back to that color, enabling quick reuse and comparison of previously selected colors.
- Reads the first page of an input PDF, optionally resizes it to a specified physical size, adds a configurable light gray border, and converts it into a “card” page while preserving aspect ratio.
- Computes the optimal tiling of the card on an A4 sheet (portrait or landscape) without further scaling, then generates a single tiled output page containing a grid of card copies.
- Provides flexible CLI options for source and card dimensions in millimeters, plus a
--no-resize-cardflag to bypass card scaling, all implemented purely with pypdf (no external PDF engines).
-
Configurable Grid Splitting via CLI Options
- Uses
argparseto accept an input PDF path, output PDF path, and optional--colsand--rowsarguments, allowing the user to define how many horizontal and vertical splits to apply (default: 2 columns × 4 rows).
- Uses
-
Precise Page Cropping Based on Page Dimensions
- Reads the first page of the input PDF, calculates the page width and height, and derives each tile’s size by dividing these dimensions by the specified number of columns and rows. It then computes crop coordinates for each grid cell.
This script provides a practical template for a simple, smartphone-friendly file upload tool:
- A clean HTML form and a small JavaScript snippet for previewing files.
- Safe and robust server-side handling using
aiohttp. - Automatic directory creation and filename conflict avoidance.
- Easy access from mobile devices via a web browser.
If you need a lightweight way to upload photos or documents from your phone to your own server, this example is a solid starting point that you can extend with authentication, HTTPS, or additional features as needed.
This sample code shows how to use Playwright and Chrome DevTools Protocol (CDP) in Python to capture network requests and responses from a real Chrome browser and save them as JSON.
The main flow is:
-
Find a free TCP port The script uses
socketto get an available local port for Chrome’s--remote-debugging-port. -
Launch Chrome with CDP enabled