Skip to content

Commit

Permalink
add installer
Browse files Browse the repository at this point in the history
  • Loading branch information
MiMillieuh authored Aug 20, 2023
1 parent 2d1fe60 commit ededdb5
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
22 changes: 22 additions & 0 deletions batterym/batter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

CURRENTPROFILE=$(powerprofilesctl get)

if [[ $CURRENTPROFILE == "performance" ]]
then
exit 0
fi

POWERSTATE=$(upower -i $(upower -e | grep BAT) | grep --color=never -E "state")

if [[ $POWERSTATE == " state: charging" || $POWERSTATE == " state: fully-charged" ]]
then

powerprofilesctl set balanced
sudo cpupower frequency-set -g ondemand

else

powerprofilesctl set power-saver
cpupower frequency-set -g powersave
fi
8 changes: 8 additions & 0 deletions batterym/batterservice.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

sh /opt/batterym/batter.sh


sleep 300

sh /opt/batterym/batterservice.sh
14 changes: 14 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

if [[ "$USER" != "root" ]]; then
echo "Error: script not running as root or with sudo! Exiting..."
exit 1
fi

cp systemd/batterym.service /etc/systemd/system/

cp -r batterym /opt

systemctl enable --now batterym.service

echo "batterym install done"
9 changes: 9 additions & 0 deletions systemd/batterym.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
After=power-profiles-daemon.service
Description=custom battery governor for laptops

[Service]
ExecStart=/bin/sh -c "sh /opt/batterym/batterservice.sh"

[Install]
WantedBy=multi-user.target

0 comments on commit ededdb5

Please sign in to comment.