Create desktop entry (icon) for one of multiple binaries

Hi,

I already have my application (auto-cpufreq) packaged as snap package.

However, now as part of the following branch GUI (GTK) version of app has been created. If auto-cpufreq-installer is used, result will be 2 binaries. One auto-cpufreq (cli) and auto-cpufreq-gtk (GTK) for which desktop entry (icon) is also created and everything works as intended.

Hence, I wanted to have same changes as part of auto-cpufreq snap package. As part of following snapcraft.yaml changes auto-cpufreq desktop entry (pointing to auto-cpufreq-gtk) is created.

But, once I click on this icon (desktop entry) I’ll get following error Failed to launch desktop file didn't specify exec field.

I have a feeling this is because there’s no mention of auto-cpufreq-gtk in in parts section of snapcraft.yaml, I tried couple of things but then the snpacraft build fails and I’m not sure what’s the best convention to follow in this case.

I hope someone has some ideas or pointers how to address my issue, thanks!

snapcraft.yaml contents:

name: auto-cpufreq
base: core22
summary: Automatic CPU speed & power optimizer for Linux
description: |
  Automatic CPU speed & power optimizer for Linux based on active
  monitoring of laptop's battery state, CPU usage and system load.
  Ultimately allowing you to improve battery life without making
  any compromises.

license: LGPL-3.0
grade: stable
confinement: strict
adopt-info: auto-cpufreq

compression: lzo

parts:
  auto-cpufreq:
    plugin: python
    python-packages:
       - setuptools
       - wheel
       - requests
    build-packages:
       - gcc
       - python3-dev
       - libgirepository1.0-dev
       - libcairo2-dev
    stage-packages:
       - coreutils
       - dmidecode
    source: .
    override-pull: |
      snapcraftctl pull
      snapcraftctl set-version `grep ^VERSION $SNAPCRAFT_PART_SRC/setup.py | sed 's/.*"\(.*\)"/\1/'`

  deploy-scripts:
    plugin: dump
    source: scripts
    organize:
      cpufreqctl.sh: usr/bin/cpufreqctl.auto-cpufreq
      snapdaemon.sh: usr/bin/snapdaemon

plugs:
   etc-auto-cpufreq-conf:
    interface: system-files
    write:
    - /etc/auto-cpufreq.conf

apps:
  auto-cpufreq:
    command: bin/auto-cpufreq
    environment:
      PYTHONPATH: $SNAP/usr/lib/python3/site-packages:$SNAP/usr/lib/python3/dist-packages:$PYTHONPATH
      LC_ALL: C.UTF-8
      LANG: C.UTF-8
      PKG_MARKER: SNAP
    plugs:
      - cpu-control
      - system-observe
      - hardware-observe
      - etc-auto-cpufreq-conf
  auto-cpufreq-gtk:
    command: bin/auto-cpufreq-gtk
    #desktop: usr/share/applications/auto-cpufreq.desktop
    environment:
      PYTHONPATH: $SNAP/usr/lib/python3/site-packages:$SNAP/usr/lib/python3/dist-packages:$PYTHONPATH
      LC_ALL: C.UTF-8
      LANG: C.UTF-8
      PKG_MARKER: SNAP
    plugs:
      - desktop
      - desktop-legacy
      - wayland
      - x11
      - cpu-control
      - system-observe
      - hardware-observe
      - etc-auto-cpufreq-conf
  service:
    command: usr/bin/snapdaemon
    plugs:
      - cpu-control
      - system-observe
      - hardware-observe
      - etc-auto-cpufreq-conf
    environment:
      LC_ALL: C.UTF-8
      LANG: C.UTF-8
      PKG_MARKER: SNAP
    daemon: simple

auto-cpufreq.desktop

[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=auto-cpufreq
Comment=Automatic CPU speed & power optimizer for Linux
Exec=auto-cpufreq-gtk
StartupWMClass=app.py
Terminal=false
Icon=${SNAP}/meta/gui/auto-cpufreq.png
Categories=System;