From 9fcb60b769b7ea50b340087b45e0bdec73984dd6 Mon Sep 17 00:00:00 2001 From: kake26 Date: Mon, 17 May 2021 01:06:15 +0200 Subject: [PATCH] initial copy from github inital move from github --- Install.md | 10 ++++++++++ README.md | 30 +++++++++++++++++++++++++++++- cpuwrangler.bash | 19 +++++++++++++++++++ cpuwrangler.service | 7 +++++++ 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 Install.md create mode 100644 cpuwrangler.bash create mode 100644 cpuwrangler.service diff --git a/Install.md b/Install.md new file mode 100644 index 0000000..5e0264f --- /dev/null +++ b/Install.md @@ -0,0 +1,10 @@ +# Install.md + +1. Create dir /opt/scripts +2. Drop cpuwrangler.bash in the new directory +3. Edit file and change $cpugov to what you want to use, default to conservative +4. CD to /etc/systemd/system/ +5. Drop in the cpuwrangler.service file +6. Run systemctl enable cpuwrangler.service + +Thats it! \ No newline at end of file diff --git a/README.md b/README.md index 24f86c3..90633cd 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,31 @@ # cpuwrangler -CPU Wrangler for the PinePhone. \ No newline at end of file + CPU Wrangler for the PinePhone. + + # What it does + + I recently got my PinePhone and noticed while there are many OSes out there, they seem to not pay attention to one thing. The CPU governor, leaving it on performance which is great for responsiveness, but eats battery. This script is a simple little tool to help adjust the governor. I've included a little bit of a description for each, but to get the full info you should look it up in the kernel docs. + + # Supported Governors + + # Performance + + This is likely the default and just keeps the CPU at max power all the time. Downside is it drains battery power and generates allot of heat. + + # Ondemand + + A CPU governor that adjusts the power according to CPU load. A better balance between responsiveness and battery saving. Downside is its quick to + jump to max power on the CPU. Still better then performance + + # Conservative + + Similar to the ondemand, but not as quick to ratchet up to max power on the CPU. This I think strikes a good balance between responsiveness and good + battery savings. Especially, if the phone is mostly idle. + + # Powersave + + Well, not much to say here except max power saving. + + # Notes + + The service code for presisting the changes across the startup require systemd. However, using it elsewhere should be trivial. diff --git a/cpuwrangler.bash b/cpuwrangler.bash new file mode 100644 index 0000000..767b2e8 --- /dev/null +++ b/cpuwrangler.bash @@ -0,0 +1,19 @@ +#!/bin/bash + +# Some variables + +$sysdu = "" # location to pull the systemd unit from github +$cur_gov = $(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor) +$cpugov = "conservative" # set what you want here + +# First, are running as root? + +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root" + exit 1 +fi + +# Default action is to reapply settings + +echo "$cpugov" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor + diff --git a/cpuwrangler.service b/cpuwrangler.service new file mode 100644 index 0000000..221b925 --- /dev/null +++ b/cpuwrangler.service @@ -0,0 +1,7 @@ +[Unit] +Description=CPU Wrangler presistent startup unit +[Service] +Type=oneshot +ExecStart=/opt/scripts/cpuwrangler.bash +[Install] +WantedBy=multi-user.target \ No newline at end of file