29 lines
610 B
Bash
Executable File
29 lines
610 B
Bash
Executable File
#!/bin/bash
|
|
# Helper script for CPU Control Plasma Widget
|
|
# Sets intel_pstate max_perf_pct with input validation
|
|
# Called via pkexec from the widget
|
|
|
|
SYSFS="/sys/devices/system/cpu/intel_pstate/max_perf_pct"
|
|
|
|
if [ -z "$1" ]; then
|
|
echo "Usage: cpu-perf-set <10-100>" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if ! [[ "$1" =~ ^[0-9]+$ ]]; then
|
|
echo "Error: value must be a number" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ "$1" -lt 10 ] || [ "$1" -gt 100 ]; then
|
|
echo "Error: value must be between 10 and 100" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ ! -f "$SYSFS" ]; then
|
|
echo "Error: intel_pstate not available" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "$1" > "$SYSFS"
|