Giter Site home page Giter Site logo

inkscape-figures-manager-rs's Introduction

Inkscape Figures Manager

A simple CLI tool to manage figures in created with Inkscape. It also provides shortcuts for common operations when creating technical figures that have the style of TikZ figures. This crate is heavily inspired by Gilles Castel's Inkscape figures manager and Inkscape shortcut manager. The reason for creating this crate is that his tools only support Linux. This crate is written to be used in macOS (but could easily be extended to work for other operating systems).

Installation

cargo install inkscape-figures-manager

Then, create a template SVG file $HOME/.config/ifm/template.svg. This file will be used as a template when creating new figures. I recommend pinning commonly used colors and setting the dimensions. The dimensions should be set to be equal to the dimensions of your LaTeX document, which can be set using the geometry package. An example template is template.svg in this repository.

Usage

inkscape-figures-manager start
inkscape-figures-manager list
inkscape-figures-manager new <path>
inkscape-figures-manager edit <path>

list lists all SVG files in all subdirectories from where the command is run. This can be used by a picker to select a figure to edit. I recommend using a picker to quickly open figures from within a project. You can use a picker tool such as choose. I use telescope.nvim in my Neovim setup; see my config for the extension I made for telescope (copy the lua/telescope/ and lua/telescope_inkscape_figures/ directories).

new creates a new figure with the specified path, and opens it. This command requires a template SVG file in $HOME/.config/ifm/template.svg, so make sure to create one. In a Neovim setup, you can use the following keymap to create new figures with Ctrl+F,

vim.keymap.set(
    "i",
    "<C-f>",
    "<Esc><cmd>exec 'r!inkscape-figures-manager new -f -d figures -l \"'.getline('.').'\"'<CR>kkkkkkddjjjf{a"
)

edit opens the inkscape for a specified path. This command will error if the path does not exist, or if the file is not an SVG.

File watcher

You can start the file watcher and the shortcut listener by executing the following command,

inkscape-figures-manager start

This command does two things:

  1. Whenever an SVG is saved in any subdirectory where the command was executed, it will compile it as a PDF to be used in LaTeX;
  2. It listens for keyboard shortcuts, as defined in the next section.

Keyboard shortcuts

To apply a style to an Inkscape object, select the object and hold Alt/Option. While holding Alt, press the keys as defined below. It will remove all the current styles of the object and put the style as specified.

Style (KEY)
Stroke width: Normal (1) Thick (2) Very thick (3)
Stroke: Solid (Q) Dashed (W) Dotted (E)
Fill White (A) Gray (S) Black (D)
Arrow Start (Z) End (X) --

Important

On macOS, the shortcuts require you to give accessibility permissions to the terminal that you are running the command in.

Warning

The program grabs all keyboard interactions while Alt/Option is held. So, no other shortcuts involving Alt/Option will be triggered while it is running.

Note

The defined keyboard shortcuts have no semantic meaning, but are defined to be easily reachable with only the left hand on a US keyboard.

Creating Figures

For an example of the figures that can be created, see my university notes repository. Alternatively, see Gilles Castel's master thesis, which contains over 100 figures.

For colors, you can use one of the qualitative color sets defined by colorbrewer.

For advice on how to create good figures, see the TikZ guidelines.

Operating System Support

At the moment, this crate only supports macOS. It can easily be extended to support other operating systems by providing a clipboard implementation for the specific operating system (see src/clipboard). If this is something you are interested in, open an issue or create a pull request.

Alternatively, if you want to use a crate like this one on Linux, see Gilles Castel's Inkscape figures manager.

inkscape-figures-manager-rs's People

Contributors

cristianpjensen avatar

Stargazers

 avatar Chenyu Zhang avatar  avatar  avatar

Watchers

 avatar

inkscape-figures-manager-rs's Issues

Error while creating figure

Don't know much rust, can't figure out why is this error cropping up

error: unexpected argument '-f' found

  tip: to pass '-f' as a value, use '-- -f'

Usage: inkscape-figures-manager new <PATH>

Shortcuts manager

Hi,

I noticed you were trying to create a shortcut manager. I've created something similar for Mac-OS here

Haven't added README yet, but until now I'm able to

  • handle key-cords (adding strokes, colours and fills) and
  • text input using terminal of choice, I installed Alacritty specifically for this purpose. iTerm seems to be slow in launching.
  • styles manager (quickly save style to disk for later use)
  • objects manager (reusable objects to be saved to disk)

In case you want to try it out you would need to install PyObjC and PyObjC-core that allows system level keytaps for macOS. Run the main file after the inkscape window is open and rest of you'll be getting a verbose output in terminal.

For some reason, it was working from vscode but not from terminal (haven't tried again). So if program is crashing in terminal, launch it from vs-code. Mac may prompt for accessibility permission as vs-code will be listening to keytaps.

In a week or so I'll be modifying the code and making it more organised. If you want to take join along, we could share the efforts and I could give you a quick rundown of how it works. Let me know!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.