From c78ea8dd597f4d4f9d04d8469e8a2ea064228aeb Mon Sep 17 00:00:00 2001 From: Adnan Hodzic Date: Wed, 22 Jan 2020 22:26:27 +0100 Subject: [PATCH] added option to detect if running on snap --- bin/auto-cpufreq | 1 + snap/snapcraft.yaml | 7 ++----- source/core.py | 10 +++++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/bin/auto-cpufreq b/bin/auto-cpufreq index 528a300..11cb23c 100755 --- a/bin/auto-cpufreq +++ b/bin/auto-cpufreq @@ -4,6 +4,7 @@ # # Blog post: http://foolcontrol.org/?p=3124 +# core import import sys sys.path.append('../') from source.core import * diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 193dfcc..76e83e1 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -31,14 +31,11 @@ parts: source: scripts organize: cpufreqctl.sh: usr/bin/cpufreqctl - # organize: - # auto-cpufreq-install.sh: usr/bin/auto-cpufreq-install - # organize: - # auto-cpufreq-remove.sh: usr/bin/auto-cpufreq-remove apps: auto-cpufreq: command: bin/auto-cpufreq environment: LC_ALL: C.UTF-8 - LANG: C.UTF-8 \ No newline at end of file + LANG: C.UTF-8 + PKG_MARKER: SNAP \ No newline at end of file diff --git a/source/core.py b/source/core.py index 09434b1..72b510d 100644 --- a/source/core.py +++ b/source/core.py @@ -37,11 +37,15 @@ auto_cpufreq_log_file = "/var/log/auto-cpufreq.log" # deploy cpufreqctl script def cpufreqctl(): - # deploy cpufreqctl script (if missing) - if os.path.isfile("/usr/bin/cpufreqctl"): + # detect if running on a SNAP + if os.getenv('PKG_MARKER') == "SNAP": pass else: - os.system("cp scripts/cpufreqctl.sh /usr/bin/cpufreqctl") + # deploy cpufreqctl script (if missing) + if os.path.isfile("/usr/bin/cpufreqctl"): + pass + else: + os.system("cp scripts/cpufreqctl.sh /usr/bin/cpufreqctl") def footer(l): print("\n" + "-" * l + "\n")