---

name: flameshot
adopt-info: flameshot
base: core24
summary: Powerful yet simple to use screenshot software
description: |
  A powerful open source screenshot and annotation tool for Linux, Flameshot
  has a varied set of markup tools available, which include Freehand drawing,
  Lines, Arrows, Boxes, Circles, Highlighting, Blur. Additionally, you can
  customise the color, size and/or thickness of many of these image annotation
  tools.
grade: stable
confinement: strict
compression: lzo
platforms:
  amd64:
    build-on: amd64
    build-for: amd64


apps:
  flameshot:
    command: usr/bin/flameshot
    desktop: usr/share/applications/org.flameshot.Flameshot.desktop
    extensions:
      - kde-neon-6
    environment:
      XDG_DATA_DIRS: $SNAP/share:$XDG_DATA_DIRS
    slots: [dbus-flameshot]
    plugs:
      - home
      - desktop
      - wayland
      - gsettings
      - removable-media
      - network
      - network-bind

parts:
  flameshot:
    #source: ./
    source: https://github.com/flameshot-org/flameshot.git
    plugin: cmake
    build-packages:
      - git
    cmake-parameters:
      - -DFLAMESHOT_ICON=/snap/flameshot/current/usr/share/icons/hicolor/scalable/apps/flameshot.svg
      - -DCMAKE_INSTALL_PREFIX=/usr
      - -DUSE_WAYLAND_CLIPBOARD=1
    source-type: git
    override-pull: |
      craftctl default
      # remove release candidates
      last_committed_tag="$(git tag -l --sort=-v:refname | grep -v rc | head -1)"
      git_revno="$(git rev-list $(git describe --tags --abbrev=0)..HEAD --count)"
      git_hash="$(git rev-parse --short HEAD)"
      snapcraftctl set-version "${last_committed_tag}+git${git_revno}.${git_hash}"
    override-build: |
      craftctl default
      # Correct the Icon path
      sed -i 's|^Icon=.*|Icon=${SNAP}/usr/share/icons/hicolor/scalable/apps/org.flameshot.Flameshot.svg|' ${CRAFT_PART_INSTALL}/usr/share/applications/org.flameshot.Flameshot.desktop
      sed -i 's/^\(Name\(\[.\+\]\)\?=.*\)$/\1 (Snap Edition)/g' ${CRAFT_PART_INSTALL}/usr/share/applications/org.flameshot.Flameshot.desktop

slots:
  # Depending on in which environment we're running we either need
  # to use the system or session DBus so we also need to have one
  # slot for each.
  dbus-flameshot:
    interface: dbus
    bus: session
    name: org.flameshot.Flameshot

layout:
  /usr/share/flameshot/translations:
    symlink: $SNAP/usr/share/flameshot/translations
