Skip to content
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

powerprofilesctl: add powerprofiles switcher script #537

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
18 changes: 18 additions & 0 deletions powerprofilesctl/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# powerprofilesctl

Shows the current powerprofile and gives the ability to change it by clicking on it.

![powerprofilesctl-performance](./powerprofilesctl-performance.png)
![powerprofilesctl-balanced](./powerprofilesctl-balanced.png)
![powerprofilesctl-power-saver](./powerprofilesctl-power-saver.png)

# Dependencies
- [powerprofilesctl](https://manpages.debian.org/unstable/power-profiles-daemon/powerprofilesctl.1.en.html)

# Config
```
[powerprofilesctl]
command=$SCRIPT_DIR/powerprofilesctl
label=🔌
interval=30
```
25 changes: 25 additions & 0 deletions powerprofilesctl/powerprofilesctl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

get_power_state() {
powerprofilesctl | grep '*' | awk '{ print $2 }' | sed 's/: *//'
}

toggle_power_state() {
current_state=$(get_power_state)

if [ "$current_state" == "power-saver" ]; then
powerprofilesctl set performance
elif [ "$current_state" == "balanced" ]; then
powerprofilesctl set power-saver
else
powerprofilesctl set balanced
fi
}

if [[ "$BLOCK_BUTTON" ]]; then
case "$BLOCK_BUTTON" in
1) toggle_power_state;;
esac
fi

echo "$(get_power_state)"
Binary file added powerprofilesctl/powerprofilesctl-balanced.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added powerprofilesctl/powerprofilesctl-performance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added powerprofilesctl/powerprofilesctl-power-saver.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions powerprofilesctl/powerprofilesctl.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[powerprofilesctl]
command=$SCRIPT_DIR/powerprofilesctl
label=🔌
interval=30