From 715aedaa44c466064d6f2adad89e81bd1d825a51 Mon Sep 17 00:00:00 2001 From: Nicolas Derumigny Date: Thu, 3 Nov 2022 00:42:31 -0600 Subject: [PATCH 1/6] Gnome 43 support. Closes #199 --- metadata.json | 2 +- src/indicator.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/metadata.json b/metadata.json index a5f4ee8f..c4f25b9d 100644 --- a/metadata.json +++ b/metadata.json @@ -1,7 +1,7 @@ { "localedir": "/usr/local/share/locale", "shell-version": [ - "3.28", "3.30", "3.36", "3.38", "40", "41", "42" + "3.28", "3.30", "3.36", "3.38", "40", "41", "42", "43" ], "uuid": "cpupower@mko-sl.de", "name": "CPU Power Manager", diff --git a/src/indicator.js b/src/indicator.js index 573796f5..e48e242f 100644 --- a/src/indicator.js +++ b/src/indicator.js @@ -108,7 +108,7 @@ var CPUFreqIndicator = class CPUFreqIndicator extends baseindicator.CPUFreqBaseI } enable() { - this.power = Main.panel.statusArea["aggregateMenu"]._power; + this.power = imports.ui.main.panel.statusArea.quickSettings._system._systemItem._powerToggle; this.powerState = this.power._proxy.State; this.powerConnectSignalId = this.power._proxy.connect( "g-properties-changed", From 43015f2b750df974bc4a1b520466a20da17039ac Mon Sep 17 00:00:00 2001 From: Nicolas Derumigny Date: Fri, 4 Nov 2022 21:52:59 -0600 Subject: [PATCH 2/6] README: updated to GNOME 43 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d81be67d..4a744469 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Lastest release - Gnome 42 + Gnome 43 License From b9fdf830966d6544788477d68aa3a0f2b95a725f Mon Sep 17 00:00:00 2001 From: Nicolas Derumigny Date: Fri, 4 Nov 2022 22:05:28 -0600 Subject: [PATCH 3/6] indicator.js: ensuring compatibility with older GNOME versions --- src/indicator.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/indicator.js b/src/indicator.js index e48e242f..a6828aca 100644 --- a/src/indicator.js +++ b/src/indicator.js @@ -108,7 +108,12 @@ var CPUFreqIndicator = class CPUFreqIndicator extends baseindicator.CPUFreqBaseI } enable() { - this.power = imports.ui.main.panel.statusArea.quickSettings._system._systemItem._powerToggle; + if (parseFloat(Config.PACKAGE_VERSION.substring(0, 4)) >= 43) { + this.power = imports.ui.main.panel.statusArea.quickSettings._system._systemItem._powerToggle; + } else { + this.power = Main.panel.statusArea["aggregateMenu"]._power; + } + this.powerState = this.power._proxy.State; this.powerConnectSignalId = this.power._proxy.connect( "g-properties-changed", From b151760684a22f4d03a137f14c654f4c5c13e19f Mon Sep 17 00:00:00 2001 From: Nicolas Derumigny Date: Thu, 3 Nov 2022 00:38:42 -0600 Subject: [PATCH 4/6] cpufreqctl: avoid boosting when measuring pstate frequency --- tool/cpufreqctl | 1 + 1 file changed, 1 insertion(+) diff --git a/tool/cpufreqctl b/tool/cpufreqctl index 1ae96f2d..74916369 100755 --- a/tool/cpufreqctl +++ b/tool/cpufreqctl @@ -276,6 +276,7 @@ intel_pstate_info_frequencies () intel_pstate_info_current () { + sleep 0.01 for scaling_cur_freq in /sys/devices/system/cpu/cpufreq/policy*/scaling_cur_freq do cat "${scaling_cur_freq}" & From cd42f5f92db54b102f78c62473c07c4cb11fe559 Mon Sep 17 00:00:00 2001 From: Nicolas Derumigny Date: Sun, 6 Nov 2022 15:30:13 -0700 Subject: [PATCH 5/6] cpufreqctl: removing awk / sort dependency when reading frequency --- tool/cpufreqctl | 89 +++++++++++++++++-------------------------------- 1 file changed, 30 insertions(+), 59 deletions(-) diff --git a/tool/cpufreqctl b/tool/cpufreqctl index 74916369..5a20cb18 100755 --- a/tool/cpufreqctl +++ b/tool/cpufreqctl @@ -22,6 +22,7 @@ # along with this program. If not, see . set -o errexit -o nounset +renice -n 19 0 >/dev/null VERSION="10.1.2" PRODUCTION=yes @@ -93,6 +94,29 @@ not_supported () EXIT_CODE=9 } +# echo min/max/avg/rnd of a space-separated list of numbers +compute_min_max_avg_rnd () +{ + measures=($1) + nb_measures=${#measures[@]} + max=0 + min=${measures[0]} + tot=0 + for i in "${measures[@]}"; do + tot=$(($tot + $i)) + if [ "$i" -gt "$max" ]; then + max=$i + fi + if [ "$i" -lt "$min" ]; then + min=$i + fi + done + avg=$(($tot/$nb_measures)) + rnd_id=$(($RANDOM % $nb_measures)) + rnd=${measures[$rnd_id]} + echo --min "${min}" --max "${max}" --avg "${avg}" --rnd "${rnd}" +} + fake_init () { FAKE_DIR=/tmp/cpufreqctl-fake-backend @@ -175,24 +199,8 @@ fake_info_frequencies () fake_info_current () { fake_init - - shuf -i 800000-3600000 -n 12 | sort -n | awk ' - BEGIN { - srand() - } - NR == 1 { - printf "%d ", $1 - } - { - sum += $1 - r[NR] = $1 - } - END { - printf "%d %.0f %d\n", $1, sum / NR, r[int(rand() * NR) + 1] - }' | while read -r min max avg rnd - do - report_info_current --min "${min}" --max "${max}" --avg "${avg}" --rnd "${rnd}" - done + measures=$(shuf -i 800000-3600000 -n 12) + report_info_current $(compute_min_max_avg_rnd "$measures") } intel_pstate_supported () @@ -276,27 +284,8 @@ intel_pstate_info_frequencies () intel_pstate_info_current () { - sleep 0.01 - for scaling_cur_freq in /sys/devices/system/cpu/cpufreq/policy*/scaling_cur_freq - do - cat "${scaling_cur_freq}" & - done | sort -n | awk ' - BEGIN { - srand() - } - NR == 1 { - printf "%d ", $1 - } - { - sum += $1 - r[NR] = $1 - } - END { - printf "%d %.0f %d\n", $1, sum / NR, r[int(rand() * NR) + 1] - }' | while read -r min max avg rnd - do - report_info_current --min "${min}" --max "${max}" --avg "${avg}" --rnd "${rnd}" - done + measures=$(cat /sys/devices/system/cpu/cpufreq/policy*/scaling_cur_freq) + report_info_current $(compute_min_max_avg_rnd "$measures") } cpufreq_supported () @@ -473,26 +462,8 @@ cpufreq_info_frequencies () cpufreq_info_current () { - for scaling_cur_freq in /sys/devices/system/cpu/cpufreq/policy*/scaling_cur_freq - do - cat "${scaling_cur_freq}" & - done | sort -n | awk ' - BEGIN { - srand() - } - NR == 1 { - printf "%d ", $1 - } - { - sum += $1 - r[NR] = $1 - } - END { - printf "%d %.0f %d\n", $1, sum / NR, r[int(rand() * NR) + 1] - }' | while read -r min max avg rnd - do - report_info_current --min "${min}" --max "${max}" --avg "${avg}" --rnd "${rnd}" - done + measures=$(cat /sys/devices/system/cpu/cpufreq/policy*/scaling_cur_freq) + report_info_current $(compute_min_max_avg_rnd "$measures") } backend_select() From 66324edd470e6762fff09404a09f2fbaeb3eb394 Mon Sep 17 00:00:00 2001 From: Nicolas Derumigny Date: Sun, 6 Nov 2022 16:11:36 -0700 Subject: [PATCH 6/6] cpufreqctl: ensuring POSIX compatibility --- tool/cpufreqctl | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/tool/cpufreqctl b/tool/cpufreqctl index 5a20cb18..96806cd0 100755 --- a/tool/cpufreqctl +++ b/tool/cpufreqctl @@ -95,25 +95,32 @@ not_supported () } # echo min/max/avg/rnd of a space-separated list of numbers +# $1 number of element +# $2 space-separated list of numbers compute_min_max_avg_rnd () { - measures=($1) - nb_measures=${#measures[@]} + nb_measures=$1 + measures=$2 max=0 - min=${measures[0]} + min=10000000 tot=0 - for i in "${measures[@]}"; do - tot=$(($tot + $i)) + idx=0 + rnd_id=$(shuf -i 0-$((nb_measures-1)) -n 1) + for i in $measures; do + tot=$((tot + i)) if [ "$i" -gt "$max" ]; then max=$i fi if [ "$i" -lt "$min" ]; then min=$i fi + if [ "$idx" -eq "$rnd_id" ]; then + rnd=$i + fi + idx=$((idx+1)) done - avg=$(($tot/$nb_measures)) - rnd_id=$(($RANDOM % $nb_measures)) - rnd=${measures[$rnd_id]} + avg=$((tot/nb_measures)) + echo --min "${min}" --max "${max}" --avg "${avg}" --rnd "${rnd}" } @@ -200,7 +207,8 @@ fake_info_current () { fake_init measures=$(shuf -i 800000-3600000 -n 12) - report_info_current $(compute_min_max_avg_rnd "$measures") + num_cores=12 + report_info_current $(compute_min_max_avg_rnd "$num_cores" "$measures") } intel_pstate_supported () @@ -285,7 +293,8 @@ intel_pstate_info_frequencies () intel_pstate_info_current () { measures=$(cat /sys/devices/system/cpu/cpufreq/policy*/scaling_cur_freq) - report_info_current $(compute_min_max_avg_rnd "$measures") + num_cores=$(getconf _NPROCESSORS_ONLN) + report_info_current $(compute_min_max_avg_rnd "$num_cores" "$measures") } cpufreq_supported () @@ -463,7 +472,8 @@ cpufreq_info_frequencies () cpufreq_info_current () { measures=$(cat /sys/devices/system/cpu/cpufreq/policy*/scaling_cur_freq) - report_info_current $(compute_min_max_avg_rnd "$measures") + num_cores=$(getconf _NPROCESSORS_ONLN) + report_info_current $(compute_min_max_avg_rnd "$num_cores" "$measures") } backend_select()