Skip to content

Rinkaa/Aseprite_OpenInSameWindow

Repository files navigation

AsepriteExtension_OpenInSameWindow

Page: https://github.com/Rinkaa/Aseprite_OpenInSameWindow

Language: English | 中文

Open files in an existing Aseprite window.

Most users do not need this extension. It is mainly useful when external tools such as Godot invoke aseprite: the launcher can reuse an existing Aseprite instance and open newly requested files in that same instance.

Runtime Requirements

  • Python 3

Installation And Usage

Install From A Release Package

  • Download and extract aseprite-openinsamewindow-<version>.zip.
  • Copy aseprite-openinsamewindow.sh (Linux) or aseprite-openinsamewindow.bat (Windows, untested) to the same directory as the Aseprite executable. If you do not want to place it there, you can specify where to find Aseprite later; see below.
  • Copy aseprite-openinsamewindow-server.py from the extracted package to the same directory as the .sh/.bat file. It only uses the Python standard library.
  • In Aseprite, install the extracted aseprite-openinsamewindow.aseprite-extension from Edit > Preferences > Extensions > Add Extension.
  • Use the .sh or .bat wrapper as if it were Aseprite. Files opened through this wrapper will reuse the previous Aseprite instance.
  • Special usage: pass --shutdown-server to the .sh or .bat wrapper to stop the long-running event server process.

Build And Use From Source

  • Run make package to create a release package. You can also copy the development files directly to the matching locations described in "Install From A Release Package".
  • During development, if you have not installed the .aseprite-extension through Aseprite's Add Extension dialog, you can run aseprite --script extension/aseprite-openinsamewindow-extension.lua for a simple test.

Details

If the wrapper is not in the same directory as the Aseprite executable, it will try to find aseprite from the environment. You can also set ASEPRITE_BIN explicitly. For example, with the .sh wrapper:

ASEPRITE_BIN=/path/to/aseprite ./aseprite-openinsamewindow.sh /path/to/file.aseprite

The default endpoint is 127.0.0.1:21204. To change the port, set ASEPRITE_OPENINSAMEWINDOW_PORT for the server. Because the Lua side has no direct way to read that value, you must also change the PORT value at the top of the Lua file to the same port.

At runtime, the server writes a temporary PID file such as /tmp/aseprite-openinsamewindow-<uid>.pid to record the server process, which helps shut down an old server process.

Implementation Overview

  • If not already running, start a localhost-only WebSocket server process that publishes open-file events. It keeps running after the shell script exits.
    • Pass --shutdown-server to the shell script to stop the already running server process.
  • If not already running, start an Aseprite instance. It keeps running after the shell script exits.
    • The Aseprite Lua extension starts a WebSocket client and listens for open-file events.
  • Each wrapper invocation reuses the existing WebSocket server and sends open-file events to the WebSocket client inside the existing Aseprite instance.

License

MIT

About

Open in an existing Aseprite window. Useful for calling from another program (Godot, Blender, etc.).

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors