-
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Usage without admin password #3
Comments
After getting the extension to work (by reading paradoxxxzero/gnome-shell-system-monitor-applet@ffeb78f) and a few stackexchanges I found out, that sudo isn't the right way. The next thing to try is policies, which might require a separate script (a wrapper to previous listed commands) and a setup |
wrapper script to allow only actions, we want to support (maybe this is not necessary)
#!/usr/bin/env bash
if [ -z "$1" ] ; then
echo "Usage:"
echo " thermalmode get"
echo " thermalmode list"
echo " thermalmode <mode>"
exit 0
fi
if [ "$1" = "get" ] ; then
output=$(smbios-thermal-ctl -g)
# ...
# Current Thermal Modes:
# Quiet
# ...
# @todo: do some awk: the line after "Current Thermal Modes:", trim spaces, kebab-case
mode=$(echo "$output" | sed -n 7p)
echo "$mode"
exit 0
fi
#output=$(smbios-thermal-ctl -i)
# ...
# Supported Thermal Modes:
# Balanced
# Cool Bottom
# Quiet
# Performance
# ...
# @todo: do required awk
# @todo: convert to kebab-case
#supported_thermal_modes= $output -> awk -> kebab-case -> array
supported_thermal_modes=(balanced cool-bottom quiet performance)
if [ "$1" = "list" ] ; then
echo "Supported thermal modes:"
for mode in "${supported_thermal_modes[@]}"; do
echo " ${mode}"
done
exit 0
fi
# set_thermal_mode
mode="$1"
for i in "${supported_thermal_modes[@]}"
do
if [ "$i" = "$mode" ] ; then
smbios-thermal-ctl --set-thermal-mode $mode #1>> /dev/null
echo "set-thermal-mode ${mode}"
exit 0
fi
done
echo "unsupported parameter."
exit 1 I think this wrapper is needed because the sudoers file in the initial post is not really save. (Parameters could be combined to potentially do sth. else than we want) Now allow to execute: chmod +x /usr/local/bin/thermalmode
sudo visudo -f /etc/sudoers.d/thermalmode
## paste (without '#')
# %wheel ALL= NOPASSWD: /usr/local/bin/thermalmode After that I replaced ["pkexec"].concat(["smbios-thermal-ctl", "--set-thermal-mode", mode]), with ["thermalmode"].concat([mode]), in |
Assuming that your user is in the wheel group, maybe* this could work:
then paste
Adjustments for 'pkexec' may also be needed.
*I can't try because of
Error: Tried to construct an object without a GType
on gnome-shell 40.1The text was updated successfully, but these errors were encountered: