From d36343c562ee2f56ddaa6941888e7acb851ac49c Mon Sep 17 00:00:00 2001 From: Francesco Bonanno Date: Sat, 19 Oct 2019 03:13:48 +0200 Subject: [PATCH 01/10] Added support to switch on/off a particular cpu Added support to select number of online cpus Fixed a missing variable --- .../contents/code/set_prefs.sh | 42 ++++++++++++++++++- .../contents/code/utils.js | 5 +++ 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh b/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh index e017ac7..8fc73e7 100755 --- a/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh +++ b/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh @@ -1,9 +1,12 @@ -#!/bin/bash +#!/usr/bin/env bash -INTEL_PSTATE=/sys/devices/system/cpu/intel_pstate +ACPI_CPU=/sys/devices/system/cpu +INTEL_PSTATE=$ACPI_CPU/intel_pstate CPU_MIN_PERF=$INTEL_PSTATE/min_perf_pct CPU_MAX_PERF=$INTEL_PSTATE/max_perf_pct CPU_TURBO=$INTEL_PSTATE/no_turbo +CPU_TOTAL_AVAILABLE=$(nproc --all) +CPU_ONLINE=$(nproc) GPU=/sys/class/drm/card0 GPU_MIN_FREQ=$GPU/gt_min_freq_mhz @@ -71,6 +74,32 @@ set_cpu_turbo () { fi } +set_cpu_state () { + num=$1 + num_off=$[$CPU_TOTAL_AVAILABLE-$num] + counter=1 + limit=$[$num-1] + all_off=$[$CPU_TOTAL_AVAILABLE-1] + if [ -n "$num" ] && [ "$num" != "0" ]; then + if [ "$num" -ne "1" ]; then + while [ "$counter" -le "$limit" ]; do + printf '1\n' > $ACPI_CPU/cpu$counter/online; 2> /dev/null + counter=$[$counter+1] + done + limit=$[$limit+$num_off] + while [ "$counter" -le "$limit" ]; do + printf '0\n' > $ACPI_CPU/cpu$counter/online; 2> /dev/null + counter=$[$counter+1] + done + else + while [ "$counter" -le "$all_off" ]; do + printf '0\n' > $ACPI_CPU/cpu$counter/online; 2> /dev/null + counter=$[$counter+1] + done + fi + fi +} + set_gpu_min_freq () { gpuminfreq=$1 if [ -n "$gpuminfreq" ] && [ "$gpuminfreq" != "0" ]; then @@ -165,6 +194,8 @@ read_all () { cpu_min_perf=`cat $CPU_MIN_PERF` cpu_max_perf=`cat $CPU_MAX_PERF` cpu_turbo=`cat $CPU_TURBO` +cpu_total_available=`echo $CPU_TOTAL_AVAILABLE` +cpu_online=`echo $CPU_ONLINE` if [ "$cpu_turbo" == "1" ]; then cpu_turbo="false" else @@ -221,6 +252,8 @@ json="{" json="${json}\"cpu_min_perf\":\"${cpu_min_perf}\"" json="${json},\"cpu_max_perf\":\"${cpu_max_perf}\"" json="${json},\"cpu_turbo\":\"${cpu_turbo}\"" +json="${json},\"cpu_total_available\":\"${cpu_total_available}\"" +json="${json},\"cpu_online\":\"${cpu_online}\"" json="${json},\"gpu_min_freq\":\"${gpu_min_freq}\"" json="${json},\"gpu_max_freq\":\"${gpu_max_freq}\"" json="${json},\"gpu_min_limit\":\"${gpu_min_limit}\"" @@ -257,6 +290,10 @@ case $1 in set_cpu_turbo $2 ;; + "-cpu-online") + set_cpu_state $2 + ;; + "-gpu-min-freq") set_gpu_min_freq $2 ;; @@ -306,6 +343,7 @@ case $1 in echo "1: set_prefs.sh [ -cpu-min-perf |" echo " -cpu-max-perf |" echo " -cpu-turbo |" + echo " -cpu-online |" echo " -gpu-min-freq |" echo " -gpu-max-freq |" echo " -gpu-boost-freq |" diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/code/utils.js b/gr.ictpro.jsalatas.plasma.pstate/contents/code/utils.js index db2d82d..f081cd5 100644 --- a/gr.ictpro.jsalatas.plasma.pstate/contents/code/utils.js +++ b/gr.ictpro.jsalatas.plasma.pstate/contents/code/utils.js @@ -60,6 +60,7 @@ var sensors = { 'cpu_cur_load': {'value': undefined, 'unit':'%', 'print': to_int}, 'cpu_cur_freq': {'value': undefined, 'unit':' MHz', 'print': to_int}, 'gpu_cur_freq': {'value': undefined, 'unit':' MHz', 'print': to_int}, + 'cpu_total_available': {'value': undefined, 'unit':'', 'print': to_int}, 'gpu_min_limit': {'value': undefined, 'unit':'', 'print': to_int}, 'gpu_max_limit': {'value': undefined, 'unit':'', 'print': to_int}, 'battery_percentage': {'value': undefined, 'unit': '%', 'print': to_int}, @@ -70,6 +71,7 @@ var sensors = { 'cpu_min_perf': {'value': undefined, 'unit':'%', 'print': to_int}, 'cpu_max_perf': {'value': undefined, 'unit':'%', 'print': to_int}, 'cpu_turbo': {'value': undefined, 'unit':'', 'print': to_bool}, + 'cpu_online': {'value': undefined, 'unit':'', 'print': to_int}, 'gpu_min_freq': {'value': undefined, 'unit':' MHz', 'print': to_int}, 'gpu_max_freq': {'value': undefined, 'unit':' MHz', 'print': to_int}, 'gpu_boost_freq': {'value': undefined, 'unit':' MHz', 'print': to_int}, @@ -98,6 +100,9 @@ var model = [ {'type': 'slider', 'text': 'Max perf', 'min': 0, 'max': 100, 'sensor': 'cpu_max_perf'}, {'type': 'switch', 'text': 'Turbo', 'sensor': 'cpu_turbo'} ]}, + {'type': 'group', 'text': 'Online CPUs', 'items' :[ + {'type': 'slider', 'text': 'CPUs', 'min': 0, 'max': 'cpu_total_available', 'sensor': 'cpu_online'}, + ]}, {'type': 'group', 'text': 'GPU Frequencies', 'visible': 'showIntelGPU', 'items' :[ {'type': 'slider', 'text': 'Min freq', 'min': 'gpu_min_limit', 'max': 'gpu_max_limit', 'sensor': 'gpu_min_freq'}, {'type': 'slider', 'text': 'Max freq', 'min': 'gpu_min_limit', 'max': 'gpu_max_limit', 'sensor': 'gpu_max_freq'}, From 9c2aacac9af11b62c5c5767e6f08a993275930a5 Mon Sep 17 00:00:00 2001 From: Francesco Bonanno Date: Sun, 2 May 2021 14:53:22 +0200 Subject: [PATCH 02/10] Adding https://github.com/jsalatas/plasma-pstate/pull/64 and using pkexec for setting preferences (PolKit instead of sudo) --- .../contents/config/main.xml | 3 --- .../contents/ui/ComboBox.qml | 2 +- .../contents/ui/FullRepresentation.qml | 9 --------- .../contents/ui/config/ConfigGeneral.qml | 7 ------- .../contents/ui/main.qml | 14 ++------------ install.sh | 15 --------------- uninstall.sh | 3 --- 7 files changed, 3 insertions(+), 50 deletions(-) diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/config/main.xml b/gr.ictpro.jsalatas.plasma.pstate/contents/config/main.xml index 401291c..92de849 100644 --- a/gr.ictpro.jsalatas.plasma.pstate/contents/config/main.xml +++ b/gr.ictpro.jsalatas.plasma.pstate/contents/config/main.xml @@ -15,8 +15,5 @@ true - - true - diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/ComboBox.qml b/gr.ictpro.jsalatas.plasma.pstate/contents/ui/ComboBox.qml index b37e1a2..4581aaa 100644 --- a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/ComboBox.qml +++ b/gr.ictpro.jsalatas.plasma.pstate/contents/ui/ComboBox.qml @@ -81,6 +81,6 @@ RowLayout { } } - Layout.minimumWidth: parent.width + Layout.minimumWidth: units.gridUnit * 4 } } diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/FullRepresentation.qml b/gr.ictpro.jsalatas.plasma.pstate/contents/ui/FullRepresentation.qml index 1dfb139..36ebcbf 100644 --- a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/FullRepresentation.qml +++ b/gr.ictpro.jsalatas.plasma.pstate/contents/ui/FullRepresentation.qml @@ -62,15 +62,6 @@ Column { } } - Connections { - target: plasmoid.configuration - onUseSudoForReadingChanged: { - if(isReady) { - initialize() - } - } - } - function is_present(item_vendors) { if(item_vendors && item_vendors.length != 0) { for(var j=0; j< item_vendors.length; j++) { diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/config/ConfigGeneral.qml b/gr.ictpro.jsalatas.plasma.pstate/contents/ui/config/ConfigGeneral.qml index 849adf4..e5e1041 100644 --- a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/config/ConfigGeneral.qml +++ b/gr.ictpro.jsalatas.plasma.pstate/contents/ui/config/ConfigGeneral.qml @@ -6,7 +6,6 @@ Item { property alias cfg_useDefaultIcon: useDefaultIconCheckbox.checked property alias cfg_showIntelGPU: showIntelGPUCheckbox.checked property string cfg_customIcon: plasmoid.configuration.customIcon - property alias cfg_useSudoForReading: useSudoForReadingCheckbox.checked GridLayout { Layout.fillWidth: true @@ -37,11 +36,5 @@ Item { text: i18n('Show Intel GPU') Layout.columnSpan: 2 } - - CheckBox { - id: useSudoForReadingCheckbox - text: i18n('Use sudo for reading values') - Layout.columnSpan: 2 - } } } diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/main.qml b/gr.ictpro.jsalatas.plasma.pstate/contents/ui/main.qml index 9573490..a41d7a4 100644 --- a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/main.qml +++ b/gr.ictpro.jsalatas.plasma.pstate/contents/ui/main.qml @@ -43,7 +43,7 @@ Item { property var sensors_model: Utils.get_sensors() property alias isReady: monitorDS.isReady property bool inTray: (plasmoid.parent === null || plasmoid.parent.objectName === 'taskItemContainer') - property var readCommand: (plasmoid.configuration.useSudoForReading ? 'sudo ' : '') + '/usr/share/plasma/plasmoids/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh -read-all' + property var readCommand: '/usr/share/plasma/plasmoids/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh -read-all' function sensor_short_name(long_name) { var parts = long_name.split('/'); @@ -189,16 +189,6 @@ Item { interval: 2000 } - Connections { - target: plasmoid.configuration - onUseSudoForReadingChanged: { - monitorDS.commandSource = readCommand - monitorDS.connectedSources = []; - monitorDS.connectedSources.length = 0; - monitorDS.connectedSources.push(monitorDS.commandSource); - } - } - PlasmaCore.DataSource { id: monitorDS engine: 'executable' @@ -235,7 +225,7 @@ Item { id: updater engine: 'executable' - property string commandSource: 'sudo /usr/share/plasma/plasmoids/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh -' + property string commandSource: '/usr/bin/pkexec /usr/share/plasma/plasmoids/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh -' onNewData: { updater.connectedSources = [] diff --git a/install.sh b/install.sh index 7a06a82..ba6a131 100755 --- a/install.sh +++ b/install.sh @@ -5,24 +5,9 @@ if [[ $EUID -ne 0 ]]; then exit 1 fi -SUDOERS_FILE="99-plasma-pstate" - -cp -R ${SUDOERS_FILE} /etc/sudoers.d/ kpackagetool5 -g -t Plasma/Applet -i gr.ictpro.jsalatas.plasma.pstate chmod 755 /usr/share/plasma/plasmoids/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh -chown root:root /etc/sudoers.d/${SUDOERS_FILE} -chmod 400 /etc/sudoers.d/${SUDOERS_FILE} - -# Test for wheel group instead of sudo -# this is the case of arch based distros -wheelgroup=`grep wheel /etc/group | wc -l` -sudogroup=`grep sudo /etc/group | wc -l` -if [ "$wheelgroup" -eq "1" ] && [ "$sudogroup" -eq "0" ]; then - # seems to be safe enough: there is a wheel group and not a sudo group - sed -i 's/sudo/wheel/' /etc/sudoers.d/${SUDOERS_FILE} -fi - echo -e "\nSetup complete." exit 0 diff --git a/uninstall.sh b/uninstall.sh index 2ca56b4..2882517 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -5,9 +5,6 @@ if [[ $EUID -ne 0 ]]; then exit 1 fi -SUDOERS_FILE="/etc/sudoers.d/99-plasma-pstate" - -rm -f ${SUDOERS_FILE} kpackagetool5 -g -t Plasma/Applet -r gr.ictpro.jsalatas.plasma.pstate echo "Uninstall complete." From dad7a9e80667a026b87311c2b15d121db017f81c Mon Sep 17 00:00:00 2001 From: Francesco Bonanno Date: Sun, 2 May 2021 18:25:03 +0200 Subject: [PATCH 03/10] Added pkexec policies, changed maintainer and package name, added support for MSI Cooler Boost via ISW --- 99-plasma-pstate | 1 - README.md | 17 ++++-- install.sh | 8 ++- .../contents/code/get_thermal.sh | 2 + ...e.mibofra.plasma.pstate.get-thermal.policy | 17 ++++++ ...cle.mibofra.plasma.pstate.set-prefs.policy | 17 ++++++ .../contents/code/set_prefs.sh | 51 ++++++++++++++++-- .../contents/code/utils.js | 12 ++++- .../contents/config/config.qml | 0 .../contents/config/main.xml | 0 .../contents/font/plasma-pstate.ttf | Bin .../contents/ui/ComboBox.qml | 0 .../contents/ui/CompactRepresentation.qml | 0 .../contents/ui/FullRepresentation.qml | 0 .../contents/ui/Group.qml | 0 .../contents/ui/Header.qml | 0 .../contents/ui/PushButton.qml | 0 .../contents/ui/Radio.qml | 0 .../contents/ui/Slider.qml | 0 .../contents/ui/Switch.qml | 0 .../contents/ui/config/ConfigGeneral.qml | 0 .../contents/ui/config/IconPicker.qml | 0 .../contents/ui/main.qml | 4 +- .../metadata.desktop | 8 +-- uninstall.sh | 5 +- 25 files changed, 123 insertions(+), 19 deletions(-) delete mode 100644 99-plasma-pstate create mode 100755 org.thefreecircle.mibofra.plasma.pstate/contents/code/get_thermal.sh create mode 100644 org.thefreecircle.mibofra.plasma.pstate/contents/code/org.thefreecircle.mibofra.plasma.pstate.get-thermal.policy create mode 100644 org.thefreecircle.mibofra.plasma.pstate/contents/code/org.thefreecircle.mibofra.plasma.pstate.set-prefs.policy rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/code/set_prefs.sh (85%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/code/utils.js (95%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/config/config.qml (100%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/config/main.xml (100%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/font/plasma-pstate.ttf (100%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/ui/ComboBox.qml (100%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/ui/CompactRepresentation.qml (100%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/ui/FullRepresentation.qml (100%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/ui/Group.qml (100%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/ui/Header.qml (100%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/ui/PushButton.qml (100%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/ui/Radio.qml (100%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/ui/Slider.qml (100%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/ui/Switch.qml (100%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/ui/config/ConfigGeneral.qml (100%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/ui/config/IconPicker.qml (100%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/ui/main.qml (97%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/metadata.desktop (63%) diff --git a/99-plasma-pstate b/99-plasma-pstate deleted file mode 100644 index 70a42ab..0000000 --- a/99-plasma-pstate +++ /dev/null @@ -1 +0,0 @@ -%sudo ALL=NOPASSWD: /usr/share/plasma/plasmoids/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh diff --git a/README.md b/README.md index d188e4e..548612f 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,10 @@ through [libsmbios library](https://github.com/dell/libsmbios). Intel P-state and CPUFreq Manager Widget with Nvidia PowerMizer Settings +4. MSI Cooler Boost + +- This assume that you already have seen if your laptop is supported by ISW tool, already seen https://github.com/YoyPa/isw/blob/master/README.md and set up it, and isw is in the executable path. + ## What it isn't This is just a GUI widget and it is not meant to replace @@ -81,10 +85,17 @@ especially in relation to similar to Dell's Thermal Management Feature that may be available in other hardware platforms. ## Issues -The widget uses a shell script that needs to be run as root user (sudo) and which apparently floods your log files with security related messages as described in [issue #16](https://github.com/jsalatas/plasma-pstate/issues/16). -If you want to get rid of these messages, please see a workaround at +Using PolKit, I don't see any log flood a the moment. + +If it's not your case, plese read: https://github.com/jsalatas/plasma-pstate/wiki/Too-many-messages-in-system-log + +For option with a slider, please, be sure to slide them and not click on an arbitrary point of the slider. This will ensure that, the plasmoid slider is working fine, getting the preference issued, avoiding it to bug plasmashell, the plasmoid, or the panel where it is docked. And surely, making polkit agent asking the password for setting the preference, as expected. + +## Info -https://github.com/jsalatas/plasma-pstate/wiki/Too-many-messages-in-system-log +The original author is maintaining the plasmoid up to his needs, see the head of: https://github.com/jsalatas/plasma-pstate/blob/master/README.md , +also because there are efforts to have hardware profiles directly in powerdevil and kcm like in gnome with https://gitlab.freedesktop.org/hadess/power-profiles-daemon . +Anyway, some tools can be still useful for some users, like me, who added the possibility to set the number of online cpus, or other tools that are out of scope of powerdevil and kcm itself. So I'm trying to keep at least it up to date, in a working state with latest KDE releases, trying to adding new functions if needed. With patience and time, also trying to redesing the ui, as the original author wanted: https://github.com/jsalatas/plasma-pstate/issues/40 (or the space on the desktop for the tools will decrease). diff --git a/install.sh b/install.sh index ba6a131..9e1f7dc 100755 --- a/install.sh +++ b/install.sh @@ -5,9 +5,13 @@ if [[ $EUID -ne 0 ]]; then exit 1 fi -kpackagetool5 -g -t Plasma/Applet -i gr.ictpro.jsalatas.plasma.pstate +kpackagetool5 -g -t Plasma/Applet -i org.thefreecircle.mibofra.plasma.pstate -chmod 755 /usr/share/plasma/plasmoids/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh +chmod 755 /usr/share/plasma/plasmoids/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh +chmod 755 /usr/share/plasma/plasmoids/org.thefreecircle.mibofra.plasma.pstate/contents/code/get_thermal.sh + +cp org.thefreecircle.mibofra.plasma.pstate/contents/code/org.thefreecircle.mibofra.plasma.pstate.get-thermal.policy /usr/share/polkit-1/actions/ +cp org.thefreecircle.mibofra.plasma.pstate/contents/code/org.thefreecircle.mibofra.plasma.pstate.set-prefs.policy /usr/share/polkit-1/actions/ echo -e "\nSetup complete." exit 0 diff --git a/org.thefreecircle.mibofra.plasma.pstate/contents/code/get_thermal.sh b/org.thefreecircle.mibofra.plasma.pstate/contents/code/get_thermal.sh new file mode 100755 index 0000000..159dac8 --- /dev/null +++ b/org.thefreecircle.mibofra.plasma.pstate/contents/code/get_thermal.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +smbios-thermal-ctl -g \ No newline at end of file diff --git a/org.thefreecircle.mibofra.plasma.pstate/contents/code/org.thefreecircle.mibofra.plasma.pstate.get-thermal.policy b/org.thefreecircle.mibofra.plasma.pstate/contents/code/org.thefreecircle.mibofra.plasma.pstate.get-thermal.policy new file mode 100644 index 0000000..1360f5a --- /dev/null +++ b/org.thefreecircle.mibofra.plasma.pstate/contents/code/org.thefreecircle.mibofra.plasma.pstate.get-thermal.policy @@ -0,0 +1,17 @@ + + + + + + Authentication is required to run Plasma P-state (Get thermal info) + + no + no + yes + + /usr/share/plasma/plasmoids/org.thefreecircle.mibofra.plasma.pstate/contents/code/get_thermal.sh + + + diff --git a/org.thefreecircle.mibofra.plasma.pstate/contents/code/org.thefreecircle.mibofra.plasma.pstate.set-prefs.policy b/org.thefreecircle.mibofra.plasma.pstate/contents/code/org.thefreecircle.mibofra.plasma.pstate.set-prefs.policy new file mode 100644 index 0000000..5b9b2c3 --- /dev/null +++ b/org.thefreecircle.mibofra.plasma.pstate/contents/code/org.thefreecircle.mibofra.plasma.pstate.set-prefs.policy @@ -0,0 +1,17 @@ + + + + + + Authentication is required to run Plasma P-state + + no + no + auth_admin + + /usr/share/plasma/plasmoids/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh + + + diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh b/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh similarity index 85% rename from gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh rename to org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh index 8fc73e7..06438c5 100755 --- a/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh +++ b/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh @@ -30,7 +30,7 @@ check_lg_drivers() { } check_dell_thermal () { - smbios-thermal-ctl -g > /dev/null 2>&1 + /usr/bin/pkexec /usr/share/plasma/plasmoids/org.thefreecircle.mibofra.plasma.pstate/contents/code/get_thermal.sh > /dev/null 2>&1 OUT=$? if [ $OUT -eq 0 ]; then return 0 @@ -49,6 +49,15 @@ check_nvidia () { fi } +check_isw () { + command -v isw &> /dev/null; + if [ $OUT -eq 0 ]; then + return 1 + else + return 0 + fi +} + set_cpu_min_perf () { minperf=$1 if [ -n "$minperf" ] && [ "$minperf" != "0" ]; then @@ -190,6 +199,19 @@ set_lg_usb_charge() { fi } +set_cooler_boost () { + boost=$1 + if [ -n "$boost" ]; then + if [ "$boost" == "true" ]; then + printf '1\n' > /run/isw_cooler_boost; 2> /dev/null + isw -b on; 2> /dev/null + else + printf '0\n' > /run/isw_cooler_boost; 2> /dev/null + isw -b off; 2> /dev/null + fi + fi +} + read_all () { cpu_min_perf=`cat $CPU_MIN_PERF` cpu_max_perf=`cat $CPU_MAX_PERF` @@ -220,7 +242,7 @@ if [ -z "$energy_perf" ]; then awk '{ printf "%s\n", $2; }' | head -n 1` fi if check_dell_thermal; then - thermal_mode=`smbios-thermal-ctl -g | grep -C 1 "Current Thermal Modes:" | tail -n 1 | awk '{$1=$1;print}' | sed "s/\t//g" | sed "s/ /-/g" | tr "[A-Z]" "[a-z]" ` + thermal_mode=`/usr/bin/pkexec /usr/share/plasma/plasmoids/org.thefreecircle.mibofra.plasma.pstate/contents/code/get_thermal.sh | grep -C 1 "Current Thermal Modes:" | tail -n 1 | awk '{$1=$1;print}' | sed "s/\t//g" | sed "s/ /-/g" | tr "[A-Z]" "[a-z]" ` fi if check_lg_drivers; then @@ -245,7 +267,20 @@ if check_lg_drivers; then fi if check_nvidia; then - powermizer=`nvidia-settings -q GpuPowerMizerMode | grep "Attribute 'GPUPowerMizerMode'" | awk -F "): " '{print $2}' | awk -F "." '{print $1}' ` + powermizer=`nvidia-settings -q GpuPowerMizerMode 2> /dev/null | grep "Attribute 'GPUPowerMizerMode'" | awk -F "): " '{print $2}' | awk -F "." '{print $1}' ` +fi + +if check_isw; then + if [[ -f /run/isw_cooler_boost ]]; then + cooler_boost=`cat /run/isw_cooler_boost` + if [ "cooler_boost" == "0" ]; then + cooler_boost="false" + else + cooler_boost="true" + fi + else + cooler_boost="false" + fi fi json="{" @@ -273,6 +308,9 @@ fi if check_nvidia; then json="${json},\"powermizer\":\"${powermizer}\"" fi +if check_isw; then + json="${json},\"cooler_boost\":\"${cooler_boost}\"" +fi json="${json}}" echo $json } @@ -334,6 +372,10 @@ case $1 in set_powermizer $2 ;; + "-cooler-boost") + set_cooler_boost $2 + ;; + "-read-all") read_all ;; @@ -353,7 +395,8 @@ case $1 in echo " -lg-battery-charge-limit |" echo " -lg-fan-mode |" echo " -lg-usb-charge |" - echo " -powermizer ] value" + echo " -powermizer |" + echo " -cooler-boost ] value" echo "2: set_prefs.sh -read-all" exit 3 ;; diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/code/utils.js b/org.thefreecircle.mibofra.plasma.pstate/contents/code/utils.js similarity index 95% rename from gr.ictpro.jsalatas.plasma.pstate/contents/code/utils.js rename to org.thefreecircle.mibofra.plasma.pstate/contents/code/utils.js index f081cd5..af42cfe 100644 --- a/gr.ictpro.jsalatas.plasma.pstate/contents/code/utils.js +++ b/org.thefreecircle.mibofra.plasma.pstate/contents/code/utils.js @@ -81,14 +81,16 @@ var sensors = { 'lg_battery_charge_limit': {'value': undefined, 'unit':'', 'print': to_bool}, 'lg_usb_charge': {'value': undefined, 'unit':'', 'print': to_bool}, 'lg_fan_mode': {'value': undefined, 'unit':'', 'print': to_bool}, - 'powermizer': {'value': undefined, 'unit':'', 'print': to_string}, + 'powermizer': {'value': undefined, 'unit':'', 'print': to_string}, + 'cooler_boost': {'value': undefined, 'unit':'', 'print': to_bool}, } var vendors = { 'dell': {'provides': ['thermal_mode']}, 'lg-laptop': {'provides': ['lg_battery_charge_limit', 'lg_usb_charge', 'lg_fan_mode']}, - 'nvidia': {'provides': ['powermizer']} + 'nvidia': {'provides': ['powermizer']}, + 'msi': {'provides': ['cooler_boost']} } var model = [ @@ -160,6 +162,12 @@ var model = [ {'text': 'Auto', 'sensor_value': '2'} ]} ] + }, + {'type': 'header', 'text': 'MSI Settings', 'icon': 'b', + 'vendors': ['msi'], + 'items': [ + {'type': 'switch', 'text': 'Cooler Boost', 'sensor': 'cooler_boost'} + ] } ] diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/config/config.qml b/org.thefreecircle.mibofra.plasma.pstate/contents/config/config.qml similarity index 100% rename from gr.ictpro.jsalatas.plasma.pstate/contents/config/config.qml rename to org.thefreecircle.mibofra.plasma.pstate/contents/config/config.qml diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/config/main.xml b/org.thefreecircle.mibofra.plasma.pstate/contents/config/main.xml similarity index 100% rename from gr.ictpro.jsalatas.plasma.pstate/contents/config/main.xml rename to org.thefreecircle.mibofra.plasma.pstate/contents/config/main.xml diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/font/plasma-pstate.ttf b/org.thefreecircle.mibofra.plasma.pstate/contents/font/plasma-pstate.ttf similarity index 100% rename from gr.ictpro.jsalatas.plasma.pstate/contents/font/plasma-pstate.ttf rename to org.thefreecircle.mibofra.plasma.pstate/contents/font/plasma-pstate.ttf diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/ComboBox.qml b/org.thefreecircle.mibofra.plasma.pstate/contents/ui/ComboBox.qml similarity index 100% rename from gr.ictpro.jsalatas.plasma.pstate/contents/ui/ComboBox.qml rename to org.thefreecircle.mibofra.plasma.pstate/contents/ui/ComboBox.qml diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/CompactRepresentation.qml b/org.thefreecircle.mibofra.plasma.pstate/contents/ui/CompactRepresentation.qml similarity index 100% rename from gr.ictpro.jsalatas.plasma.pstate/contents/ui/CompactRepresentation.qml rename to org.thefreecircle.mibofra.plasma.pstate/contents/ui/CompactRepresentation.qml diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/FullRepresentation.qml b/org.thefreecircle.mibofra.plasma.pstate/contents/ui/FullRepresentation.qml similarity index 100% rename from gr.ictpro.jsalatas.plasma.pstate/contents/ui/FullRepresentation.qml rename to org.thefreecircle.mibofra.plasma.pstate/contents/ui/FullRepresentation.qml diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/Group.qml b/org.thefreecircle.mibofra.plasma.pstate/contents/ui/Group.qml similarity index 100% rename from gr.ictpro.jsalatas.plasma.pstate/contents/ui/Group.qml rename to org.thefreecircle.mibofra.plasma.pstate/contents/ui/Group.qml diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/Header.qml b/org.thefreecircle.mibofra.plasma.pstate/contents/ui/Header.qml similarity index 100% rename from gr.ictpro.jsalatas.plasma.pstate/contents/ui/Header.qml rename to org.thefreecircle.mibofra.plasma.pstate/contents/ui/Header.qml diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/PushButton.qml b/org.thefreecircle.mibofra.plasma.pstate/contents/ui/PushButton.qml similarity index 100% rename from gr.ictpro.jsalatas.plasma.pstate/contents/ui/PushButton.qml rename to org.thefreecircle.mibofra.plasma.pstate/contents/ui/PushButton.qml diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/Radio.qml b/org.thefreecircle.mibofra.plasma.pstate/contents/ui/Radio.qml similarity index 100% rename from gr.ictpro.jsalatas.plasma.pstate/contents/ui/Radio.qml rename to org.thefreecircle.mibofra.plasma.pstate/contents/ui/Radio.qml diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/Slider.qml b/org.thefreecircle.mibofra.plasma.pstate/contents/ui/Slider.qml similarity index 100% rename from gr.ictpro.jsalatas.plasma.pstate/contents/ui/Slider.qml rename to org.thefreecircle.mibofra.plasma.pstate/contents/ui/Slider.qml diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/Switch.qml b/org.thefreecircle.mibofra.plasma.pstate/contents/ui/Switch.qml similarity index 100% rename from gr.ictpro.jsalatas.plasma.pstate/contents/ui/Switch.qml rename to org.thefreecircle.mibofra.plasma.pstate/contents/ui/Switch.qml diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/config/ConfigGeneral.qml b/org.thefreecircle.mibofra.plasma.pstate/contents/ui/config/ConfigGeneral.qml similarity index 100% rename from gr.ictpro.jsalatas.plasma.pstate/contents/ui/config/ConfigGeneral.qml rename to org.thefreecircle.mibofra.plasma.pstate/contents/ui/config/ConfigGeneral.qml diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/config/IconPicker.qml b/org.thefreecircle.mibofra.plasma.pstate/contents/ui/config/IconPicker.qml similarity index 100% rename from gr.ictpro.jsalatas.plasma.pstate/contents/ui/config/IconPicker.qml rename to org.thefreecircle.mibofra.plasma.pstate/contents/ui/config/IconPicker.qml diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/main.qml b/org.thefreecircle.mibofra.plasma.pstate/contents/ui/main.qml similarity index 97% rename from gr.ictpro.jsalatas.plasma.pstate/contents/ui/main.qml rename to org.thefreecircle.mibofra.plasma.pstate/contents/ui/main.qml index a41d7a4..617ed3d 100644 --- a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/main.qml +++ b/org.thefreecircle.mibofra.plasma.pstate/contents/ui/main.qml @@ -43,7 +43,7 @@ Item { property var sensors_model: Utils.get_sensors() property alias isReady: monitorDS.isReady property bool inTray: (plasmoid.parent === null || plasmoid.parent.objectName === 'taskItemContainer') - property var readCommand: '/usr/share/plasma/plasmoids/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh -read-all' + property var readCommand: '/usr/share/plasma/plasmoids/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh -read-all' function sensor_short_name(long_name) { var parts = long_name.split('/'); @@ -225,7 +225,7 @@ Item { id: updater engine: 'executable' - property string commandSource: '/usr/bin/pkexec /usr/share/plasma/plasmoids/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh -' + property string commandSource: '/usr/bin/pkexec /usr/share/plasma/plasmoids/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh -' onNewData: { updater.connectedSources = [] diff --git a/gr.ictpro.jsalatas.plasma.pstate/metadata.desktop b/org.thefreecircle.mibofra.plasma.pstate/metadata.desktop similarity index 63% rename from gr.ictpro.jsalatas.plasma.pstate/metadata.desktop rename to org.thefreecircle.mibofra.plasma.pstate/metadata.desktop index c62923b..e89eb9a 100644 --- a/gr.ictpro.jsalatas.plasma.pstate/metadata.desktop +++ b/org.thefreecircle.mibofra.plasma.pstate/metadata.desktop @@ -4,13 +4,13 @@ Name=Intel P-state and CPUFreq Manager Icon=cpu Type=Service X-KDE-ParentApp= -X-KDE-PluginInfo-Author=John Salatas +X-KDE-PluginInfo-Author=Francesco Bonanno X-KDE-PluginInfo-Category=System Information -X-KDE-PluginInfo-Email=jsalatas@ictpro.gr +X-KDE-PluginInfo-Email=mibofra@thefreecircle.org X-KDE-PluginInfo-License=GPL2+ -X-KDE-PluginInfo-Name=gr.ictpro.jsalatas.plasma.pstate +X-KDE-PluginInfo-Name=org.thefreecircle.mibofra.plasma.pstate X-KDE-PluginInfo-Version=1.0.6 -X-KDE-PluginInfo-Website=https://jsalatas.ictpro.gr +X-KDE-PluginInfo-Website=https://github.com/mibofra/plasma-pstate X-KDE-ServiceTypes=Plasma/Applet X-Plasma-API=declarativeappletscript X-Plasma-MainScript=ui/main.qml diff --git a/uninstall.sh b/uninstall.sh index 2882517..2156f3a 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -5,7 +5,10 @@ if [[ $EUID -ne 0 ]]; then exit 1 fi -kpackagetool5 -g -t Plasma/Applet -r gr.ictpro.jsalatas.plasma.pstate +kpackagetool5 -g -t Plasma/Applet -r org.thefreecircle.mibofra.plasma.pstate + +rm /usr/share/polkit-1/actions/org.thefreecircle.mibofra.plasma.pstate.get-thermal.policy +rm /usr/share/polkit-1/actions/org.thefreecircle.mibofra.plasma.pstate.set-prefs.policy echo "Uninstall complete." exit 0 From 33f61445de9f31e266fae407211fae28691affe8 Mon Sep 17 00:00:00 2001 From: Francesco Bonanno Date: Sun, 2 May 2021 18:35:16 +0200 Subject: [PATCH 04/10] Fixed if cycle for cooler booster detect + updated README --- README.md | 5 +++-- .../contents/code/set_prefs.sh | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 548612f..343d7dc 100644 --- a/README.md +++ b/README.md @@ -73,9 +73,10 @@ sudo apt install linux-tools-generic linux-tools-`uname -r` Assuming that you have checked out the latest code, you just need to run the following commands as root: ``` -sudo kpackagetool5 -g -t Plasma/Applet -u gr.ictpro.jsalatas.plasma.pstate +sudo kpackagetool5 -g -t Plasma/Applet -u org.thefreecircle.mibofra.plasma.pstate -sudo chmod 755 /usr/share/plasma/plasmoids/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh +sudo chmod 755 /usr/share/plasma/plasmoids/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh +sudo chmod 755 /usr/share/plasma/plasmoids/org.thefreecircle.mibofra.plasma.pstate/contents/code/get_thermal.sh ``` diff --git a/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh b/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh index 06438c5..1a906d7 100755 --- a/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh +++ b/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh @@ -271,15 +271,15 @@ if check_nvidia; then fi if check_isw; then - if [[ -f /run/isw_cooler_boost ]]; then + if [[ ! -f /run/isw_cooler_boost ]]; then + cooler_boost="false" + else cooler_boost=`cat /run/isw_cooler_boost` if [ "cooler_boost" == "0" ]; then cooler_boost="false" else cooler_boost="true" fi - else - cooler_boost="false" fi fi From 015045f03a1bdb68211b227d821b8c6ca99d40a3 Mon Sep 17 00:00:00 2001 From: Francesco Bonanno Date: Sun, 2 May 2021 18:55:43 +0200 Subject: [PATCH 05/10] Fixing a typo in set_prefs --- .../contents/code/set_prefs.sh | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh b/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh index 1a906d7..2be8dbb 100755 --- a/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh +++ b/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh @@ -177,9 +177,9 @@ set_lg_fan_mode() { enabled=$1 if [ -n "$enabled" ]; then if [ "$enabled" == "true" ]; then - printf '0\n' > $LG_FAN_MODE; 2> /dev/null + printf '0' > $LG_FAN_MODE; 2> /dev/null else - printf '1\n' > $LG_FAN_MODE; 2> /dev/null + printf '1' > $LG_FAN_MODE; 2> /dev/null fi fi } @@ -223,12 +223,14 @@ if [ "$cpu_turbo" == "1" ]; then else cpu_turbo="true" fi -gpu_min_freq=`cat $GPU_MIN_FREQ` -gpu_max_freq=`cat $GPU_MAX_FREQ` -gpu_min_limit=`cat $GPU_MIN_LIMIT` -gpu_max_limit=`cat $GPU_MAX_LIMIT` -gpu_boost_freq=`cat $GPU_BOOST_FREQ` -gpu_cur_freq=`cat $GPU_CUR_FREQ` +if [ -f $GPU_MIN_FREQ ]; then + gpu_min_freq=`cat $GPU_MIN_FREQ` + gpu_max_freq=`cat $GPU_MAX_FREQ` + gpu_min_limit=`cat $GPU_MIN_LIMIT` + gpu_max_limit=`cat $GPU_MAX_LIMIT` + gpu_boost_freq=`cat $GPU_BOOST_FREQ` + gpu_cur_freq=`cat $GPU_CUR_FREQ` +fi cpu_governor=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor` energy_perf=`cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference` if [ -z "$energy_perf" ]; then @@ -275,10 +277,10 @@ if check_isw; then cooler_boost="false" else cooler_boost=`cat /run/isw_cooler_boost` - if [ "cooler_boost" == "0" ]; then - cooler_boost="false" - else + if [ "$cooler_boost" == "1" ]; then cooler_boost="true" + else + cooler_boost="false" fi fi fi @@ -289,12 +291,14 @@ json="${json},\"cpu_max_perf\":\"${cpu_max_perf}\"" json="${json},\"cpu_turbo\":\"${cpu_turbo}\"" json="${json},\"cpu_total_available\":\"${cpu_total_available}\"" json="${json},\"cpu_online\":\"${cpu_online}\"" -json="${json},\"gpu_min_freq\":\"${gpu_min_freq}\"" -json="${json},\"gpu_max_freq\":\"${gpu_max_freq}\"" -json="${json},\"gpu_min_limit\":\"${gpu_min_limit}\"" -json="${json},\"gpu_max_limit\":\"${gpu_max_limit}\"" -json="${json},\"gpu_boost_freq\":\"${gpu_boost_freq}\"" -json="${json},\"gpu_cur_freq\":\"${gpu_cur_freq}\"" +if [ -f $GPU_MIN_FREQ ]; then + json="${json},\"gpu_min_freq\":\"${gpu_min_freq}\"" + json="${json},\"gpu_max_freq\":\"${gpu_max_freq}\"" + json="${json},\"gpu_min_limit\":\"${gpu_min_limit}\"" + json="${json},\"gpu_max_limit\":\"${gpu_max_limit}\"" + json="${json},\"gpu_boost_freq\":\"${gpu_boost_freq}\"" + json="${json},\"gpu_cur_freq\":\"${gpu_cur_freq}\"" +fi json="${json},\"cpu_governor\":\"${cpu_governor}\"" json="${json},\"energy_perf\":\"${energy_perf}\"" if check_dell_thermal; then From 054d6faf2c6980858b9c4799e1afbf1ec8f15ca1 Mon Sep 17 00:00:00 2001 From: Francesco Bonanno Date: Sun, 2 May 2021 19:10:35 +0200 Subject: [PATCH 06/10] Changed detection of isw exec --- .../contents/code/set_prefs.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh b/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh index 2be8dbb..bd06b06 100755 --- a/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh +++ b/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh @@ -50,11 +50,11 @@ check_nvidia () { } check_isw () { - command -v isw &> /dev/null; - if [ $OUT -eq 0 ]; then - return 1 - else + isw=`command -v isw` + if [ -z "${isw}" ]; then return 0 + else + return 1 fi } From d1ea79de5201d252bb4f775496d98b7d05b88598 Mon Sep 17 00:00:00 2001 From: Francesco Bonanno Date: Sun, 2 May 2021 19:23:20 +0200 Subject: [PATCH 07/10] Fixing a typo on detecting isw --- .../contents/code/set_prefs.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh b/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh index bd06b06..9460348 100755 --- a/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh +++ b/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh @@ -52,9 +52,9 @@ check_nvidia () { check_isw () { isw=`command -v isw` if [ -z "${isw}" ]; then - return 0 - else return 1 + else + return 0 fi } From 54cec6abfc7b505f2279fa9fde7b02f92b785ac3 Mon Sep 17 00:00:00 2001 From: Mario Medina Date: Tue, 11 May 2021 00:34:03 -0500 Subject: [PATCH 08/10] Adding support for AMD cpu --- .../contents/code/set_prefs.sh | 64 ++++++++++++++++--- .../contents/code/utils.js | 2 + 2 files changed, 58 insertions(+), 8 deletions(-) diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh b/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh index e017ac7..89327cc 100755 --- a/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh +++ b/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh @@ -1,9 +1,22 @@ #!/bin/bash -INTEL_PSTATE=/sys/devices/system/cpu/intel_pstate -CPU_MIN_PERF=$INTEL_PSTATE/min_perf_pct -CPU_MAX_PERF=$INTEL_PSTATE/max_perf_pct -CPU_TURBO=$INTEL_PSTATE/no_turbo +if [ -d /sys/devices/system/cpu/cpufreq ]; then + INTEL_PSTATE=/sys/devices/system/cpu/cpufreq + CPU_MIN_PERF=$INTEL_PSTATE/policy0/scaling_min_freq + CPU_MAX_PERF=$INTEL_PSTATE/policy0/scaling_max_freq + CPU_MIN_PERF_SET=$INTEL_PSTATE/policy*/scaling_min_freq + CPU_MAX_PERF_SET=$INTEL_PSTATE/policy*/scaling_max_freq + CPU_MIN_FREQ=$INTEL_PSTATE/policy0/cpuinfo_min_freq + CPU_MAX_FREQ=$INTEL_PSTATE/policy0/cpuinfo_max_freq + CPU_TURBO=$INTEL_PSTATE/boost + AMD=1 +else + INTEL_PSTATE=/sys/devices/system/cpu/intel_pstate + CPU_MIN_PERF=$INTEL_PSTATE/min_perf_pct + CPU_MAX_PERF=$INTEL_PSTATE/max_perf_pct + CPU_TURBO=$INTEL_PSTATE/no_turbo + AMD=0 +fi GPU=/sys/class/drm/card0 GPU_MIN_FREQ=$GPU/gt_min_freq_mhz @@ -48,15 +61,33 @@ check_nvidia () { set_cpu_min_perf () { minperf=$1 - if [ -n "$minperf" ] && [ "$minperf" != "0" ]; then + if [ -n "$minperf" ] && [ "$minperf" != "0" -a "$AMD" == "0" -o "$AMD" == "1" ]; then + if [ "$AMD" == "0" ]; then printf '%s\n' "$minperf" > $CPU_MIN_PERF; 2> /dev/null + else + minfreq=$(cat $CPU_MIN_FREQ) + maxfreq=$(cat $CPU_MAX_FREQ) + freq=$((($maxfreq-$minfreq)*$minperf/100 + $minfreq)) + for d in $CPU_MIN_PERF_SET; do + printf '%s\n' "$freq" > $d; 2> /dev/null + done + fi fi } set_cpu_max_perf () { maxperf=$1 if [ -n "$maxperf" ] && [ "$maxperf" != "0" ]; then + if [ "$AMD" == "0" ]; then printf '%s\n' "$maxperf" > $CPU_MAX_PERF; 2> /dev/null + else + minfreq=$(cat $CPU_MIN_FREQ) + maxfreq=$(cat $CPU_MAX_FREQ) + freq=$((($maxfreq-$minfreq)*$maxperf/100 + $minfreq)) + for d in $CPU_MAX_PERF_SET; do + printf '%s\n' "$freq" > $d; 2> /dev/null + done + fi fi } @@ -64,9 +95,17 @@ set_cpu_turbo () { turbo=$1 if [ -n "$turbo" ]; then if [ "$turbo" == "true" ]; then + if [ "$AMD" == "0" ]; then printf '0\n' > $CPU_TURBO; 2> /dev/null + else + printf '1\n' > $CPU_TURBO; 2> /dev/null + fi else + if [ "$AMD" == "0" ]; then printf '1\n' > $CPU_TURBO; 2> /dev/null + else + printf '0\n' > $CPU_TURBO; 2> /dev/null + fi fi fi } @@ -162,10 +201,19 @@ set_lg_usb_charge() { } read_all () { -cpu_min_perf=`cat $CPU_MIN_PERF` -cpu_max_perf=`cat $CPU_MAX_PERF` +if [ "$AMD" == "0" ]; then + cpu_min_perf=`cat $CPU_MIN_PERF` + cpu_max_perf=`cat $CPU_MAX_PERF` +else + cpu_min_freq=`cat $CPU_MIN_FREQ` + cpu_max_freq=`cat $CPU_MAX_FREQ` + max=$(cat $CPU_MAX_PERF) + min=$(cat $CPU_MIN_PERF) + cpu_max_perf=$(((100+($max-$cpu_max_freq)*100/$cpu_max_freq))) + cpu_min_perf=$((($min-$cpu_min_freq)*100/$cpu_min_freq)) +fi cpu_turbo=`cat $CPU_TURBO` -if [ "$cpu_turbo" == "1" ]; then +if [ "$cpu_turbo" == "1" -a "$AMD" = "0" -o "$cpu_turbo" == "0" -a "$AMD" = "1" ]; then cpu_turbo="false" else cpu_turbo="true" diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/code/utils.js b/gr.ictpro.jsalatas.plasma.pstate/contents/code/utils.js index db2d82d..f212c38 100644 --- a/gr.ictpro.jsalatas.plasma.pstate/contents/code/utils.js +++ b/gr.ictpro.jsalatas.plasma.pstate/contents/code/utils.js @@ -105,6 +105,8 @@ var model = [ ]}, {'type': 'radio', 'text': 'CPU Governor', 'sensor': 'cpu_governor', 'items' :[ {'symbol': 'a', 'text': 'Performance', 'sensor_value': 'performance'}, + {'symbol': 'k', 'text': 'Balance Performance', 'sensor_value': 'ondemand'}, + {'symbol': 'l', 'text': 'Balance Power', 'sensor_value': 'conservative'}, {'symbol': 'f', 'text': 'Powersave', 'sensor_value': 'powersave'} ]} ] From 4719190e97f3a1edffa11dc4a012f7219b346c56 Mon Sep 17 00:00:00 2001 From: Mario Medina Date: Tue, 11 May 2021 01:36:49 -0500 Subject: [PATCH 09/10] Adding support for AMD/Ryzen 7 and adding conservative and ondemand governors --- 99-plasma-pstate | 1 - README.md | 27 +- install.sh | 21 +- .../contents/code/get_thermal.sh | 2 + ...e.mibofra.plasma.pstate.get-thermal.policy | 17 + ...cle.mibofra.plasma.pstate.set-prefs.policy | 17 + .../contents/code/set_prefs.sh | 164 +++++-- .../contents/code/set_prefs.sh~ | 461 ++++++++++++++++++ .../contents/code/utils.js | 17 +- .../contents/code/utils.js~ | 185 +++++++ .../contents/config/config.qml | 0 .../contents/config/main.xml | 3 - .../contents/font/plasma-pstate.ttf | Bin .../contents/ui/ComboBox.qml | 2 +- .../contents/ui/CompactRepresentation.qml | 0 .../contents/ui/FullRepresentation.qml | 9 - .../contents/ui/Group.qml | 0 .../contents/ui/Header.qml | 0 .../contents/ui/PushButton.qml | 0 .../contents/ui/Radio.qml | 0 .../contents/ui/Slider.qml | 0 .../contents/ui/Switch.qml | 0 .../contents/ui/config/ConfigGeneral.qml | 7 - .../contents/ui/config/IconPicker.qml | 0 .../contents/ui/main.qml | 14 +- .../metadata.desktop | 8 +- uninstall.sh | 6 +- 27 files changed, 854 insertions(+), 107 deletions(-) delete mode 100644 99-plasma-pstate create mode 100755 org.thefreecircle.mibofra.plasma.pstate/contents/code/get_thermal.sh create mode 100644 org.thefreecircle.mibofra.plasma.pstate/contents/code/org.thefreecircle.mibofra.plasma.pstate.get-thermal.policy create mode 100644 org.thefreecircle.mibofra.plasma.pstate/contents/code/org.thefreecircle.mibofra.plasma.pstate.set-prefs.policy rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/code/set_prefs.sh (65%) create mode 100755 org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh~ rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/code/utils.js (91%) create mode 100644 org.thefreecircle.mibofra.plasma.pstate/contents/code/utils.js~ rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/config/config.qml (100%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/config/main.xml (85%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/font/plasma-pstate.ttf (100%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/ui/ComboBox.qml (98%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/ui/CompactRepresentation.qml (100%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/ui/FullRepresentation.qml (94%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/ui/Group.qml (100%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/ui/Header.qml (100%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/ui/PushButton.qml (100%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/ui/Radio.qml (100%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/ui/Slider.qml (100%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/ui/Switch.qml (100%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/ui/config/ConfigGeneral.qml (81%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/ui/config/IconPicker.qml (100%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/contents/ui/main.qml (93%) rename {gr.ictpro.jsalatas.plasma.pstate => org.thefreecircle.mibofra.plasma.pstate}/metadata.desktop (63%) diff --git a/99-plasma-pstate b/99-plasma-pstate deleted file mode 100644 index 70a42ab..0000000 --- a/99-plasma-pstate +++ /dev/null @@ -1 +0,0 @@ -%sudo ALL=NOPASSWD: /usr/share/plasma/plasmoids/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh diff --git a/README.md b/README.md index 23910a0..343d7dc 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,5 @@ # Intel P-state and CPUFreq Manager Widget -```diff --Important -``` -as of October 11, 2020, I'm not willing to maintain this widget anymore. I will maintain it based only to my personal needs. I thank you for your support and feedback all this time. Hope the community will take over from here and make the widget even better than it is now. - ## What it is Intel P-state and CPUFreq Manager is a KDE Plasma widget in order to control the frequencies of Intel CPUs and their integrated GPUs for any modern Intel @@ -33,6 +28,10 @@ through [libsmbios library](https://github.com/dell/libsmbios). Intel P-state and CPUFreq Manager Widget with Nvidia PowerMizer Settings +4. MSI Cooler Boost + +- This assume that you already have seen if your laptop is supported by ISW tool, already seen https://github.com/YoyPa/isw/blob/master/README.md and set up it, and isw is in the executable path. + ## What it isn't This is just a GUI widget and it is not meant to replace @@ -74,9 +73,10 @@ sudo apt install linux-tools-generic linux-tools-`uname -r` Assuming that you have checked out the latest code, you just need to run the following commands as root: ``` -sudo kpackagetool5 -g -t Plasma/Applet -u gr.ictpro.jsalatas.plasma.pstate +sudo kpackagetool5 -g -t Plasma/Applet -u org.thefreecircle.mibofra.plasma.pstate -sudo chmod 755 /usr/share/plasma/plasmoids/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh +sudo chmod 755 /usr/share/plasma/plasmoids/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh +sudo chmod 755 /usr/share/plasma/plasmoids/org.thefreecircle.mibofra.plasma.pstate/contents/code/get_thermal.sh ``` @@ -86,10 +86,17 @@ especially in relation to similar to Dell's Thermal Management Feature that may be available in other hardware platforms. ## Issues -The widget uses a shell script that needs to be run as root user (sudo) and which apparently floods your log files with security related messages as described in [issue #16](https://github.com/jsalatas/plasma-pstate/issues/16). -If you want to get rid of these messages, please see a workaround at +Using PolKit, I don't see any log flood a the moment. + +If it's not your case, plese read: https://github.com/jsalatas/plasma-pstate/wiki/Too-many-messages-in-system-log + +For option with a slider, please, be sure to slide them and not click on an arbitrary point of the slider. This will ensure that, the plasmoid slider is working fine, getting the preference issued, avoiding it to bug plasmashell, the plasmoid, or the panel where it is docked. And surely, making polkit agent asking the password for setting the preference, as expected. + +## Info -https://github.com/jsalatas/plasma-pstate/wiki/Too-many-messages-in-system-log +The original author is maintaining the plasmoid up to his needs, see the head of: https://github.com/jsalatas/plasma-pstate/blob/master/README.md , +also because there are efforts to have hardware profiles directly in powerdevil and kcm like in gnome with https://gitlab.freedesktop.org/hadess/power-profiles-daemon . +Anyway, some tools can be still useful for some users, like me, who added the possibility to set the number of online cpus, or other tools that are out of scope of powerdevil and kcm itself. So I'm trying to keep at least it up to date, in a working state with latest KDE releases, trying to adding new functions if needed. With patience and time, also trying to redesing the ui, as the original author wanted: https://github.com/jsalatas/plasma-pstate/issues/40 (or the space on the desktop for the tools will decrease). diff --git a/install.sh b/install.sh index 7a06a82..9e1f7dc 100755 --- a/install.sh +++ b/install.sh @@ -5,24 +5,13 @@ if [[ $EUID -ne 0 ]]; then exit 1 fi -SUDOERS_FILE="99-plasma-pstate" +kpackagetool5 -g -t Plasma/Applet -i org.thefreecircle.mibofra.plasma.pstate -cp -R ${SUDOERS_FILE} /etc/sudoers.d/ -kpackagetool5 -g -t Plasma/Applet -i gr.ictpro.jsalatas.plasma.pstate +chmod 755 /usr/share/plasma/plasmoids/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh +chmod 755 /usr/share/plasma/plasmoids/org.thefreecircle.mibofra.plasma.pstate/contents/code/get_thermal.sh -chmod 755 /usr/share/plasma/plasmoids/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh - -chown root:root /etc/sudoers.d/${SUDOERS_FILE} -chmod 400 /etc/sudoers.d/${SUDOERS_FILE} - -# Test for wheel group instead of sudo -# this is the case of arch based distros -wheelgroup=`grep wheel /etc/group | wc -l` -sudogroup=`grep sudo /etc/group | wc -l` -if [ "$wheelgroup" -eq "1" ] && [ "$sudogroup" -eq "0" ]; then - # seems to be safe enough: there is a wheel group and not a sudo group - sed -i 's/sudo/wheel/' /etc/sudoers.d/${SUDOERS_FILE} -fi +cp org.thefreecircle.mibofra.plasma.pstate/contents/code/org.thefreecircle.mibofra.plasma.pstate.get-thermal.policy /usr/share/polkit-1/actions/ +cp org.thefreecircle.mibofra.plasma.pstate/contents/code/org.thefreecircle.mibofra.plasma.pstate.set-prefs.policy /usr/share/polkit-1/actions/ echo -e "\nSetup complete." exit 0 diff --git a/org.thefreecircle.mibofra.plasma.pstate/contents/code/get_thermal.sh b/org.thefreecircle.mibofra.plasma.pstate/contents/code/get_thermal.sh new file mode 100755 index 0000000..159dac8 --- /dev/null +++ b/org.thefreecircle.mibofra.plasma.pstate/contents/code/get_thermal.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +smbios-thermal-ctl -g \ No newline at end of file diff --git a/org.thefreecircle.mibofra.plasma.pstate/contents/code/org.thefreecircle.mibofra.plasma.pstate.get-thermal.policy b/org.thefreecircle.mibofra.plasma.pstate/contents/code/org.thefreecircle.mibofra.plasma.pstate.get-thermal.policy new file mode 100644 index 0000000..1360f5a --- /dev/null +++ b/org.thefreecircle.mibofra.plasma.pstate/contents/code/org.thefreecircle.mibofra.plasma.pstate.get-thermal.policy @@ -0,0 +1,17 @@ + + + + + + Authentication is required to run Plasma P-state (Get thermal info) + + no + no + yes + + /usr/share/plasma/plasmoids/org.thefreecircle.mibofra.plasma.pstate/contents/code/get_thermal.sh + + + diff --git a/org.thefreecircle.mibofra.plasma.pstate/contents/code/org.thefreecircle.mibofra.plasma.pstate.set-prefs.policy b/org.thefreecircle.mibofra.plasma.pstate/contents/code/org.thefreecircle.mibofra.plasma.pstate.set-prefs.policy new file mode 100644 index 0000000..5b9b2c3 --- /dev/null +++ b/org.thefreecircle.mibofra.plasma.pstate/contents/code/org.thefreecircle.mibofra.plasma.pstate.set-prefs.policy @@ -0,0 +1,17 @@ + + + + + + Authentication is required to run Plasma P-state + + no + no + auth_admin + + /usr/share/plasma/plasmoids/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh + + + diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh b/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh similarity index 65% rename from gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh rename to org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh index 89327cc..9ccfd71 100755 --- a/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh +++ b/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh @@ -1,22 +1,26 @@ -#!/bin/bash +#!/usr/bin/env bash + +ACPI_CPU=/sys/devices/system/cpu if [ -d /sys/devices/system/cpu/cpufreq ]; then - INTEL_PSTATE=/sys/devices/system/cpu/cpufreq - CPU_MIN_PERF=$INTEL_PSTATE/policy0/scaling_min_freq - CPU_MAX_PERF=$INTEL_PSTATE/policy0/scaling_max_freq - CPU_MIN_PERF_SET=$INTEL_PSTATE/policy*/scaling_min_freq - CPU_MAX_PERF_SET=$INTEL_PSTATE/policy*/scaling_max_freq - CPU_MIN_FREQ=$INTEL_PSTATE/policy0/cpuinfo_min_freq - CPU_MAX_FREQ=$INTEL_PSTATE/policy0/cpuinfo_max_freq - CPU_TURBO=$INTEL_PSTATE/boost - AMD=1 -else - INTEL_PSTATE=/sys/devices/system/cpu/intel_pstate - CPU_MIN_PERF=$INTEL_PSTATE/min_perf_pct - CPU_MAX_PERF=$INTEL_PSTATE/max_perf_pct - CPU_TURBO=$INTEL_PSTATE/no_turbo - AMD=0 + INTEL_PSTATE=$ACPI_CPU/cpufreq + CPU_MIN_PERF=$INTEL_PSTATE/policy0/scaling_min_freq + CPU_MAX_PERF=$INTEL_PSTATE/policy0/scaling_max_freq + CPU_MIN_PERF_SET=$INTEL_PSTATE/policy*/scaling_min_freq + CPU_MAX_PERF_SET=$INTEL_PSTATE/policy*/scaling_max_freq + CPU_MIN_FREQ=$INTEL_PSTATE/policy0/cpuinfo_min_freq + CPU_MAX_FREQ=$INTEL_PSTATE/policy0/cpuinfo_max_freq + CPU_TURBO=$INTEL_PSTATE/boost + AMD=1 +else + INTEL_PSTATE=$ACPI_CPU/intel_pstate + CPU_MIN_PERF=$INTEL_PSTATE/min_perf_pct + CPU_MAX_PERF=$INTEL_PSTATE/max_perf_pct + CPU_TURBO=$INTEL_PSTATE/no_turbo + AMD=0 fi +CPU_TOTAL_AVAILABLE=$(nproc --all) +CPU_ONLINE=$(nproc) GPU=/sys/class/drm/card0 GPU_MIN_FREQ=$GPU/gt_min_freq_mhz @@ -40,7 +44,7 @@ check_lg_drivers() { } check_dell_thermal () { - smbios-thermal-ctl -g > /dev/null 2>&1 + /usr/bin/pkexec /usr/share/plasma/plasmoids/org.thefreecircle.mibofra.plasma.pstate/contents/code/get_thermal.sh > /dev/null 2>&1 OUT=$? if [ $OUT -eq 0 ]; then return 0 @@ -59,6 +63,15 @@ check_nvidia () { fi } +check_isw () { + isw=`command -v isw` + if [ -z "${isw}" ]; then + return 1 + else + return 0 + fi +} + set_cpu_min_perf () { minperf=$1 if [ -n "$minperf" ] && [ "$minperf" != "0" -a "$AMD" == "0" -o "$AMD" == "1" ]; then @@ -67,10 +80,10 @@ set_cpu_min_perf () { else minfreq=$(cat $CPU_MIN_FREQ) maxfreq=$(cat $CPU_MAX_FREQ) - freq=$((($maxfreq-$minfreq)*$minperf/100 + $minfreq)) - for d in $CPU_MIN_PERF_SET; do + freq=$((($maxfreq-$minfreq)*$minperf/100 + $minfreq)) + for d in $CPU_MIN_PERF_SET; do printf '%s\n' "$freq" > $d; 2> /dev/null - done + done fi fi } @@ -83,8 +96,8 @@ set_cpu_max_perf () { else minfreq=$(cat $CPU_MIN_FREQ) maxfreq=$(cat $CPU_MAX_FREQ) - freq=$((($maxfreq-$minfreq)*$maxperf/100 + $minfreq)) - for d in $CPU_MAX_PERF_SET; do + freq=$((($maxfreq-$minfreq)*$maxperf/100 + $minfreq)) + for d in $CPU_MAX_PERF_SET; do printf '%s\n' "$freq" > $d; 2> /dev/null done fi @@ -110,6 +123,32 @@ set_cpu_turbo () { fi } +set_cpu_state () { + num=$1 + num_off=$[$CPU_TOTAL_AVAILABLE-$num] + counter=1 + limit=$[$num-1] + all_off=$[$CPU_TOTAL_AVAILABLE-1] + if [ -n "$num" ] && [ "$num" != "0" ]; then + if [ "$num" -ne "1" ]; then + while [ "$counter" -le "$limit" ]; do + printf '1\n' > $ACPI_CPU/cpu$counter/online; 2> /dev/null + counter=$[$counter+1] + done + limit=$[$limit+$num_off] + while [ "$counter" -le "$limit" ]; do + printf '0\n' > $ACPI_CPU/cpu$counter/online; 2> /dev/null + counter=$[$counter+1] + done + else + while [ "$counter" -le "$all_off" ]; do + printf '0\n' > $ACPI_CPU/cpu$counter/online; 2> /dev/null + counter=$[$counter+1] + done + fi + fi +} + set_gpu_min_freq () { gpuminfreq=$1 if [ -n "$gpuminfreq" ] && [ "$gpuminfreq" != "0" ]; then @@ -178,9 +217,9 @@ set_lg_fan_mode() { enabled=$1 if [ -n "$enabled" ]; then if [ "$enabled" == "true" ]; then - printf '0\n' > $LG_FAN_MODE; 2> /dev/null + printf '0' > $LG_FAN_MODE; 2> /dev/null else - printf '1\n' > $LG_FAN_MODE; 2> /dev/null + printf '1' > $LG_FAN_MODE; 2> /dev/null fi fi } @@ -200,6 +239,19 @@ set_lg_usb_charge() { fi } +set_cooler_boost () { + boost=$1 + if [ -n "$boost" ]; then + if [ "$boost" == "true" ]; then + printf '1\n' > /run/isw_cooler_boost; 2> /dev/null + isw -b on; 2> /dev/null + else + printf '0\n' > /run/isw_cooler_boost; 2> /dev/null + isw -b off; 2> /dev/null + fi + fi +} + read_all () { if [ "$AMD" == "0" ]; then cpu_min_perf=`cat $CPU_MIN_PERF` @@ -212,18 +264,22 @@ else cpu_max_perf=$(((100+($max-$cpu_max_freq)*100/$cpu_max_freq))) cpu_min_perf=$((($min-$cpu_min_freq)*100/$cpu_min_freq)) fi +cpu_total_available=`echo $CPU_TOTAL_AVAILABLE` +cpu_online=`echo $CPU_ONLINE` cpu_turbo=`cat $CPU_TURBO` if [ "$cpu_turbo" == "1" -a "$AMD" = "0" -o "$cpu_turbo" == "0" -a "$AMD" = "1" ]; then cpu_turbo="false" else cpu_turbo="true" fi -gpu_min_freq=`cat $GPU_MIN_FREQ` -gpu_max_freq=`cat $GPU_MAX_FREQ` -gpu_min_limit=`cat $GPU_MIN_LIMIT` -gpu_max_limit=`cat $GPU_MAX_LIMIT` -gpu_boost_freq=`cat $GPU_BOOST_FREQ` -gpu_cur_freq=`cat $GPU_CUR_FREQ` +if [ -f $GPU_MIN_FREQ ]; then + gpu_min_freq=`cat $GPU_MIN_FREQ` + gpu_max_freq=`cat $GPU_MAX_FREQ` + gpu_min_limit=`cat $GPU_MIN_LIMIT` + gpu_max_limit=`cat $GPU_MAX_LIMIT` + gpu_boost_freq=`cat $GPU_BOOST_FREQ` + gpu_cur_freq=`cat $GPU_CUR_FREQ` +fi cpu_governor=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor` energy_perf=`cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference` if [ -z "$energy_perf" ]; then @@ -237,7 +293,7 @@ if [ -z "$energy_perf" ]; then awk '{ printf "%s\n", $2; }' | head -n 1` fi if check_dell_thermal; then - thermal_mode=`smbios-thermal-ctl -g | grep -C 1 "Current Thermal Modes:" | tail -n 1 | awk '{$1=$1;print}' | sed "s/\t//g" | sed "s/ /-/g" | tr "[A-Z]" "[a-z]" ` + thermal_mode=`/usr/bin/pkexec /usr/share/plasma/plasmoids/org.thefreecircle.mibofra.plasma.pstate/contents/code/get_thermal.sh | grep -C 1 "Current Thermal Modes:" | tail -n 1 | awk '{$1=$1;print}' | sed "s/\t//g" | sed "s/ /-/g" | tr "[A-Z]" "[a-z]" ` fi if check_lg_drivers; then @@ -262,19 +318,36 @@ if check_lg_drivers; then fi if check_nvidia; then - powermizer=`nvidia-settings -q GpuPowerMizerMode | grep "Attribute 'GPUPowerMizerMode'" | awk -F "): " '{print $2}' | awk -F "." '{print $1}' ` + powermizer=`nvidia-settings -q GpuPowerMizerMode 2> /dev/null | grep "Attribute 'GPUPowerMizerMode'" | awk -F "): " '{print $2}' | awk -F "." '{print $1}' ` +fi + +if check_isw; then + if [[ ! -f /run/isw_cooler_boost ]]; then + cooler_boost="false" + else + cooler_boost=`cat /run/isw_cooler_boost` + if [ "$cooler_boost" == "1" ]; then + cooler_boost="true" + else + cooler_boost="false" + fi + fi fi json="{" json="${json}\"cpu_min_perf\":\"${cpu_min_perf}\"" json="${json},\"cpu_max_perf\":\"${cpu_max_perf}\"" json="${json},\"cpu_turbo\":\"${cpu_turbo}\"" -json="${json},\"gpu_min_freq\":\"${gpu_min_freq}\"" -json="${json},\"gpu_max_freq\":\"${gpu_max_freq}\"" -json="${json},\"gpu_min_limit\":\"${gpu_min_limit}\"" -json="${json},\"gpu_max_limit\":\"${gpu_max_limit}\"" -json="${json},\"gpu_boost_freq\":\"${gpu_boost_freq}\"" -json="${json},\"gpu_cur_freq\":\"${gpu_cur_freq}\"" +json="${json},\"cpu_total_available\":\"${cpu_total_available}\"" +json="${json},\"cpu_online\":\"${cpu_online}\"" +if [ -f $GPU_MIN_FREQ ]; then + json="${json},\"gpu_min_freq\":\"${gpu_min_freq}\"" + json="${json},\"gpu_max_freq\":\"${gpu_max_freq}\"" + json="${json},\"gpu_min_limit\":\"${gpu_min_limit}\"" + json="${json},\"gpu_max_limit\":\"${gpu_max_limit}\"" + json="${json},\"gpu_boost_freq\":\"${gpu_boost_freq}\"" + json="${json},\"gpu_cur_freq\":\"${gpu_cur_freq}\"" +fi json="${json},\"cpu_governor\":\"${cpu_governor}\"" json="${json},\"energy_perf\":\"${energy_perf}\"" if check_dell_thermal; then @@ -288,6 +361,9 @@ fi if check_nvidia; then json="${json},\"powermizer\":\"${powermizer}\"" fi +if check_isw; then + json="${json},\"cooler_boost\":\"${cooler_boost}\"" +fi json="${json}}" echo $json } @@ -305,6 +381,10 @@ case $1 in set_cpu_turbo $2 ;; + "-cpu-online") + set_cpu_state $2 + ;; + "-gpu-min-freq") set_gpu_min_freq $2 ;; @@ -345,6 +425,10 @@ case $1 in set_powermizer $2 ;; + "-cooler-boost") + set_cooler_boost $2 + ;; + "-read-all") read_all ;; @@ -354,6 +438,7 @@ case $1 in echo "1: set_prefs.sh [ -cpu-min-perf |" echo " -cpu-max-perf |" echo " -cpu-turbo |" + echo " -cpu-online |" echo " -gpu-min-freq |" echo " -gpu-max-freq |" echo " -gpu-boost-freq |" @@ -363,7 +448,8 @@ case $1 in echo " -lg-battery-charge-limit |" echo " -lg-fan-mode |" echo " -lg-usb-charge |" - echo " -powermizer ] value" + echo " -powermizer |" + echo " -cooler-boost ] value" echo "2: set_prefs.sh -read-all" exit 3 ;; diff --git a/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh~ b/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh~ new file mode 100755 index 0000000..318799a --- /dev/null +++ b/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh~ @@ -0,0 +1,461 @@ +#!/usr/bin/env bash + +ACPI_CPU=/sys/devices/system/cpu + +if [ -d /sys/devices/system/cpu/cpufreq ]; then + INTEL_PSTATE=$ACPI_CPU/cpufreq + CPU_MIN_PERF=$INTEL_PSTATE/policy0/scaling_min_freq + CPU_MAX_PERF=$INTEL_PSTATE/policy0/scaling_max_freq + CPU_MIN_PERF_SET=$INTEL_PSTATE/policy*/scaling_min_freq + CPU_MAX_PERF_SET=$INTEL_PSTATE/policy*/scaling_max_freq + CPU_MIN_FREQ=$INTEL_PSTATE/policy0/cpuinfo_min_freq + CPU_MAX_FREQ=$INTEL_PSTATE/policy0/cpuinfo_max_freq + CPU_TURBO=$INTEL_PSTATE/boost + AMD=1 +else + INTEL_PSTATE=$ACPI_CPU/intel_pstate + CPU_MIN_PERF=$INTEL_PSTATE/min_perf_pct + CPU_MAX_PERF=$INTEL_PSTATE/max_perf_pct + CPU_TURBO=$INTEL_PSTATE/no_turbo + AMD=0 +fi +CPU_TOTAL_AVAILABLE=$(nproc --all) +CPU_ONLINE=$(nproc) + +GPU=/sys/class/drm/card0 +GPU_MIN_FREQ=$GPU/gt_min_freq_mhz +GPU_MAX_FREQ=$GPU/gt_max_freq_mhz +GPU_MIN_LIMIT=$GPU/gt_RP1_freq_mhz +GPU_MAX_LIMIT=$GPU/gt_RP0_freq_mhz +GPU_BOOST_FREQ=$GPU/gt_boost_freq_mhz +GPU_CUR_FREQ=$GPU/gt_cur_freq_mhz + +LG_LAPTOP_DRIVER=/sys/devices/platform/lg-laptop +LG_FAN_MODE=$LG_LAPTOP_DRIVER/fan_mode +LG_BATTERY_CHARGE_LIMIT=$LG_LAPTOP_DRIVER/battery_care_limit +LG_USB_CHARGE=$LG_LAPTOP_DRIVER/usb_charge + +check_lg_drivers() { + if [ -d $LG_LAPTOP_DRIVER ]; then + return 0 + else + return 1 + fi +} + +check_dell_thermal () { + /usr/bin/pkexec /usr/share/plasma/plasmoids/org.thefreecircle.mibofra.plasma.pstate/contents/code/get_thermal.sh > /dev/null 2>&1 + OUT=$? + if [ $OUT -eq 0 ]; then + return 0 + else + return 1 + fi +} + +check_nvidia () { + nvidia-settings -q GpuPowerMizerMode > /dev/null 2>&1 + OUT=$? + if [ $OUT -eq 0 ]; then + return 0 + else + return 1 + fi +} + +check_isw () { + isw=`command -v isw` + if [ -z "${isw}" ]; then + return 1 + else + return 0 + fi +} + +set_cpu_min_perf () { + minperf=$1 + if [ -n "$minperf" ] && [ "$minperf" != "0" -a "$AMD" == "0" -o "$AMD" == "1" ]; then + if [ "$AMD" == "0" ]; then + printf '%s\n' "$minperf" > $CPU_MIN_PERF; 2> /dev/null + else + minfreq=$(cat $CPU_MIN_FREQ) + maxfreq=$(cat $CPU_MAX_FREQ) + freq=$((($maxfreq-$minfreq)*$minperf/100 + $minfreq)) + for d in $CPU_MIN_PERF_SET; do + printf '%s\n' "$freq" > $d; 2> /dev/null + done + fi + fi +} + +set_cpu_max_perf () { + maxperf=$1 + if [ -n "$maxperf" ] && [ "$maxperf" != "0" ]; then + if [ "$AMD" == "0" ]; then + printf '%s\n' "$maxperf" > $CPU_MAX_PERF; 2> /dev/null + else + minfreq=$(cat $CPU_MIN_FREQ) + maxfreq=$(cat $CPU_MAX_FREQ) + freq=$((($maxfreq-$minfreq)*$maxperf/100 + $minfreq)) + for d in $CPU_MAX_PERF_SET; do + printf '%s\n' "$freq" > $d; 2> /dev/null + done + fi + fi +} + +set_cpu_turbo () { + turbo=$1 + if [ -n "$turbo" ]; then + if [ "$turbo" == "true" ]; then + if [ "$AMD" == "0" ]; then + printf '0\n' > $CPU_TURBO; 2> /dev/null + else + printf '1\n' > $CPU_TURBO; 2> /dev/null + fi + else + if [ "$AMD" == "0" ]; then + printf '1\n' > $CPU_TURBO; 2> /dev/null + else + printf '0\n' > $CPU_TURBO; 2> /dev/null + fi + fi + fi +} + +set_cpu_state () { + num=$1 + num_off=$[$CPU_TOTAL_AVAILABLE-$num] + counter=1 + limit=$[$num-1] + all_off=$[$CPU_TOTAL_AVAILABLE-1] + if [ -n "$num" ] && [ "$num" != "0" ]; then + if [ "$num" -ne "1" ]; then + while [ "$counter" -le "$limit" ]; do + printf '1\n' > $ACPI_CPU/cpu$counter/online; 2> /dev/null + counter=$[$counter+1] + done + limit=$[$limit+$num_off] + while [ "$counter" -le "$limit" ]; do + printf '0\n' > $ACPI_CPU/cpu$counter/online; 2> /dev/null + counter=$[$counter+1] + done + else + while [ "$counter" -le "$all_off" ]; do + printf '0\n' > $ACPI_CPU/cpu$counter/online; 2> /dev/null + counter=$[$counter+1] + done + fi + fi +} + +set_gpu_min_freq () { + gpuminfreq=$1 + if [ -n "$gpuminfreq" ] && [ "$gpuminfreq" != "0" ]; then + printf '%s\n' "$gpuminfreq" > $GPU_MIN_FREQ; 2> /dev/null + fi +} + +set_gpu_max_freq () { + gpumaxfreq=$1 + if [ -n "$gpumaxfreq" ] && [ "$gpumaxfreq" != "0" ]; then + printf '%s\n' "$gpumaxfreq" > $GPU_MAX_FREQ; 2> /dev/null + fi +} + +set_gpu_boost_freq () { + gpuboostfreq=$1 + if [ -n "$gpuboostfreq" ] && [ "$gpuboostfreq" != "0" ]; then + printf '%s\n' "$gpuboostfreq" > $GPU_BOOST_FREQ; 2> /dev/null + fi +} + +set_cpu_governor () { + gov=$1 + if [ -n "$gov" ]; then + for cpu in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do + printf '%s\n' "$gov" > $cpu; 2> /dev/null + done + fi +} + +set_energy_perf () { + energyperf=$1 + if [ -n "$energyperf" ]; then + if [ -f /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference ]; then + for cpu in /sys/devices/system/cpu/cpu*/cpufreq/energy_performance_preference; do + printf '%s\n' "$energyperf" > $cpu; 2> /dev/null + done + else + pnum=$(echo $energyperf | sed -r 's/^performance$/0/; + s/^balance_performance$/4/; + s/^(default|normal)$/6/; + s/^balance_power?$/8/; + s/^power(save)?$/15/') + + x86_energy_perf_policy $pnum > /dev/null 2>&1 + fi + fi +} + +set_thermal_mode () { + smbios-thermal-ctl --set-thermal-mode=$1 2> /dev/null +} + +set_lg_battery_charge_limit(){ + enabled=$1 + if [ -n "$enabled" ]; then + if [ "$enabled" == "true" ]; then + printf '80\n' > $LG_BATTERY_CHARGE_LIMIT; 2> /dev/null + else + printf '100\n' > $LG_BATTERY_CHARGE_LIMIT; 2> /dev/null + fi + fi +} + +set_lg_fan_mode() { + enabled=$1 + if [ -n "$enabled" ]; then + if [ "$enabled" == "true" ]; then + printf '0' > $LG_FAN_MODE; 2> /dev/null + else + printf '1' > $LG_FAN_MODE; 2> /dev/null + fi + fi +} + +set_powermizer () { + nvidia-settings -a "[gpu:0]/GpuPowerMizerMode=$1" 2> /dev/null +} + +set_lg_usb_charge() { + enabled=$1 + if [ -n "$enabled" ]; then + if [ "$enabled" == "true" ]; then + printf '1\n' > $LG_USB_CHARGE; 2> /dev/null + else + printf '0\n' > $LG_USB_CHARGE; 2> /dev/null + fi + fi +} + +set_cooler_boost () { + boost=$1 + if [ -n "$boost" ]; then + if [ "$boost" == "true" ]; then + printf '1\n' > /run/isw_cooler_boost; 2> /dev/null + isw -b on; 2> /dev/null + else + printf '0\n' > /run/isw_cooler_boost; 2> /dev/null + isw -b off; 2> /dev/null + fi + fi +} + +read_all () { +if [ "$AMD" == "0" ]; then + cpu_min_perf=`cat $CPU_MIN_PERF` + cpu_max_perf=`cat $CPU_MAX_PERF` +else + cpu_min_freq=`cat $CPU_MIN_FREQ` + cpu_max_freq=`cat $CPU_MAX_FREQ` + max=$(cat $CPU_MAX_PERF) + min=$(cat $CPU_MIN_PERF) + cpu_max_perf=$(((100+($max-$cpu_max_freq)*100/$cpu_max_freq))) + cpu_min_perf=$((($min-$cpu_min_freq)*100/$cpu_min_freq)) +fi +cpu_turbo=`cat $CPU_TURBO` +if [ "$cpu_turbo" == "1" -a "$AMD" = "0" -o "$cpu_turbo" == "0" -a "$AMD" = "1" ]; then + cpu_turbo="false" +else + cpu_turbo="true" +fi +cpu_total_available=`echo $CPU_TOTAL_AVAILABLE` +cpu_online=`echo $CPU_ONLINE` +if [ "$cpu_turbo" == "1" ]; then + cpu_turbo="false" +else + cpu_turbo="true" +fi +if [ -f $GPU_MIN_FREQ ]; then + gpu_min_freq=`cat $GPU_MIN_FREQ` + gpu_max_freq=`cat $GPU_MAX_FREQ` + gpu_min_limit=`cat $GPU_MIN_LIMIT` + gpu_max_limit=`cat $GPU_MAX_LIMIT` + gpu_boost_freq=`cat $GPU_BOOST_FREQ` + gpu_cur_freq=`cat $GPU_CUR_FREQ` +fi +cpu_governor=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor` +energy_perf=`cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference` +if [ -z "$energy_perf" ]; then + energy_perf=`x86_energy_perf_policy -r 2>/dev/null | grep -v 'HWP_' | \ + sed -r 's/://; + s/(0x0000000000000000|EPB 0)/performance/; + s/(0x0000000000000004|EPB 4)/balance_performance/; + s/(0x0000000000000006|EPB 6)/default/; + s/(0x0000000000000008|EPB 8)/balance_power/; + s/(0x000000000000000f|EPB 15)/power/' | \ + awk '{ printf "%s\n", $2; }' | head -n 1` +fi +if check_dell_thermal; then + thermal_mode=`/usr/bin/pkexec /usr/share/plasma/plasmoids/org.thefreecircle.mibofra.plasma.pstate/contents/code/get_thermal.sh | grep -C 1 "Current Thermal Modes:" | tail -n 1 | awk '{$1=$1;print}' | sed "s/\t//g" | sed "s/ /-/g" | tr "[A-Z]" "[a-z]" ` +fi + +if check_lg_drivers; then + lg_battery_charge_limit=`cat $LG_BATTERY_CHARGE_LIMIT` + if [ "$lg_battery_charge_limit" == "80" ]; then + lg_battery_charge_limit="true" + else + lg_battery_charge_limit="false" + fi + lg_usb_charge=`cat $LG_USB_CHARGE` + if [ "$lg_usb_charge" == "1" ]; then + lg_usb_charge="true" + else + lg_usb_charge="false" + fi + lg_fan_mode=`cat $LG_FAN_MODE` + if [ "$lg_fan_mode" == "1" ]; then + lg_fan_mode="false" + else + lg_fan_mode="true" + fi +fi + +if check_nvidia; then + powermizer=`nvidia-settings -q GpuPowerMizerMode 2> /dev/null | grep "Attribute 'GPUPowerMizerMode'" | awk -F "): " '{print $2}' | awk -F "." '{print $1}' ` +fi + +if check_isw; then + if [[ ! -f /run/isw_cooler_boost ]]; then + cooler_boost="false" + else + cooler_boost=`cat /run/isw_cooler_boost` + if [ "$cooler_boost" == "1" ]; then + cooler_boost="true" + else + cooler_boost="false" + fi + fi +fi + +json="{" +json="${json}\"cpu_min_perf\":\"${cpu_min_perf}\"" +json="${json},\"cpu_max_perf\":\"${cpu_max_perf}\"" +json="${json},\"cpu_turbo\":\"${cpu_turbo}\"" +json="${json},\"cpu_total_available\":\"${cpu_total_available}\"" +json="${json},\"cpu_online\":\"${cpu_online}\"" +if [ -f $GPU_MIN_FREQ ]; then + json="${json},\"gpu_min_freq\":\"${gpu_min_freq}\"" + json="${json},\"gpu_max_freq\":\"${gpu_max_freq}\"" + json="${json},\"gpu_min_limit\":\"${gpu_min_limit}\"" + json="${json},\"gpu_max_limit\":\"${gpu_max_limit}\"" + json="${json},\"gpu_boost_freq\":\"${gpu_boost_freq}\"" + json="${json},\"gpu_cur_freq\":\"${gpu_cur_freq}\"" +fi +json="${json},\"cpu_governor\":\"${cpu_governor}\"" +json="${json},\"energy_perf\":\"${energy_perf}\"" +if check_dell_thermal; then + json="${json},\"thermal_mode\":\"${thermal_mode}\"" +fi +if check_lg_drivers; then + json="${json},\"lg_battery_charge_limit\":\"${lg_battery_charge_limit}\"" + json="${json},\"lg_usb_charge\":\"${lg_usb_charge}\"" + json="${json},\"lg_fan_mode\":\"${lg_fan_mode}\"" +fi +if check_nvidia; then + json="${json},\"powermizer\":\"${powermizer}\"" +fi +if check_isw; then + json="${json},\"cooler_boost\":\"${cooler_boost}\"" +fi +json="${json}}" +echo $json +} + +case $1 in + "-cpu-min-perf") + set_cpu_min_perf $2 + ;; + + "-cpu-max-perf") + set_cpu_max_perf $2 + ;; + + "-cpu-turbo") + set_cpu_turbo $2 + ;; + + "-cpu-online") + set_cpu_state $2 + ;; + + "-gpu-min-freq") + set_gpu_min_freq $2 + ;; + + "-gpu-max-freq") + set_gpu_max_freq $2 + ;; + + "-gpu-boost-freq") + set_gpu_boost_freq $2 + ;; + + "-cpu-governor") + set_cpu_governor $2 + ;; + + "-energy-perf") + set_energy_perf $2 + ;; + + "-thermal-mode") + set_thermal_mode $2 + ;; + + "-lg-battery-charge-limit") + set_lg_battery_charge_limit $2 + ;; + + "-lg-fan-mode") + set_lg_fan_mode $2 + ;; + + "-lg-usb-charge") + set_lg_usb_charge $2 + ;; + + "-powermizer") + set_powermizer $2 + ;; + + "-cooler-boost") + set_cooler_boost $2 + ;; + + "-read-all") + read_all + ;; + + *) + echo "Usage:" + echo "1: set_prefs.sh [ -cpu-min-perf |" + echo " -cpu-max-perf |" + echo " -cpu-turbo |" + echo " -cpu-online |" + echo " -gpu-min-freq |" + echo " -gpu-max-freq |" + echo " -gpu-boost-freq |" + echo " -cpu-governor |" + echo " -energy-perf |" + echo " -thermal-mode |" + echo " -lg-battery-charge-limit |" + echo " -lg-fan-mode |" + echo " -lg-usb-charge |" + echo " -powermizer |" + echo " -cooler-boost ] value" + echo "2: set_prefs.sh -read-all" + exit 3 + ;; +esac diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/code/utils.js b/org.thefreecircle.mibofra.plasma.pstate/contents/code/utils.js similarity index 91% rename from gr.ictpro.jsalatas.plasma.pstate/contents/code/utils.js rename to org.thefreecircle.mibofra.plasma.pstate/contents/code/utils.js index f212c38..1f73396 100644 --- a/gr.ictpro.jsalatas.plasma.pstate/contents/code/utils.js +++ b/org.thefreecircle.mibofra.plasma.pstate/contents/code/utils.js @@ -60,6 +60,7 @@ var sensors = { 'cpu_cur_load': {'value': undefined, 'unit':'%', 'print': to_int}, 'cpu_cur_freq': {'value': undefined, 'unit':' MHz', 'print': to_int}, 'gpu_cur_freq': {'value': undefined, 'unit':' MHz', 'print': to_int}, + 'cpu_total_available': {'value': undefined, 'unit':'', 'print': to_int}, 'gpu_min_limit': {'value': undefined, 'unit':'', 'print': to_int}, 'gpu_max_limit': {'value': undefined, 'unit':'', 'print': to_int}, 'battery_percentage': {'value': undefined, 'unit': '%', 'print': to_int}, @@ -70,6 +71,7 @@ var sensors = { 'cpu_min_perf': {'value': undefined, 'unit':'%', 'print': to_int}, 'cpu_max_perf': {'value': undefined, 'unit':'%', 'print': to_int}, 'cpu_turbo': {'value': undefined, 'unit':'', 'print': to_bool}, + 'cpu_online': {'value': undefined, 'unit':'', 'print': to_int}, 'gpu_min_freq': {'value': undefined, 'unit':' MHz', 'print': to_int}, 'gpu_max_freq': {'value': undefined, 'unit':' MHz', 'print': to_int}, 'gpu_boost_freq': {'value': undefined, 'unit':' MHz', 'print': to_int}, @@ -79,14 +81,16 @@ var sensors = { 'lg_battery_charge_limit': {'value': undefined, 'unit':'', 'print': to_bool}, 'lg_usb_charge': {'value': undefined, 'unit':'', 'print': to_bool}, 'lg_fan_mode': {'value': undefined, 'unit':'', 'print': to_bool}, - 'powermizer': {'value': undefined, 'unit':'', 'print': to_string}, + 'powermizer': {'value': undefined, 'unit':'', 'print': to_string}, + 'cooler_boost': {'value': undefined, 'unit':'', 'print': to_bool}, } var vendors = { 'dell': {'provides': ['thermal_mode']}, 'lg-laptop': {'provides': ['lg_battery_charge_limit', 'lg_usb_charge', 'lg_fan_mode']}, - 'nvidia': {'provides': ['powermizer']} + 'nvidia': {'provides': ['powermizer']}, + 'msi': {'provides': ['cooler_boost']} } var model = [ @@ -98,6 +102,9 @@ var model = [ {'type': 'slider', 'text': 'Max perf', 'min': 0, 'max': 100, 'sensor': 'cpu_max_perf'}, {'type': 'switch', 'text': 'Turbo', 'sensor': 'cpu_turbo'} ]}, + {'type': 'group', 'text': 'Online CPUs', 'items' :[ + {'type': 'slider', 'text': 'CPUs', 'min': 0, 'max': 'cpu_total_available', 'sensor': 'cpu_online'}, + ]}, {'type': 'group', 'text': 'GPU Frequencies', 'visible': 'showIntelGPU', 'items' :[ {'type': 'slider', 'text': 'Min freq', 'min': 'gpu_min_limit', 'max': 'gpu_max_limit', 'sensor': 'gpu_min_freq'}, {'type': 'slider', 'text': 'Max freq', 'min': 'gpu_min_limit', 'max': 'gpu_max_limit', 'sensor': 'gpu_max_freq'}, @@ -157,6 +164,12 @@ var model = [ {'text': 'Auto', 'sensor_value': '2'} ]} ] + }, + {'type': 'header', 'text': 'MSI Settings', 'icon': 'b', + 'vendors': ['msi'], + 'items': [ + {'type': 'switch', 'text': 'Cooler Boost', 'sensor': 'cooler_boost'} + ] } ] diff --git a/org.thefreecircle.mibofra.plasma.pstate/contents/code/utils.js~ b/org.thefreecircle.mibofra.plasma.pstate/contents/code/utils.js~ new file mode 100644 index 0000000..af42cfe --- /dev/null +++ b/org.thefreecircle.mibofra.plasma.pstate/contents/code/utils.js~ @@ -0,0 +1,185 @@ +/* + * Copyright 2018 John Salatas + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2 or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +function to_int(item) { + var val = Math.round(parseFloat(item['value']), 0); + return 0 == val || val ? val + item['unit'] : ''; +} + +function array_to_int(items) { + var res = ''; + var keys = Object.keys(items['value']) + for (var i=0; i< keys.length; i++) { + var item = items['value'][keys[i]] + var val = Math.round(parseFloat(item), 0); + if(0 == val || val) { + if(res) { + res += ' | ' + } + res += val + items['unit']; + } + }; + return res; +} + +function to_time(item) { + var val = Math.round(parseFloat(item['value']), 0); + var hours = Math.floor(val / 3600); + var minutes = Math.floor((val - (hours * 3600)) / 60); + + if (minutes < 10) {minutes = "0"+minutes;} + return hours ? hours+':'+minutes : ''; +} + +function to_bool(item) { + return parseInt(item['value'], 10) == 1; +} + +function to_string(item) { + return item['value']; +} + +var sensors = { + // Informational + 'cpu_cur_load': {'value': undefined, 'unit':'%', 'print': to_int}, + 'cpu_cur_freq': {'value': undefined, 'unit':' MHz', 'print': to_int}, + 'gpu_cur_freq': {'value': undefined, 'unit':' MHz', 'print': to_int}, + 'cpu_total_available': {'value': undefined, 'unit':'', 'print': to_int}, + 'gpu_min_limit': {'value': undefined, 'unit':'', 'print': to_int}, + 'gpu_max_limit': {'value': undefined, 'unit':'', 'print': to_int}, + 'battery_percentage': {'value': undefined, 'unit': '%', 'print': to_int}, + 'battery_remaining_time': {'value': undefined, 'print': to_time}, + 'package_temp': {'value': undefined, 'unit': ' \u2103', 'print': to_int}, + 'fan_speeds': {'value': {}, 'unit': ' RPM', 'print': array_to_int}, + // Tunable + 'cpu_min_perf': {'value': undefined, 'unit':'%', 'print': to_int}, + 'cpu_max_perf': {'value': undefined, 'unit':'%', 'print': to_int}, + 'cpu_turbo': {'value': undefined, 'unit':'', 'print': to_bool}, + 'cpu_online': {'value': undefined, 'unit':'', 'print': to_int}, + 'gpu_min_freq': {'value': undefined, 'unit':' MHz', 'print': to_int}, + 'gpu_max_freq': {'value': undefined, 'unit':' MHz', 'print': to_int}, + 'gpu_boost_freq': {'value': undefined, 'unit':' MHz', 'print': to_int}, + 'cpu_governor': {'value': undefined, 'unit':'', 'print': to_string}, + 'energy_perf': {'value': undefined, 'unit':'', 'print': to_string}, + 'thermal_mode': {'value': undefined, 'unit':'', 'print': to_string}, + 'lg_battery_charge_limit': {'value': undefined, 'unit':'', 'print': to_bool}, + 'lg_usb_charge': {'value': undefined, 'unit':'', 'print': to_bool}, + 'lg_fan_mode': {'value': undefined, 'unit':'', 'print': to_bool}, + 'powermizer': {'value': undefined, 'unit':'', 'print': to_string}, + 'cooler_boost': {'value': undefined, 'unit':'', 'print': to_bool}, + +} + +var vendors = { + 'dell': {'provides': ['thermal_mode']}, + 'lg-laptop': {'provides': ['lg_battery_charge_limit', 'lg_usb_charge', 'lg_fan_mode']}, + 'nvidia': {'provides': ['powermizer']}, + 'msi': {'provides': ['cooler_boost']} +} + +var model = [ + {'type': 'header', 'text': 'Processor Settings', 'icon': 'd', + 'sensors': ['cpu_cur_load', 'cpu_cur_freq', 'gpu_cur_freq'], + 'items': [ + {'type': 'group', 'text': 'CPU Frequencies', 'items' :[ + {'type': 'slider', 'text': 'Min perf', 'min': 0, 'max': 100, 'sensor': 'cpu_min_perf'}, + {'type': 'slider', 'text': 'Max perf', 'min': 0, 'max': 100, 'sensor': 'cpu_max_perf'}, + {'type': 'switch', 'text': 'Turbo', 'sensor': 'cpu_turbo'} + ]}, + {'type': 'group', 'text': 'Online CPUs', 'items' :[ + {'type': 'slider', 'text': 'CPUs', 'min': 0, 'max': 'cpu_total_available', 'sensor': 'cpu_online'}, + ]}, + {'type': 'group', 'text': 'GPU Frequencies', 'visible': 'showIntelGPU', 'items' :[ + {'type': 'slider', 'text': 'Min freq', 'min': 'gpu_min_limit', 'max': 'gpu_max_limit', 'sensor': 'gpu_min_freq'}, + {'type': 'slider', 'text': 'Max freq', 'min': 'gpu_min_limit', 'max': 'gpu_max_limit', 'sensor': 'gpu_max_freq'}, + {'type': 'slider', 'text': 'Boost freq', 'min': 'gpu_min_limit', 'max': 'gpu_max_limit', 'sensor': 'gpu_boost_freq'}, + ]}, + {'type': 'radio', 'text': 'CPU Governor', 'sensor': 'cpu_governor', 'items' :[ + {'symbol': 'a', 'text': 'Performance', 'sensor_value': 'performance'}, + {'symbol': 'f', 'text': 'Powersave', 'sensor_value': 'powersave'} + ]} + ] + }, + {'type': 'header', 'text': 'Energy Performance', 'icon': 'h', + 'sensors': ['battery_percentage', 'battery_remaining_time'], + 'items': [ + {'type': 'radio', 'text': '', 'sensor': 'energy_perf', 'items' :[ + {'symbol': 'i', 'text': 'Default', 'sensor_value': 'default'}, + {'symbol': 'a', 'text': 'Performance', 'sensor_value': 'performance'}, + {'symbol': 'k', 'text': 'Balance Performance', 'sensor_value': 'balance_performance'}, + {'symbol': 'l', 'text': 'Balance Power', 'sensor_value': 'balance_power'}, + {'symbol': 'f', 'text': 'Power', 'sensor_value': 'power'} + ]} + ] + }, + {'type': 'header', 'text': 'Thermal Management', 'icon': 'b', + 'vendors': ['dell'], + 'sensors': ['package_temp', 'fan_speeds'], + 'items': [ + {'type': 'radio', 'text': '', 'sensor': 'thermal_mode', 'items' :[ + {'symbol': 'e', 'text': 'Performance', 'sensor_value': 'performance'}, + {'symbol': 'j', 'text': 'Balanced', 'sensor_value': 'balanced'}, + {'symbol': 'g', 'text': 'Cool Bottom', 'sensor_value': 'cool-bottom'}, + {'symbol': 'c', 'text': 'Quiet', 'sensor_value': 'quiet'} + ]} + ] + }, + {'type': 'header', 'text': 'Power Supply Management', 'icon': 'm', + 'vendors': ['lg-laptop'], + 'items': [ + {'type': 'switch', 'text': 'Battery Limit', 'sensor': 'lg_battery_charge_limit'}, + {'type': 'switch', 'text': 'USB Charge', 'sensor': 'lg_usb_charge'} + ] + }, + {'type': 'header', 'text': 'Fan Control', 'icon': 'n', + 'vendors': ['lg-laptop'], + 'items': [ + {'type': 'switch', 'text': 'Silent Mode', 'sensor': 'lg_fan_mode'} + ] + }, + {'type': 'header', 'text': 'Nvidia Settings', 'icon': 'o', + 'vendors': ['nvidia'], + 'items': [ + {'type': 'combobox', 'text': 'PowerMizer', 'sensor': 'powermizer', 'items' :[ + {'text': 'Adaptive', 'sensor_value': '0'}, + {'text': 'Prefer Max Performance', 'sensor_value': '1'}, + {'text': 'Auto', 'sensor_value': '2'} + ]} + ] + }, + {'type': 'header', 'text': 'MSI Settings', 'icon': 'b', + 'vendors': ['msi'], + 'items': [ + {'type': 'switch', 'text': 'Cooler Boost', 'sensor': 'cooler_boost'} + ] + } +] + +function get_model() { + return model; +} + +function get_sensors() { + return sensors; +} + +function get_vendors() { + return vendors; +} + diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/config/config.qml b/org.thefreecircle.mibofra.plasma.pstate/contents/config/config.qml similarity index 100% rename from gr.ictpro.jsalatas.plasma.pstate/contents/config/config.qml rename to org.thefreecircle.mibofra.plasma.pstate/contents/config/config.qml diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/config/main.xml b/org.thefreecircle.mibofra.plasma.pstate/contents/config/main.xml similarity index 85% rename from gr.ictpro.jsalatas.plasma.pstate/contents/config/main.xml rename to org.thefreecircle.mibofra.plasma.pstate/contents/config/main.xml index 401291c..92de849 100644 --- a/gr.ictpro.jsalatas.plasma.pstate/contents/config/main.xml +++ b/org.thefreecircle.mibofra.plasma.pstate/contents/config/main.xml @@ -15,8 +15,5 @@ true - - true - diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/font/plasma-pstate.ttf b/org.thefreecircle.mibofra.plasma.pstate/contents/font/plasma-pstate.ttf similarity index 100% rename from gr.ictpro.jsalatas.plasma.pstate/contents/font/plasma-pstate.ttf rename to org.thefreecircle.mibofra.plasma.pstate/contents/font/plasma-pstate.ttf diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/ComboBox.qml b/org.thefreecircle.mibofra.plasma.pstate/contents/ui/ComboBox.qml similarity index 98% rename from gr.ictpro.jsalatas.plasma.pstate/contents/ui/ComboBox.qml rename to org.thefreecircle.mibofra.plasma.pstate/contents/ui/ComboBox.qml index b37e1a2..4581aaa 100644 --- a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/ComboBox.qml +++ b/org.thefreecircle.mibofra.plasma.pstate/contents/ui/ComboBox.qml @@ -81,6 +81,6 @@ RowLayout { } } - Layout.minimumWidth: parent.width + Layout.minimumWidth: units.gridUnit * 4 } } diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/CompactRepresentation.qml b/org.thefreecircle.mibofra.plasma.pstate/contents/ui/CompactRepresentation.qml similarity index 100% rename from gr.ictpro.jsalatas.plasma.pstate/contents/ui/CompactRepresentation.qml rename to org.thefreecircle.mibofra.plasma.pstate/contents/ui/CompactRepresentation.qml diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/FullRepresentation.qml b/org.thefreecircle.mibofra.plasma.pstate/contents/ui/FullRepresentation.qml similarity index 94% rename from gr.ictpro.jsalatas.plasma.pstate/contents/ui/FullRepresentation.qml rename to org.thefreecircle.mibofra.plasma.pstate/contents/ui/FullRepresentation.qml index 1dfb139..36ebcbf 100644 --- a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/FullRepresentation.qml +++ b/org.thefreecircle.mibofra.plasma.pstate/contents/ui/FullRepresentation.qml @@ -62,15 +62,6 @@ Column { } } - Connections { - target: plasmoid.configuration - onUseSudoForReadingChanged: { - if(isReady) { - initialize() - } - } - } - function is_present(item_vendors) { if(item_vendors && item_vendors.length != 0) { for(var j=0; j< item_vendors.length; j++) { diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/Group.qml b/org.thefreecircle.mibofra.plasma.pstate/contents/ui/Group.qml similarity index 100% rename from gr.ictpro.jsalatas.plasma.pstate/contents/ui/Group.qml rename to org.thefreecircle.mibofra.plasma.pstate/contents/ui/Group.qml diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/Header.qml b/org.thefreecircle.mibofra.plasma.pstate/contents/ui/Header.qml similarity index 100% rename from gr.ictpro.jsalatas.plasma.pstate/contents/ui/Header.qml rename to org.thefreecircle.mibofra.plasma.pstate/contents/ui/Header.qml diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/PushButton.qml b/org.thefreecircle.mibofra.plasma.pstate/contents/ui/PushButton.qml similarity index 100% rename from gr.ictpro.jsalatas.plasma.pstate/contents/ui/PushButton.qml rename to org.thefreecircle.mibofra.plasma.pstate/contents/ui/PushButton.qml diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/Radio.qml b/org.thefreecircle.mibofra.plasma.pstate/contents/ui/Radio.qml similarity index 100% rename from gr.ictpro.jsalatas.plasma.pstate/contents/ui/Radio.qml rename to org.thefreecircle.mibofra.plasma.pstate/contents/ui/Radio.qml diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/Slider.qml b/org.thefreecircle.mibofra.plasma.pstate/contents/ui/Slider.qml similarity index 100% rename from gr.ictpro.jsalatas.plasma.pstate/contents/ui/Slider.qml rename to org.thefreecircle.mibofra.plasma.pstate/contents/ui/Slider.qml diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/Switch.qml b/org.thefreecircle.mibofra.plasma.pstate/contents/ui/Switch.qml similarity index 100% rename from gr.ictpro.jsalatas.plasma.pstate/contents/ui/Switch.qml rename to org.thefreecircle.mibofra.plasma.pstate/contents/ui/Switch.qml diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/config/ConfigGeneral.qml b/org.thefreecircle.mibofra.plasma.pstate/contents/ui/config/ConfigGeneral.qml similarity index 81% rename from gr.ictpro.jsalatas.plasma.pstate/contents/ui/config/ConfigGeneral.qml rename to org.thefreecircle.mibofra.plasma.pstate/contents/ui/config/ConfigGeneral.qml index 849adf4..e5e1041 100644 --- a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/config/ConfigGeneral.qml +++ b/org.thefreecircle.mibofra.plasma.pstate/contents/ui/config/ConfigGeneral.qml @@ -6,7 +6,6 @@ Item { property alias cfg_useDefaultIcon: useDefaultIconCheckbox.checked property alias cfg_showIntelGPU: showIntelGPUCheckbox.checked property string cfg_customIcon: plasmoid.configuration.customIcon - property alias cfg_useSudoForReading: useSudoForReadingCheckbox.checked GridLayout { Layout.fillWidth: true @@ -37,11 +36,5 @@ Item { text: i18n('Show Intel GPU') Layout.columnSpan: 2 } - - CheckBox { - id: useSudoForReadingCheckbox - text: i18n('Use sudo for reading values') - Layout.columnSpan: 2 - } } } diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/config/IconPicker.qml b/org.thefreecircle.mibofra.plasma.pstate/contents/ui/config/IconPicker.qml similarity index 100% rename from gr.ictpro.jsalatas.plasma.pstate/contents/ui/config/IconPicker.qml rename to org.thefreecircle.mibofra.plasma.pstate/contents/ui/config/IconPicker.qml diff --git a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/main.qml b/org.thefreecircle.mibofra.plasma.pstate/contents/ui/main.qml similarity index 93% rename from gr.ictpro.jsalatas.plasma.pstate/contents/ui/main.qml rename to org.thefreecircle.mibofra.plasma.pstate/contents/ui/main.qml index 9573490..617ed3d 100644 --- a/gr.ictpro.jsalatas.plasma.pstate/contents/ui/main.qml +++ b/org.thefreecircle.mibofra.plasma.pstate/contents/ui/main.qml @@ -43,7 +43,7 @@ Item { property var sensors_model: Utils.get_sensors() property alias isReady: monitorDS.isReady property bool inTray: (plasmoid.parent === null || plasmoid.parent.objectName === 'taskItemContainer') - property var readCommand: (plasmoid.configuration.useSudoForReading ? 'sudo ' : '') + '/usr/share/plasma/plasmoids/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh -read-all' + property var readCommand: '/usr/share/plasma/plasmoids/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh -read-all' function sensor_short_name(long_name) { var parts = long_name.split('/'); @@ -189,16 +189,6 @@ Item { interval: 2000 } - Connections { - target: plasmoid.configuration - onUseSudoForReadingChanged: { - monitorDS.commandSource = readCommand - monitorDS.connectedSources = []; - monitorDS.connectedSources.length = 0; - monitorDS.connectedSources.push(monitorDS.commandSource); - } - } - PlasmaCore.DataSource { id: monitorDS engine: 'executable' @@ -235,7 +225,7 @@ Item { id: updater engine: 'executable' - property string commandSource: 'sudo /usr/share/plasma/plasmoids/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh -' + property string commandSource: '/usr/bin/pkexec /usr/share/plasma/plasmoids/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh -' onNewData: { updater.connectedSources = [] diff --git a/gr.ictpro.jsalatas.plasma.pstate/metadata.desktop b/org.thefreecircle.mibofra.plasma.pstate/metadata.desktop similarity index 63% rename from gr.ictpro.jsalatas.plasma.pstate/metadata.desktop rename to org.thefreecircle.mibofra.plasma.pstate/metadata.desktop index c62923b..e89eb9a 100644 --- a/gr.ictpro.jsalatas.plasma.pstate/metadata.desktop +++ b/org.thefreecircle.mibofra.plasma.pstate/metadata.desktop @@ -4,13 +4,13 @@ Name=Intel P-state and CPUFreq Manager Icon=cpu Type=Service X-KDE-ParentApp= -X-KDE-PluginInfo-Author=John Salatas +X-KDE-PluginInfo-Author=Francesco Bonanno X-KDE-PluginInfo-Category=System Information -X-KDE-PluginInfo-Email=jsalatas@ictpro.gr +X-KDE-PluginInfo-Email=mibofra@thefreecircle.org X-KDE-PluginInfo-License=GPL2+ -X-KDE-PluginInfo-Name=gr.ictpro.jsalatas.plasma.pstate +X-KDE-PluginInfo-Name=org.thefreecircle.mibofra.plasma.pstate X-KDE-PluginInfo-Version=1.0.6 -X-KDE-PluginInfo-Website=https://jsalatas.ictpro.gr +X-KDE-PluginInfo-Website=https://github.com/mibofra/plasma-pstate X-KDE-ServiceTypes=Plasma/Applet X-Plasma-API=declarativeappletscript X-Plasma-MainScript=ui/main.qml diff --git a/uninstall.sh b/uninstall.sh index 2ca56b4..2156f3a 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -5,10 +5,10 @@ if [[ $EUID -ne 0 ]]; then exit 1 fi -SUDOERS_FILE="/etc/sudoers.d/99-plasma-pstate" +kpackagetool5 -g -t Plasma/Applet -r org.thefreecircle.mibofra.plasma.pstate -rm -f ${SUDOERS_FILE} -kpackagetool5 -g -t Plasma/Applet -r gr.ictpro.jsalatas.plasma.pstate +rm /usr/share/polkit-1/actions/org.thefreecircle.mibofra.plasma.pstate.get-thermal.policy +rm /usr/share/polkit-1/actions/org.thefreecircle.mibofra.plasma.pstate.set-prefs.policy echo "Uninstall complete." exit 0 From d9219f3215aa557a6fbb8c6cc17d81927d5d7071 Mon Sep 17 00:00:00 2001 From: Mario Medina Date: Tue, 11 May 2021 01:44:12 -0500 Subject: [PATCH 10/10] Remove backup files --- .../contents/code/set_prefs.sh~ | 461 ------------------ .../contents/code/utils.js~ | 185 ------- 2 files changed, 646 deletions(-) delete mode 100755 org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh~ delete mode 100644 org.thefreecircle.mibofra.plasma.pstate/contents/code/utils.js~ diff --git a/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh~ b/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh~ deleted file mode 100755 index 318799a..0000000 --- a/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh~ +++ /dev/null @@ -1,461 +0,0 @@ -#!/usr/bin/env bash - -ACPI_CPU=/sys/devices/system/cpu - -if [ -d /sys/devices/system/cpu/cpufreq ]; then - INTEL_PSTATE=$ACPI_CPU/cpufreq - CPU_MIN_PERF=$INTEL_PSTATE/policy0/scaling_min_freq - CPU_MAX_PERF=$INTEL_PSTATE/policy0/scaling_max_freq - CPU_MIN_PERF_SET=$INTEL_PSTATE/policy*/scaling_min_freq - CPU_MAX_PERF_SET=$INTEL_PSTATE/policy*/scaling_max_freq - CPU_MIN_FREQ=$INTEL_PSTATE/policy0/cpuinfo_min_freq - CPU_MAX_FREQ=$INTEL_PSTATE/policy0/cpuinfo_max_freq - CPU_TURBO=$INTEL_PSTATE/boost - AMD=1 -else - INTEL_PSTATE=$ACPI_CPU/intel_pstate - CPU_MIN_PERF=$INTEL_PSTATE/min_perf_pct - CPU_MAX_PERF=$INTEL_PSTATE/max_perf_pct - CPU_TURBO=$INTEL_PSTATE/no_turbo - AMD=0 -fi -CPU_TOTAL_AVAILABLE=$(nproc --all) -CPU_ONLINE=$(nproc) - -GPU=/sys/class/drm/card0 -GPU_MIN_FREQ=$GPU/gt_min_freq_mhz -GPU_MAX_FREQ=$GPU/gt_max_freq_mhz -GPU_MIN_LIMIT=$GPU/gt_RP1_freq_mhz -GPU_MAX_LIMIT=$GPU/gt_RP0_freq_mhz -GPU_BOOST_FREQ=$GPU/gt_boost_freq_mhz -GPU_CUR_FREQ=$GPU/gt_cur_freq_mhz - -LG_LAPTOP_DRIVER=/sys/devices/platform/lg-laptop -LG_FAN_MODE=$LG_LAPTOP_DRIVER/fan_mode -LG_BATTERY_CHARGE_LIMIT=$LG_LAPTOP_DRIVER/battery_care_limit -LG_USB_CHARGE=$LG_LAPTOP_DRIVER/usb_charge - -check_lg_drivers() { - if [ -d $LG_LAPTOP_DRIVER ]; then - return 0 - else - return 1 - fi -} - -check_dell_thermal () { - /usr/bin/pkexec /usr/share/plasma/plasmoids/org.thefreecircle.mibofra.plasma.pstate/contents/code/get_thermal.sh > /dev/null 2>&1 - OUT=$? - if [ $OUT -eq 0 ]; then - return 0 - else - return 1 - fi -} - -check_nvidia () { - nvidia-settings -q GpuPowerMizerMode > /dev/null 2>&1 - OUT=$? - if [ $OUT -eq 0 ]; then - return 0 - else - return 1 - fi -} - -check_isw () { - isw=`command -v isw` - if [ -z "${isw}" ]; then - return 1 - else - return 0 - fi -} - -set_cpu_min_perf () { - minperf=$1 - if [ -n "$minperf" ] && [ "$minperf" != "0" -a "$AMD" == "0" -o "$AMD" == "1" ]; then - if [ "$AMD" == "0" ]; then - printf '%s\n' "$minperf" > $CPU_MIN_PERF; 2> /dev/null - else - minfreq=$(cat $CPU_MIN_FREQ) - maxfreq=$(cat $CPU_MAX_FREQ) - freq=$((($maxfreq-$minfreq)*$minperf/100 + $minfreq)) - for d in $CPU_MIN_PERF_SET; do - printf '%s\n' "$freq" > $d; 2> /dev/null - done - fi - fi -} - -set_cpu_max_perf () { - maxperf=$1 - if [ -n "$maxperf" ] && [ "$maxperf" != "0" ]; then - if [ "$AMD" == "0" ]; then - printf '%s\n' "$maxperf" > $CPU_MAX_PERF; 2> /dev/null - else - minfreq=$(cat $CPU_MIN_FREQ) - maxfreq=$(cat $CPU_MAX_FREQ) - freq=$((($maxfreq-$minfreq)*$maxperf/100 + $minfreq)) - for d in $CPU_MAX_PERF_SET; do - printf '%s\n' "$freq" > $d; 2> /dev/null - done - fi - fi -} - -set_cpu_turbo () { - turbo=$1 - if [ -n "$turbo" ]; then - if [ "$turbo" == "true" ]; then - if [ "$AMD" == "0" ]; then - printf '0\n' > $CPU_TURBO; 2> /dev/null - else - printf '1\n' > $CPU_TURBO; 2> /dev/null - fi - else - if [ "$AMD" == "0" ]; then - printf '1\n' > $CPU_TURBO; 2> /dev/null - else - printf '0\n' > $CPU_TURBO; 2> /dev/null - fi - fi - fi -} - -set_cpu_state () { - num=$1 - num_off=$[$CPU_TOTAL_AVAILABLE-$num] - counter=1 - limit=$[$num-1] - all_off=$[$CPU_TOTAL_AVAILABLE-1] - if [ -n "$num" ] && [ "$num" != "0" ]; then - if [ "$num" -ne "1" ]; then - while [ "$counter" -le "$limit" ]; do - printf '1\n' > $ACPI_CPU/cpu$counter/online; 2> /dev/null - counter=$[$counter+1] - done - limit=$[$limit+$num_off] - while [ "$counter" -le "$limit" ]; do - printf '0\n' > $ACPI_CPU/cpu$counter/online; 2> /dev/null - counter=$[$counter+1] - done - else - while [ "$counter" -le "$all_off" ]; do - printf '0\n' > $ACPI_CPU/cpu$counter/online; 2> /dev/null - counter=$[$counter+1] - done - fi - fi -} - -set_gpu_min_freq () { - gpuminfreq=$1 - if [ -n "$gpuminfreq" ] && [ "$gpuminfreq" != "0" ]; then - printf '%s\n' "$gpuminfreq" > $GPU_MIN_FREQ; 2> /dev/null - fi -} - -set_gpu_max_freq () { - gpumaxfreq=$1 - if [ -n "$gpumaxfreq" ] && [ "$gpumaxfreq" != "0" ]; then - printf '%s\n' "$gpumaxfreq" > $GPU_MAX_FREQ; 2> /dev/null - fi -} - -set_gpu_boost_freq () { - gpuboostfreq=$1 - if [ -n "$gpuboostfreq" ] && [ "$gpuboostfreq" != "0" ]; then - printf '%s\n' "$gpuboostfreq" > $GPU_BOOST_FREQ; 2> /dev/null - fi -} - -set_cpu_governor () { - gov=$1 - if [ -n "$gov" ]; then - for cpu in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do - printf '%s\n' "$gov" > $cpu; 2> /dev/null - done - fi -} - -set_energy_perf () { - energyperf=$1 - if [ -n "$energyperf" ]; then - if [ -f /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference ]; then - for cpu in /sys/devices/system/cpu/cpu*/cpufreq/energy_performance_preference; do - printf '%s\n' "$energyperf" > $cpu; 2> /dev/null - done - else - pnum=$(echo $energyperf | sed -r 's/^performance$/0/; - s/^balance_performance$/4/; - s/^(default|normal)$/6/; - s/^balance_power?$/8/; - s/^power(save)?$/15/') - - x86_energy_perf_policy $pnum > /dev/null 2>&1 - fi - fi -} - -set_thermal_mode () { - smbios-thermal-ctl --set-thermal-mode=$1 2> /dev/null -} - -set_lg_battery_charge_limit(){ - enabled=$1 - if [ -n "$enabled" ]; then - if [ "$enabled" == "true" ]; then - printf '80\n' > $LG_BATTERY_CHARGE_LIMIT; 2> /dev/null - else - printf '100\n' > $LG_BATTERY_CHARGE_LIMIT; 2> /dev/null - fi - fi -} - -set_lg_fan_mode() { - enabled=$1 - if [ -n "$enabled" ]; then - if [ "$enabled" == "true" ]; then - printf '0' > $LG_FAN_MODE; 2> /dev/null - else - printf '1' > $LG_FAN_MODE; 2> /dev/null - fi - fi -} - -set_powermizer () { - nvidia-settings -a "[gpu:0]/GpuPowerMizerMode=$1" 2> /dev/null -} - -set_lg_usb_charge() { - enabled=$1 - if [ -n "$enabled" ]; then - if [ "$enabled" == "true" ]; then - printf '1\n' > $LG_USB_CHARGE; 2> /dev/null - else - printf '0\n' > $LG_USB_CHARGE; 2> /dev/null - fi - fi -} - -set_cooler_boost () { - boost=$1 - if [ -n "$boost" ]; then - if [ "$boost" == "true" ]; then - printf '1\n' > /run/isw_cooler_boost; 2> /dev/null - isw -b on; 2> /dev/null - else - printf '0\n' > /run/isw_cooler_boost; 2> /dev/null - isw -b off; 2> /dev/null - fi - fi -} - -read_all () { -if [ "$AMD" == "0" ]; then - cpu_min_perf=`cat $CPU_MIN_PERF` - cpu_max_perf=`cat $CPU_MAX_PERF` -else - cpu_min_freq=`cat $CPU_MIN_FREQ` - cpu_max_freq=`cat $CPU_MAX_FREQ` - max=$(cat $CPU_MAX_PERF) - min=$(cat $CPU_MIN_PERF) - cpu_max_perf=$(((100+($max-$cpu_max_freq)*100/$cpu_max_freq))) - cpu_min_perf=$((($min-$cpu_min_freq)*100/$cpu_min_freq)) -fi -cpu_turbo=`cat $CPU_TURBO` -if [ "$cpu_turbo" == "1" -a "$AMD" = "0" -o "$cpu_turbo" == "0" -a "$AMD" = "1" ]; then - cpu_turbo="false" -else - cpu_turbo="true" -fi -cpu_total_available=`echo $CPU_TOTAL_AVAILABLE` -cpu_online=`echo $CPU_ONLINE` -if [ "$cpu_turbo" == "1" ]; then - cpu_turbo="false" -else - cpu_turbo="true" -fi -if [ -f $GPU_MIN_FREQ ]; then - gpu_min_freq=`cat $GPU_MIN_FREQ` - gpu_max_freq=`cat $GPU_MAX_FREQ` - gpu_min_limit=`cat $GPU_MIN_LIMIT` - gpu_max_limit=`cat $GPU_MAX_LIMIT` - gpu_boost_freq=`cat $GPU_BOOST_FREQ` - gpu_cur_freq=`cat $GPU_CUR_FREQ` -fi -cpu_governor=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor` -energy_perf=`cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference` -if [ -z "$energy_perf" ]; then - energy_perf=`x86_energy_perf_policy -r 2>/dev/null | grep -v 'HWP_' | \ - sed -r 's/://; - s/(0x0000000000000000|EPB 0)/performance/; - s/(0x0000000000000004|EPB 4)/balance_performance/; - s/(0x0000000000000006|EPB 6)/default/; - s/(0x0000000000000008|EPB 8)/balance_power/; - s/(0x000000000000000f|EPB 15)/power/' | \ - awk '{ printf "%s\n", $2; }' | head -n 1` -fi -if check_dell_thermal; then - thermal_mode=`/usr/bin/pkexec /usr/share/plasma/plasmoids/org.thefreecircle.mibofra.plasma.pstate/contents/code/get_thermal.sh | grep -C 1 "Current Thermal Modes:" | tail -n 1 | awk '{$1=$1;print}' | sed "s/\t//g" | sed "s/ /-/g" | tr "[A-Z]" "[a-z]" ` -fi - -if check_lg_drivers; then - lg_battery_charge_limit=`cat $LG_BATTERY_CHARGE_LIMIT` - if [ "$lg_battery_charge_limit" == "80" ]; then - lg_battery_charge_limit="true" - else - lg_battery_charge_limit="false" - fi - lg_usb_charge=`cat $LG_USB_CHARGE` - if [ "$lg_usb_charge" == "1" ]; then - lg_usb_charge="true" - else - lg_usb_charge="false" - fi - lg_fan_mode=`cat $LG_FAN_MODE` - if [ "$lg_fan_mode" == "1" ]; then - lg_fan_mode="false" - else - lg_fan_mode="true" - fi -fi - -if check_nvidia; then - powermizer=`nvidia-settings -q GpuPowerMizerMode 2> /dev/null | grep "Attribute 'GPUPowerMizerMode'" | awk -F "): " '{print $2}' | awk -F "." '{print $1}' ` -fi - -if check_isw; then - if [[ ! -f /run/isw_cooler_boost ]]; then - cooler_boost="false" - else - cooler_boost=`cat /run/isw_cooler_boost` - if [ "$cooler_boost" == "1" ]; then - cooler_boost="true" - else - cooler_boost="false" - fi - fi -fi - -json="{" -json="${json}\"cpu_min_perf\":\"${cpu_min_perf}\"" -json="${json},\"cpu_max_perf\":\"${cpu_max_perf}\"" -json="${json},\"cpu_turbo\":\"${cpu_turbo}\"" -json="${json},\"cpu_total_available\":\"${cpu_total_available}\"" -json="${json},\"cpu_online\":\"${cpu_online}\"" -if [ -f $GPU_MIN_FREQ ]; then - json="${json},\"gpu_min_freq\":\"${gpu_min_freq}\"" - json="${json},\"gpu_max_freq\":\"${gpu_max_freq}\"" - json="${json},\"gpu_min_limit\":\"${gpu_min_limit}\"" - json="${json},\"gpu_max_limit\":\"${gpu_max_limit}\"" - json="${json},\"gpu_boost_freq\":\"${gpu_boost_freq}\"" - json="${json},\"gpu_cur_freq\":\"${gpu_cur_freq}\"" -fi -json="${json},\"cpu_governor\":\"${cpu_governor}\"" -json="${json},\"energy_perf\":\"${energy_perf}\"" -if check_dell_thermal; then - json="${json},\"thermal_mode\":\"${thermal_mode}\"" -fi -if check_lg_drivers; then - json="${json},\"lg_battery_charge_limit\":\"${lg_battery_charge_limit}\"" - json="${json},\"lg_usb_charge\":\"${lg_usb_charge}\"" - json="${json},\"lg_fan_mode\":\"${lg_fan_mode}\"" -fi -if check_nvidia; then - json="${json},\"powermizer\":\"${powermizer}\"" -fi -if check_isw; then - json="${json},\"cooler_boost\":\"${cooler_boost}\"" -fi -json="${json}}" -echo $json -} - -case $1 in - "-cpu-min-perf") - set_cpu_min_perf $2 - ;; - - "-cpu-max-perf") - set_cpu_max_perf $2 - ;; - - "-cpu-turbo") - set_cpu_turbo $2 - ;; - - "-cpu-online") - set_cpu_state $2 - ;; - - "-gpu-min-freq") - set_gpu_min_freq $2 - ;; - - "-gpu-max-freq") - set_gpu_max_freq $2 - ;; - - "-gpu-boost-freq") - set_gpu_boost_freq $2 - ;; - - "-cpu-governor") - set_cpu_governor $2 - ;; - - "-energy-perf") - set_energy_perf $2 - ;; - - "-thermal-mode") - set_thermal_mode $2 - ;; - - "-lg-battery-charge-limit") - set_lg_battery_charge_limit $2 - ;; - - "-lg-fan-mode") - set_lg_fan_mode $2 - ;; - - "-lg-usb-charge") - set_lg_usb_charge $2 - ;; - - "-powermizer") - set_powermizer $2 - ;; - - "-cooler-boost") - set_cooler_boost $2 - ;; - - "-read-all") - read_all - ;; - - *) - echo "Usage:" - echo "1: set_prefs.sh [ -cpu-min-perf |" - echo " -cpu-max-perf |" - echo " -cpu-turbo |" - echo " -cpu-online |" - echo " -gpu-min-freq |" - echo " -gpu-max-freq |" - echo " -gpu-boost-freq |" - echo " -cpu-governor |" - echo " -energy-perf |" - echo " -thermal-mode |" - echo " -lg-battery-charge-limit |" - echo " -lg-fan-mode |" - echo " -lg-usb-charge |" - echo " -powermizer |" - echo " -cooler-boost ] value" - echo "2: set_prefs.sh -read-all" - exit 3 - ;; -esac diff --git a/org.thefreecircle.mibofra.plasma.pstate/contents/code/utils.js~ b/org.thefreecircle.mibofra.plasma.pstate/contents/code/utils.js~ deleted file mode 100644 index af42cfe..0000000 --- a/org.thefreecircle.mibofra.plasma.pstate/contents/code/utils.js~ +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright 2018 John Salatas - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2 or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -function to_int(item) { - var val = Math.round(parseFloat(item['value']), 0); - return 0 == val || val ? val + item['unit'] : ''; -} - -function array_to_int(items) { - var res = ''; - var keys = Object.keys(items['value']) - for (var i=0; i< keys.length; i++) { - var item = items['value'][keys[i]] - var val = Math.round(parseFloat(item), 0); - if(0 == val || val) { - if(res) { - res += ' | ' - } - res += val + items['unit']; - } - }; - return res; -} - -function to_time(item) { - var val = Math.round(parseFloat(item['value']), 0); - var hours = Math.floor(val / 3600); - var minutes = Math.floor((val - (hours * 3600)) / 60); - - if (minutes < 10) {minutes = "0"+minutes;} - return hours ? hours+':'+minutes : ''; -} - -function to_bool(item) { - return parseInt(item['value'], 10) == 1; -} - -function to_string(item) { - return item['value']; -} - -var sensors = { - // Informational - 'cpu_cur_load': {'value': undefined, 'unit':'%', 'print': to_int}, - 'cpu_cur_freq': {'value': undefined, 'unit':' MHz', 'print': to_int}, - 'gpu_cur_freq': {'value': undefined, 'unit':' MHz', 'print': to_int}, - 'cpu_total_available': {'value': undefined, 'unit':'', 'print': to_int}, - 'gpu_min_limit': {'value': undefined, 'unit':'', 'print': to_int}, - 'gpu_max_limit': {'value': undefined, 'unit':'', 'print': to_int}, - 'battery_percentage': {'value': undefined, 'unit': '%', 'print': to_int}, - 'battery_remaining_time': {'value': undefined, 'print': to_time}, - 'package_temp': {'value': undefined, 'unit': ' \u2103', 'print': to_int}, - 'fan_speeds': {'value': {}, 'unit': ' RPM', 'print': array_to_int}, - // Tunable - 'cpu_min_perf': {'value': undefined, 'unit':'%', 'print': to_int}, - 'cpu_max_perf': {'value': undefined, 'unit':'%', 'print': to_int}, - 'cpu_turbo': {'value': undefined, 'unit':'', 'print': to_bool}, - 'cpu_online': {'value': undefined, 'unit':'', 'print': to_int}, - 'gpu_min_freq': {'value': undefined, 'unit':' MHz', 'print': to_int}, - 'gpu_max_freq': {'value': undefined, 'unit':' MHz', 'print': to_int}, - 'gpu_boost_freq': {'value': undefined, 'unit':' MHz', 'print': to_int}, - 'cpu_governor': {'value': undefined, 'unit':'', 'print': to_string}, - 'energy_perf': {'value': undefined, 'unit':'', 'print': to_string}, - 'thermal_mode': {'value': undefined, 'unit':'', 'print': to_string}, - 'lg_battery_charge_limit': {'value': undefined, 'unit':'', 'print': to_bool}, - 'lg_usb_charge': {'value': undefined, 'unit':'', 'print': to_bool}, - 'lg_fan_mode': {'value': undefined, 'unit':'', 'print': to_bool}, - 'powermizer': {'value': undefined, 'unit':'', 'print': to_string}, - 'cooler_boost': {'value': undefined, 'unit':'', 'print': to_bool}, - -} - -var vendors = { - 'dell': {'provides': ['thermal_mode']}, - 'lg-laptop': {'provides': ['lg_battery_charge_limit', 'lg_usb_charge', 'lg_fan_mode']}, - 'nvidia': {'provides': ['powermizer']}, - 'msi': {'provides': ['cooler_boost']} -} - -var model = [ - {'type': 'header', 'text': 'Processor Settings', 'icon': 'd', - 'sensors': ['cpu_cur_load', 'cpu_cur_freq', 'gpu_cur_freq'], - 'items': [ - {'type': 'group', 'text': 'CPU Frequencies', 'items' :[ - {'type': 'slider', 'text': 'Min perf', 'min': 0, 'max': 100, 'sensor': 'cpu_min_perf'}, - {'type': 'slider', 'text': 'Max perf', 'min': 0, 'max': 100, 'sensor': 'cpu_max_perf'}, - {'type': 'switch', 'text': 'Turbo', 'sensor': 'cpu_turbo'} - ]}, - {'type': 'group', 'text': 'Online CPUs', 'items' :[ - {'type': 'slider', 'text': 'CPUs', 'min': 0, 'max': 'cpu_total_available', 'sensor': 'cpu_online'}, - ]}, - {'type': 'group', 'text': 'GPU Frequencies', 'visible': 'showIntelGPU', 'items' :[ - {'type': 'slider', 'text': 'Min freq', 'min': 'gpu_min_limit', 'max': 'gpu_max_limit', 'sensor': 'gpu_min_freq'}, - {'type': 'slider', 'text': 'Max freq', 'min': 'gpu_min_limit', 'max': 'gpu_max_limit', 'sensor': 'gpu_max_freq'}, - {'type': 'slider', 'text': 'Boost freq', 'min': 'gpu_min_limit', 'max': 'gpu_max_limit', 'sensor': 'gpu_boost_freq'}, - ]}, - {'type': 'radio', 'text': 'CPU Governor', 'sensor': 'cpu_governor', 'items' :[ - {'symbol': 'a', 'text': 'Performance', 'sensor_value': 'performance'}, - {'symbol': 'f', 'text': 'Powersave', 'sensor_value': 'powersave'} - ]} - ] - }, - {'type': 'header', 'text': 'Energy Performance', 'icon': 'h', - 'sensors': ['battery_percentage', 'battery_remaining_time'], - 'items': [ - {'type': 'radio', 'text': '', 'sensor': 'energy_perf', 'items' :[ - {'symbol': 'i', 'text': 'Default', 'sensor_value': 'default'}, - {'symbol': 'a', 'text': 'Performance', 'sensor_value': 'performance'}, - {'symbol': 'k', 'text': 'Balance Performance', 'sensor_value': 'balance_performance'}, - {'symbol': 'l', 'text': 'Balance Power', 'sensor_value': 'balance_power'}, - {'symbol': 'f', 'text': 'Power', 'sensor_value': 'power'} - ]} - ] - }, - {'type': 'header', 'text': 'Thermal Management', 'icon': 'b', - 'vendors': ['dell'], - 'sensors': ['package_temp', 'fan_speeds'], - 'items': [ - {'type': 'radio', 'text': '', 'sensor': 'thermal_mode', 'items' :[ - {'symbol': 'e', 'text': 'Performance', 'sensor_value': 'performance'}, - {'symbol': 'j', 'text': 'Balanced', 'sensor_value': 'balanced'}, - {'symbol': 'g', 'text': 'Cool Bottom', 'sensor_value': 'cool-bottom'}, - {'symbol': 'c', 'text': 'Quiet', 'sensor_value': 'quiet'} - ]} - ] - }, - {'type': 'header', 'text': 'Power Supply Management', 'icon': 'm', - 'vendors': ['lg-laptop'], - 'items': [ - {'type': 'switch', 'text': 'Battery Limit', 'sensor': 'lg_battery_charge_limit'}, - {'type': 'switch', 'text': 'USB Charge', 'sensor': 'lg_usb_charge'} - ] - }, - {'type': 'header', 'text': 'Fan Control', 'icon': 'n', - 'vendors': ['lg-laptop'], - 'items': [ - {'type': 'switch', 'text': 'Silent Mode', 'sensor': 'lg_fan_mode'} - ] - }, - {'type': 'header', 'text': 'Nvidia Settings', 'icon': 'o', - 'vendors': ['nvidia'], - 'items': [ - {'type': 'combobox', 'text': 'PowerMizer', 'sensor': 'powermizer', 'items' :[ - {'text': 'Adaptive', 'sensor_value': '0'}, - {'text': 'Prefer Max Performance', 'sensor_value': '1'}, - {'text': 'Auto', 'sensor_value': '2'} - ]} - ] - }, - {'type': 'header', 'text': 'MSI Settings', 'icon': 'b', - 'vendors': ['msi'], - 'items': [ - {'type': 'switch', 'text': 'Cooler Boost', 'sensor': 'cooler_boost'} - ] - } -] - -function get_model() { - return model; -} - -function get_sensors() { - return sensors; -} - -function get_vendors() { - return vendors; -} -