While mowing the lawn this afternoon I rescued this little fella that flew straight into a cobweb.

Red and black moth on my finger

Notes on getting autostart working for a classic confined snap

Last night I finally managed to get a working build of the Snippet Pixie snap that pretty much works as hoped, but there were a couple of things I had to change in order to get autostart working that I thought it might help others to mention here.

There's a couple of wrinkles due to naming.

The snap is called snippetpixie and uses that in the snapcraft.yaml apps: entry, but the binary and canonical name for the app (as used in meson build etc.) is com.github.bytepixie.snippetpixie, and that's the app's "ID" too. It's a GTK app built with Vala, initially for elementary OS.

This means the .desktop file is usually called com.github.bytepixie.snippetpixie.desktop. So in the app it uses this as the desktop file name when trying to copy and fix it up to create an autostart version, but the DesktopAppInfo class failed to find the file by that name.

Turns out snapd/snapcraft takes that com.github.bytepixie.snippetpixie.desktop file and renames it to snippetpixie_snippetpixie.desktop at some point (I think install time by snapd), making some changes to the Exec line along the way.

This means the DesktopAppInfo class doesn't recognise com.github.bytepixie.snippetpixie.desktop as valid.

In the end I had to add specific code for running as a snap to change the desktop file name to look for, and also be careful about the way the Exec line is changed for the new autostart version to carefully insert the required --start param in the altered command line instead of blindly changing it to com.github.bytepixie.snippetpixie --start.

You can see some of the altered (not very clever, but it works) code in snippetpixie's update_autostart function.

Hope this helps someone else having troubles getting autostart to work for a snap.

One More Thing...

I guess I'm also officially announcing that there's candidate availability of a snap for Snippet Pixie!

It can be installed from the candidate channel with…

sudo snap install snippetpixie --classic --candidate

Any feedback on the snap is warmly welcomed via either the Snapcraft forum's "Call for testing" post, or Snippet Pixie's GitHub Issues.

Get It!!!

Get

Get

Almost Back In The Saddle

Almost Back In The Saddle
RustyElm

 
 
00:00 /
 
1X
 

Hello, my name is Ian Jones, and this is the RustyElm microcast, a short, very ad-hoc journal of my attempt to learn Rust and Elm in order to build a side project.

I had a draft podcast way back in mid September 2018, but never finished it as I was just too damn busy.

Things have been kinda crazy, starting with working on multiple huge releases of WP Offload Media, and helping out with WP Offload SES. Giving my best 8 hours or more of mental energy a day to my work for Delicious Brains doesn't leave much in the tank for late night hacking. I very much enjoy working on WP Offload Media, it's an awesome plugin, and I enjoy having primary responsibility for it's development, so I naturally put a lot of my energy into it and am always thinking about it.

Having said that, I did get an itch for something I needed to build that also took my eye off of RustyElm and learning Rust and Elm, that being: Snippet Pixie.

Snippet Pixie is "Your little expandable text snippet helper", for Linux. I couldn't find a good Linux application alternative to the likes of Text Expander or Dash (which I currently use on macOS). So, in the end, I kinda just had to build it, otherwise known as scratching my itch. My primary desktop Linux distribution is elementary OS, so that's what I built it for, in Vala.

Turns out that may have helped me get my shrivelled little brain around the Rust concept of Ownership, as Vala also doesn't let you throw objects around without taking into consideration ownership. It caught me out a few times when the complier complained about not being able to assign an unowned reference etc, and reminded me a lot of how Rust handles ownership. Even though things aren't exactly the same, I'm going to chalk that one up as some progress in my learning of Rust, alright?!

Anyhow, Snippet Pixie recently had a momentous release that included date/time, clipboard, embedded snippets and cursor placeholders, adding a whole new level of functionality. And even though I'm in the middle of trying to get a snap sorted so it'll be usable on many more Linux distributions, and still have plans for more improvements to Snippet Pixie, I feel like I no longer have a huge pressure to keep adding functionality and can relax a little bit on it.

As such, I'm starting to look at getting started with my Rust and Elm based project for my evening recreational programming. Stay tuned.

Micro.blog: @ianmjones

Twitter: @ianmjones

Snippet Pixie 1.2 released with support for placeholders πŸŽ‰οΈ

I'm very proud to announce that Snippet Pixie now includes support for placeholders! πŸŽ‰οΈ

This release took an immense amount of work, with lots of thought taken in the design of the placeholders feature, hopefully you find these new super powers useful!

  • Date/Time: Insert the current or calculated date/time with configurable format.
  • Clipboard: Insert the text contents of the clipboard.
  • Snippets: Insert snippets in your snippets!
  • Cursor: Set where the cursor should end up after the snippet has expanded.

Read on for a summary of the placeholders feature and how to use the different types of placeholder.

Placeholders

All placeholders are delimited (wrapped) by $$, with the placeholder name starting with an @ symbol.

For example, today's date can be inserted with $$@date$$.

Some placeholders allow for extra arguments when : follows their name and that is followed by the argument. For example a format for a date, or the abbreviation for a snippet. Check the following descriptions for each placeholder for more details.

To use $$ in your snippet body, escape the second $ with a backslash like so: $\$.

@date

