snd

package module
v1.0.0-rc6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2024 License: MIT Imports: 2 Imported by: 0

README


Discord GitHub Discussions GitHub release (latest by date)

Sales & Dungeons — Thermal Printer as D&D Utility.

With Sales & Dungeons you can create highly customizable handouts, quick reference and much more for your Dungeons and Dragons (or other PnP) Sessions. Most Thermal Printer are small in size and can be taken with you and kept right at the gaming table. Use-cases range from printing out magic items, spells or a letter that the group found to little character sheets of your players to use as DM note. The possibilities are nearly endless!

Printer SetupTested PrinterWiki

Important: If you have trouble getting this to work it's best to drop by our Discord.

Screenshot

Screenshot Generator

Screenshot AI

Features

  • Works on
    • Windows
    • Mac (Intel, M1)
    • Linux (x64, ARM64)
    • Raspberry Pi (ARMv6, ARMv7)
    • Anything else go can be compiled on
  • Extensive templating system through Nunjucks
  • Extensive random generator system
  • Various connection methods
    • Windows Direct Printing
    • Raw USB Printing
    • CUPS (Linux, Mac)
    • Serial
  • Import & Export templates and data sources
  • Fast access to external data sources like Open5e (instant access to SRD monsters, spells and more)
  • Import data from other sources:
    • CSV
    • FoundryVTT Modules
    • Fight Club 5e XML Format
    • 5eTools
  • Access Community Templates, Generators & Data Sources from within the App
  • AI LLM Support (OpenAI, OpenRouter, Custom Local)
    • Generate entries by prompt using the power of AI
    • Translate entries by prompt
    • Execute AI prompts in your templates and generators
    • Support for using Local LLMs (for example via LM Studio) or any custom endpoints that are compatible with OpenAI API
  • Cloud sync for templates, generators and data sources

📁 Download

You can find the latest version on the release page:

🍎 Mac

The mac bundles are not signed at the moment so you might face the following problems when opening the application:

It's not opening because it's from a unverified developer

If your mac is telling you that this app is from a unverified developer you can allow it via the "Privacy & Security" settings. More info: Open a Mac app from an unidentified developer

It's not opening because the app "is damaged"

On M1, M2, etc. it can happen that the app is reported as damaged. Just copy Sales & Dungeons into your Applications folder and execute the following command to allow it to run:

xattr -d com.apple.quarantine "/Applications/Sales & Dungeons.app/"

🐳 Docker

The headless version of Sales & Dungeons (using LibUSB) is also available via a docker container:

  1. docker pull ghcr.io/bigjk/snd:master (container)
  2. docker run --expose 7123:7123 --device=/dev/bus/usb -v /some/place/to/persist:/app/userdata ghcr.io/bigjk/snd:master (change /some/place/to/persist to a folder where the user data should be persisted to)
  3. Open http://127.0.0.1:7123 in your favorite browser
Docker Compose Example
version: "3"
services:
  snd:
    image: ghcr.io/bigjk/snd:master
    ports:
      - "7123:7123"
    devices:
      - "/dev/bus/usb"
    volumes:
      - "/some/place/to/persist:/app/userdata"

Printer Requirements

At the moment Sales & Dungeons only supports the ESC/POS (Epson Standard Code) control codes, which is still one of the most used control code set. Check if a thermal printer you are interested in mentions ESC/POS or Epson in the description or manual.

In general the rule of thumb is:

  • Most cheap chinese thermal printer found on Amazon or AliExpress support it
  • Most epson thermal printer obviously support it
  • A lot of older Serial printer (like Metapace T-1) also support it

More specific information about tested printers can be found in the wiki: Printer-Settings

How It Works

Templates: Templates are created in HTML (and CSS) in combination with the Nunjucks templating language. You can imagine the templates as little websites. That makes it possible to use all the nice and convenient layout options that HTML and CSS has to offer and even include any common framework you might need (e.g. Fontawesome for Icons).

Rendered HTML: After creating a template you can create entries with the data you want and print them. Nunjucks will create the rendered HTML from the data you want to print.

Rendered Image: Then this HTML get's converted to a image. Currently this conversion is done by Chrome via the Chrome Debug Protocol. Although Chrome seems like a huge overkill for just HTML-To-Image conversion it's the standard solution at the moment because it supports most of the modern HTML and CSS features.

ESC / POS Commands: The last step before our awesome template hits the Printer is the conversion from the rendered image to the "draw image" command of the printer.

Printer: The generated command will then be sent to the printer and printed. Now your template is ready to be used!

🎉 🎉 🎉

Printers, Templating & Building

If you want to see what printers were already tested, which settings they need, how the templates work or how you can build Sales & Dungeons yourself please visit the wiki.

Thanks to all contributors ❤

Thanks to JetBrains

This Project is supported with a JetBrains License through the Open Source Support Program.

JetBrains Logo (Main) logo.

Credits

Icons used in the Sales & Dungeons Logo were made by Smashicons, Good Ware from www.flaticon.com

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BuildTime string
View Source
var GitBranch string
View Source
var GitCommitHash string

Functions

func IsDataSourceID added in v0.7.3

func IsDataSourceID(id string) bool

func IsGeneratorID added in v0.7.3

func IsGeneratorID(id string) bool

func IsTemplateID added in v0.7.3

func IsTemplateID(id string) bool

Types

type DataSource

