Skip to content
This repository was archived by the owner on Sep 22, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion 99-plasma-pstate

This file was deleted.

22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ through [libsmbios library](https://github.com/dell/libsmbios).

<a target="_blank" rel="noopener noreferrer" href="https://github.com/jsalatas/plasma-pstate/raw/master/screenshots/screenshot_4.png"><img src="https://github.com/jsalatas/plasma-pstate/raw/master/screenshots/screenshot_4.png" alt="Intel P-state and CPUFreq Manager Widget with Nvidia PowerMizer Settings" title="Intel P-state and CPUFreq Manager Widget with Nvidia PowerMizer Settings" width="500px"></a>

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
Expand Down Expand Up @@ -69,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
```


Expand All @@ -81,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).

21 changes: 5 additions & 16 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
smbios-thermal-ctl -g
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
<policyconfig>

<action id="org.thefreecircle.mibofra.plasma.pstate.get-thermal.pkexec.get_thermal.sh">
<message>Authentication is required to run Plasma P-state (Get thermal info)</message>
<defaults>
<allow_any>no</allow_any>
<allow_inactive>no</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/share/plasma/plasmoids/org.thefreecircle.mibofra.plasma.pstate/contents/code/get_thermal.sh</annotate>
</action>

</policyconfig>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
<policyconfig>

<action id="org.thefreecircle.mibofra.plasma.pstate.set-prefs.pkexec.set_prefs.sh">
<message>Authentication is required to run Plasma P-state</message>
<defaults>
<allow_any>no</allow_any>
<allow_inactive>no</allow_inactive>
<allow_active>auth_admin</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/share/plasma/plasmoids/org.thefreecircle.mibofra.plasma.pstate/contents/code/set_prefs.sh</annotate>
</action>

</policyconfig>
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -27,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
Expand All @@ -46,6 +49,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" ]; then
Expand All @@ -71,6 +83,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
Expand Down Expand Up @@ -139,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
}
Expand All @@ -161,21 +199,38 @@ 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`
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
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
Expand All @@ -189,7 +244,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
Expand All @@ -214,19 +269,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
Expand All @@ -240,6 +312,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
}
Expand All @@ -257,6 +332,10 @@ case $1 in
set_cpu_turbo $2
;;

"-cpu-online")
set_cpu_state $2
;;

"-gpu-min-freq")
set_gpu_min_freq $2
;;
Expand Down Expand Up @@ -297,6 +376,10 @@ case $1 in
set_powermizer $2
;;

"-cooler-boost")
set_cooler_boost $2
;;

"-read-all")
read_all
;;
Expand All @@ -306,6 +389,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 |"
Expand All @@ -315,7 +399,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
;;
Expand Down
Loading