Quick Examples:

  • Today's date with system format: $$@date$$
  • Today's date with custom format: $$@date:%Y-%m-%d %H:%M:%S$$
  • Tomorrow's date with system format: $$@date@+1D$$
  • Date 2 weeks from today with custom format: $$@date@+2W:%x$$
  • Time 3 hours from now: $$@time@+3H$$

@time is an alias for @date, with one important difference, the default output if no format specified is the default time format (%X) rather than default date format (%x).

The optional format specified after : can take a format string as detailed in the GLib.DateTime.format function's docs.

The optional date calculation starts with an @ after the placeholder name, followed by a signed integer and unit. The unit types are as follows:

  • Y: Years
  • M: Months
  • W: Weeks
  • D: Days
  • h: Hours
  • m: Minutes
  • s: Seconds

You can apply more than one date calculation, for example +2h+30m adds 2 hours and 30 minutes to the current time.

You can use both positive (+) and negative calculations, for example -3D takes 3 days from the current date.

@clipboard

When $$@clipboard$$ is part of a snippet's body, when its abbreviation is expanded the current text contents of the clipboard will replace the placeholder.

@snippet

You can have up to three levels of embedded snippets with the @snippet placeholder.

The abbreviation for the snippet to be embedded is entered after :, for example $$@snippet:sigg;$$ expands the snippet with abbreviation sigg; in place of the placeholder.

@cursor

Adding $$@cursor$$ to a snippet's body will put the cursor in its place after expansion instead of at the end of the expanded text.

If $$@cursor$$ is entered more than once in a snippet's body or via snippet embedding, then the last occurrence of the cursor placeholder wins.

Get It!!!

Get

This is what the snapcraft store\'s usage map looks like for an app when you're the only person that knows there's a beta snap available. 😜

Snippet Pixie beta in Snap Store

Snippet Pixie 1.1 adds snippets export and import

I'm super happy to announce that Snippet Pixie 1.1 has been released. πŸŽ‰

This release includes two features that go hand in hand, snippets export and import.

Snippet Pixie is a great way to build a library of time and keystroke saving short text abbreviations that automatically expand while you type, but up until this release you could only add snippets to your second machine by either manually adding them again or finding and copying the settings database.

Export

It's now possible to export your snippets to a JSON format file for the purpose of backup or transfer to another machine for import. Now when you add new snippets on one machine you can quickly add them to another machine.

Import

When using the import feature Snippet Pixie by default will not overwrite existing snippets with the same abbreviation, but you can optionally do that if you've made changes to the abbreviations on one installation and want to apply them to another.

For safety, the import feature also does not delete any existing snippets.

UI

The welcome screen in Snippet Pixie now includes an Import Snippets option to get new installations up and running quickly. If you've already got some snippets in Snippet Pixie then you can use the "Import snippets..." option from the cog menu.

The cog menu is where you'll find the "Export snippets..." option too, it's enabled if you have some snippets to export.

CLI

Want to script an automatic backup or import? Snippet Pixie has your back as it also has new command line options for export and import.

-e, --export=filename
Export snippets to file

-i, --import=filename
Import snippets from file, skips snippets where abbreviation already exists

--force
If used in conjunction with import, existing snippets with same abbreviation are updated

File Format

Some people might be wondering why I picked JSON as the file format. The primary reason is flexability and general support for the format. There are something like eleventy million utilities for handling JSON, so if you want to manipulate or generate your own file of snippets you'll be able to do it easily.

I'll document the format properly at some point, but it's very simple as this vastly trimmed down export of some of my snippets shows...

{
  "generator" : "com.github.bytepixie.snippetpixie",
  "version" : 101,
  "data" : [
    {
      "snippets" : [
        {
          "abbreviation" : "joy`",
          "body" : "πŸ˜‚"
        },
        {
          "abbreviation" : "ksig`",
          "body" : "Kind regards,\n\nIan"
        },
        {
          "abbreviation" : "shrug`",
          "body" : "Β―\\_(ツ)_/Β―"
        },
        {
          "abbreviation" : "sp`",
          "body" : "Snippet Pixie"
        },
        {
          "abbreviation" : "spu`",
          "body" : "[www.snippetpixie.com](https://www.snippetpixie.com)"
        }
      ]
    }
  ]
}

The generator and version elements are very important, Snippet Pixie will not currently import a file that doesn't have those two elements with those same values as they signify a format that it understands.

The data array contains a list of data types with data that can be imported, currently there's only snippets.

Each of the objects in the snippets array contains only an abbreviation and body, on export they are ordered alphabetically by the abbreviation and if there are duplicates (it's possible) then by a hidden id which typically means by order of addition unless entries have been renamed. Due to this ordering, if overwriting duplicates on import is allowed then last duplicate in the file will "win", but by default first entry will "win" if the abbreviation does not exist in Snippet Pixie's library already.

As you can see from the example, it's UTF-8 and supports emoji and new lines (those \n bits), and characters like \ are escaped etc.

Get It!

As always, you can get Snippet Pixie from the elementary AppCenter.

Hope you like it, if you have any feature requests or problems with Snippet Pixie, please stop by the GitHub repository and share your thoughts!

Snippet Pixie start screen with import snippets option