type DataSource struct {
	Name        string `json:"name"`
	Slug        string `json:"slug"`
	Author      string `json:"author"`
	Description string `json:"description"`
	Version     string `json:"version"`
}

DataSource represents a data source in S&D.

func (DataSource) ID

func (ds DataSource) ID() string

type Entry

type Entry struct {
	ID   string                 `json:"id"`
	Name string                 `json:"name"`
	Data map[string]interface{} `json:"data"`
}

Entry represents one data entry in a template or data source.

type Generator added in v0.5.0

type Generator struct {
	Name            string            `json:"name"`
	Slug            string            `json:"slug"`
	Author          string            `json:"author"`
	Description     string            `json:"description"`
	PrintTemplate   string            `json:"printTemplate"`
	PassEntriesToJS bool              `json:"passEntriesToJS"`
	Config          []GeneratorConfig `json:"config"`
	Images          map[string]string `json:"images"`
	DataSources     []string          `json:"dataSources"`
	Version         string            `json:"version"`
}

Generator represents one S&D generator. Instead of working with fixed data entries like the template a generator procedurally generates new entries to print on the spot.

func (Generator) ID added in v0.5.0

func (t Generator) ID() string

type GeneratorConfig added in v0.5.0

type GeneratorConfig struct {
	Key         string      `json:"key"`
	Name        string      `json:"name"`
	Description string      `json:"description"`
	Type        string      `json:"type"`
	Default     interface{} `json:"default"`
}

type Settings

type Settings struct {
	PrinterType     string `json:"printerType"`
	PrinterEndpoint string `json:"printerEndpoint"`
	PrinterWidth    int    `json:"printerWidth"`
	Commands        struct {
		ExplicitInit      bool `json:"explicitInit"`
		Cut               bool `json:"cut"`
		ForceStandardMode bool `json:"forceStandardMode"`
		LinesBefore       int  `json:"linesBefore"`
		LinesAfter        int  `json:"linesAfter"`
		SplitPrinting     bool `json:"splitPrinting"`
		SplitHeight       int  `json:"splitHeight"`
		SplitDelay        int  `json:"splitDelay"`
	} `json:"commands"`
	Stylesheets           []string `json:"stylesheets"`
	SpellcheckerLanguages []string `json:"spellcheckerLanguages"`
	PackageRepos          []string `json:"packageRepos"`
	SyncKey               string   `json:"syncKey"`
	SyncEnabled           bool     `json:"syncEnabled"`
	AIEnabled             bool     `json:"aiEnabled"`
	AIApiKey              string   `json:"aiApiKey"`
	AIModel               string   `json:"aiModel"`
	AIProvider            string   `json:"aiProvider"`
	AIContextWindow       int      `json:"aiContextWindow"`
	AIMaxTokens           int      `json:"aiMaxTokens"`
	AIURL                 string   `json:"aiUrl"`
}

Settings represents the basic settings for S&D.

type Template

type Template struct {
	Name          string                 `json:"name"`
	Slug          string                 `json:"slug"`
	Author        string                 `json:"author"`
	Description   string                 `json:"description"`
	PrintTemplate string                 `json:"printTemplate"`
	ListTemplate  string                 `json:"listTemplate"`
	SkeletonData  map[string]interface{} `json:"skeletonData"`
	Images        map[string]string      `json:"images"`
	Config        []TemplateConfig       `json:"config"`
	DataSources   []string               `json:"dataSources"`
	Version       string                 `json:"version"`
}

Template represents one S&D template.

func (Template) ID

func (t Template) ID() string

type TemplateConfig added in v0.7.3

type TemplateConfig struct {
	Key         string      `json:"key"`
	Name        string      `json:"name"`
	Description string      `json:"description"`
	Type        string      `json:"type"`
	Default     interface{} `json:"default"`
}

Directories

Path Synopsis
cmd
app
Package database represents the data layer of S&D.
Package database represents the data layer of S&D.
Package imexport provides functions to import and export S&D templates and data sources.
Package imexport provides functions to import and export S&D templates and data sources.
vtt
Package log provides logging utilities for S&D and makes it possible to hook into the logging to save the logs somewhere else.
Package log provides logging utilities for S&D and makes it possible to hook into the logging to save the logs somewhere else.
cups
Package cups provides printing for Sales & Dungeons via cups.
Package cups provides printing for Sales & Dungeons via cups.
remote
Package remote provides printing for Sales & Dungeons via a remote endpoint.
Package remote provides printing for Sales & Dungeons via a remote endpoint.
rsnd
Package rsnd provides printing for Sales & Dungeons via a another S&D instance.
Package rsnd provides printing for Sales & Dungeons via a another S&D instance.
usb
Package usb provides printing for Sales & Dungeons via USB.
Package usb provides printing for Sales & Dungeons via USB.
windows
Package windows provides printing for Sales & Dungeons via direct printing on windows.
Package windows provides printing for Sales & Dungeons via direct printing on windows.
Package rendering provides a function to render HTML to images or HTML after JS execution.
Package rendering provides a function to render HTML to images or HTML after JS execution.
rpc
Package server represents the webserver that powers S&D.
Package server represents the webserver that powers S&D.
thermalprinter
epson
Package epson implements the protocol used by most thermal printer, also commonly referred to as ESC or POS commands.
Package epson implements the protocol used by most thermal printer, also commonly referred to as ESC or POS commands.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL