name: sayonara
version: 1.5.2-beta3-323a641a
grade: stable
summary: Small and lightweight music player.
description: |
  Sayonara is as a lightweight and fast library manager and music player.
  It holds a lot of features like
  Many supported music and playlist formats
  Media library with search function
  Directory view
  External device support
  Genre organization
  Playlist view organized by tabs
  (Dynamic) playback
  Equalizer
  Metadata editor (including tags from path)
  Lyrics
  Shutdown function
  MP3 Converter
  Customizable spectrum analyzer and level meter
  Last.FM radio and scrobbling
  Soundcloud support
  Internet streams
  Stream recorder
  Podcasts
  Radio Broadcasting
  Multimedia key support
  Desktop integration (DBus Mpris2 compatible)
  2 skins
confinement: strict
base: core18

apps:
  sayonara:
    adapter: full
    command: usr/bin/sayonara
    command-chain:
      - bin/desktop-launch
    desktop: usr/share/applications/sayonara.desktop
    plugs:
      - audio-playback
      - desktop
      - desktop-legacy
      - home
      - mount-observe
      - network
      - network-manager-observe
      - opengl
      - optical-drive
      - removable-media
      - unity7
      - wayland
      - x11
    slots:
      - mpris
    environment:
      # Use GTK3 cursor theme, icon theme and open/save file dialogs.
      QT_QPA_PLATFORMTHEME: gtk3
      # Disable Wayland
      DISABLE_WAYLAND: 1

layout:
  /usr/share/sayonara:
    bind: $SNAP/usr/share/sayonara

parts:
  desktop-base:
    # Additional libraries
    plugin: nil
    stage-packages:
      - libglu1-mesa
      - libgpm2

  desktop-qt5:
    # Support for QT5 
    # https://snapcraft.io/docs/t/desktop-app-support-qt5/11703
    source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
    source-subdir: qt
    plugin: make
    make-parameters: ["FLAVOR=qt5"]
    build-packages:
      - qtbase5-dev
      - dpkg-dev
    stage-packages:
      - libxkbcommon0
      - ttf-ubuntu-font-family
      - dmz-cursor-theme
      - light-themes
      - adwaita-icon-theme
      - gnome-themes-standard
      - shared-mime-info
      - libqt5gui5
      - libgdk-pixbuf2.0-0
      - libqt5svg5 # for loading icon themes which are svg
      - try: [appmenu-qt5] # not available on core18
      - locales-all

  qt5-gtk-platform:
    # GTK theme integration
    # https://snapcraft.io/docs/t/desktop-app-support-qt5/11703
    plugin: nil
    stage-packages:
      - qt5-gtk-platformtheme

  sayonara:
    source: /root/project
    source-type: local
    plugin: cmake
    configflags:
      - -DCMAKE_BUILD_TYPE=Release
      - -DCMAKE_INSTALL_PREFIX=/usr
    override-build: |
      snapcraftctl build
      sed -i 's|Icon=sayonara|Icon=${SNAP}/usr/share/icons/hicolor/256x256/apps/sayonara.png|g' $SNAPCRAFT_PART_INSTALL/usr/share/applications/sayonara.desktop
    build-packages:
      - cmake
      - git
      - libgstreamer-plugins-bad1.0-dev
      - libgstreamer-plugins-base1.0-dev
      - libgstreamer1.0-dev
      - libtag1-dev
      - pkg-config
      - qtbase5-dev
      - qttools5-dev
      - qttools5-dev-tools
      - zlib1g-dev
    stage-packages:
      - gstreamer1.0-plugins-bad
      - gstreamer1.0-plugins-good
      - libgstreamer-plugins-bad1.0-0
      - libgstreamer-plugins-good1.0-0
      - libqt5sql5-sqlite
      - libgcc1
      - libglib2.0-0
      - libgstreamer-plugins-base1.0-0
      - libgstreamer1.0-0
      - libqt5core5a
      - libqt5dbus5
      - libqt5network5
      - libqt5sql5
      - libqt5widgets5
      - libqt5xml5
      - libstdc++6
      - zlib1g
      - libslang2
    plugin: cmake
    after: 
      - desktop-base
      - qt5-gtk-platform
      - desktop-qt5

plugs:
  # Support for common GTK themes
  # https://forum.snapcraft.io/t/how-to-use-the-system-gtk-theme-via-the-gtk-common-themes-snap/6235
  gsettings:
  gtk-3-themes:
    interface: content
    target: $SNAP/data-dir/themes
    default-provider: gtk-common-themes
  icon-themes:
    interface: content
    target: $SNAP/data-dir/icons
    default-provider: gtk-common-themes
  sound-themes:
    interface: content
    target: $SNAP/data-dir/sounds
    default-provider: gtk-common-themes