Disabling systemctl service on host from snap


As part of auto-cpufreq (Automatic CPU speed & power optimizer for Linux), in latest changes on gnome-power branch I would like to be able to disable GNOME power savings profiles on users host machine. Outside of snap context, these changes work fine if I use the tool’s git installer, but once these changes are running as part of snap package (even in devmode) they don’t seem to have any affect (which makes sense as this service is not available as part of the snap).

Hence I was wondering how could I do this using snap package? Latest version of snapcraft.yaml:

name: auto-cpufreq
base: core20
version: '1.8.0'
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

compression: lzo

    plugin: python
       - setuptools
       - wheel
       - gcc
       - python3-dev
       - coreutils
       - dmidecode
    source: .

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

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

    command: bin/auto-cpufreq
      PYTHONPATH: $SNAP/usr/lib/python3/site-packages:$SNAP/usr/lib/python3/dist-packages:$PYTHONPATH
      - cpu-control
      - system-observe
      - hardware-observe
      - etc-auto-cpufreq-conf
      LC_ALL: C.UTF-8
      LANG: C.UTF-8

    command: usr/bin/snapdaemon
      - cpu-control
      - system-observe
      - hardware-observe
      LC_ALL: C.UTF-8
      LANG: C.UTF-8
    daemon: simple


Out of all the posts on this forum, this came as closest one to what I’m trying to do (different service in my case). However it still didn’t help as I’m not sure what exactly was done in the end.

Well, there is not actually a way to manage services outside of the snap space from a snap … while snapctl enables you to manage services inside the same snap and the snapd-control interface (only allowed in brand stores) gives you access to manage services of other snaps, there is currently no way to access any non-snapped services from a snapped application/service …

there is also no guarantee that your user actually has the gnome power savings stuff installed at all … it could be a manjaro system using i3wm, an arch install running KDE, or an lxQt based desktop on a debian machine …

what you could perhaps do is to show some kind of popup informing the user to please disable these bits manually …

Thank you for confirming that this is not possible with application packaged as a Snap package. Do you know if there are any plans to have one such functionality in future?

I would greatly improve detection and make sure if user is running GNOME and if power-profiles-daemon is running as a systemd service as auto-cpufreq also supports other init systems. Another option would to set it to be used as part of auto-cpufreq config file. While one such implementation might be challenging from technological point of view it’s not a problem at all.

Yes, if this is the only way forward, in case power-profiles-daemon service is detected and user installed application using a Snap they will be instructed with popup or some other way to a script in repo which will allow them to disable it.

i don’t, but the guys in the snapd team probably do, i have moved this post to their category …