diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 915138c..ac89f99 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -36,7 +36,7 @@ apps: PKG_MARKER: SNAP service: - command: bin/auto-cpufreq --daemon 2>&1 | tee -a /var/log/auto-cpufreq.log + command: bin/auto-cpufreq --daemon 2>&1 | tee -a $SNAP_DATA/auto-cpufreq.log plugs: - cpu-control - system-observe diff --git a/source/core.py b/source/core.py index 676f6d9..79a52e1 100644 --- a/source/core.py +++ b/source/core.py @@ -40,6 +40,7 @@ bat_state = power.PowerManagement().get_providing_power_source_type() # auto-cpufreq log file auto_cpufreq_log_file = "/var/log/auto-cpufreq.log" +auto_cpufreq_log_file_snap = "/var/snap/auto-cpufreq/current/auto-cpufreq.log" # daemon check dcheck = s.getoutput("snapctl get daemon") @@ -406,8 +407,9 @@ def delete_file(file): # read log func def read_log(): - if os.path.isfile(auto_cpufreq_log_file): - # read /var/log/auto-cpufreq.log + if os.getenv("PKG_MARKER") == "SNAP": + s.call(["tail", "-n 50", "-f", auto_cpufreq_log_file_snap]) + elif os.path.isfile(auto_cpufreq_log_file): s.call(["tail", "-n 50", "-f", auto_cpufreq_log_file]) else: print("\n" + "-" * 30 + " auto-cpufreq log " + "-" * 31 + "\n")