add: manus-ai waybar_power_profiles_integration.md for niri desktop manager
This commit is contained in:
@@ -0,0 +1,114 @@
|
|||||||
|
# Integrating Power Profiles Daemon into Waybar
|
||||||
|
|
||||||
|
This guide explains how to integrate the `power-profiles-daemon.service` into Waybar, providing a toggleable button to switch between power profiles.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
Ensure you have the following installed:
|
||||||
|
- `waybar` (version 0.9.22 or later recommended)
|
||||||
|
- `power-profiles-daemon`
|
||||||
|
|
||||||
|
## 1. Waybar Configuration
|
||||||
|
|
||||||
|
Add the `power-profiles-daemon` module to your Waybar configuration file (typically located at `~/.config/waybar/config`).
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"modules-right": [
|
||||||
|
"power-profiles-daemon",
|
||||||
|
// ... other modules
|
||||||
|
],
|
||||||
|
|
||||||
|
"power-profiles-daemon": {
|
||||||
|
"format": "{icon}",
|
||||||
|
"tooltip-format": "Power profile: {profile}\nDriver: {driver}",
|
||||||
|
"tooltip": true,
|
||||||
|
"format-icons": {
|
||||||
|
"default": "",
|
||||||
|
"performance": "⚡",
|
||||||
|
"balanced": "",
|
||||||
|
"power-saver": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 2. Automatic Toggling
|
||||||
|
|
||||||
|
Waybar's built-in `power-profiles-daemon` module automatically cycles through available profiles when clicked. You don't need a separate script for basic toggling. However, if you want a custom script for more complex behavior, you can use a `custom/power_profile` module instead.
|
||||||
|
|
||||||
|
### Using the Built-in Module (Recommended)
|
||||||
|
|
||||||
|
The built-in module is the most efficient way to handle this. It interacts directly with the daemon via D-Bus.
|
||||||
|
|
||||||
|
### Custom Toggle Script (Optional)
|
||||||
|
|
||||||
|
If you prefer a custom script, create a file at `~/.config/waybar/scripts/toggle_power_profile.sh`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
current_profile=$(powerprofilesctl get)
|
||||||
|
|
||||||
|
case $current_profile in
|
||||||
|
"power-saver")
|
||||||
|
powerprofilesctl set balanced
|
||||||
|
;;
|
||||||
|
"balanced")
|
||||||
|
powerprofilesctl set performance
|
||||||
|
;;
|
||||||
|
"performance")
|
||||||
|
powerprofilesctl set power-saver
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
powerprofilesctl set balanced
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
```
|
||||||
|
|
||||||
|
Make it executable:
|
||||||
|
```bash
|
||||||
|
chmod +x ~/.config/waybar/scripts/toggle_power_profile.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, use a custom module in your Waybar config:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"custom/power_profile": {
|
||||||
|
"exec": "powerprofilesctl get",
|
||||||
|
"interval": 30,
|
||||||
|
"on-click": "~/.config/waybar/scripts/toggle_power_profile.sh",
|
||||||
|
"format": "Profile: {}"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 3. Styling (Optional)
|
||||||
|
|
||||||
|
You can style the module in your `style.css`:
|
||||||
|
|
||||||
|
```css
|
||||||
|
#power-profiles-daemon {
|
||||||
|
padding-left: 10px;
|
||||||
|
padding-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#power-profiles-daemon.performance {
|
||||||
|
background-color: #f38ba8;
|
||||||
|
color: #1e1e2e;
|
||||||
|
}
|
||||||
|
|
||||||
|
#power-profiles-daemon.balanced {
|
||||||
|
background-color: #a6e3a1;
|
||||||
|
color: #1e1e2e;
|
||||||
|
}
|
||||||
|
|
||||||
|
#power-profiles-daemon.power-saver {
|
||||||
|
background-color: #89b4fa;
|
||||||
|
color: #1e1e2e;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## References
|
||||||
|
|
||||||
|
[1] [Arch Linux Manual: waybar-power-profiles-daemon(5)](https://man.archlinux.org/man/extra/waybar/waybar-power-profiles-daemon.5.en)
|
||||||
|
[2] [power-profiles-daemon GitLab](https://gitlab.freedesktop.org/hadess/power-profiles-daemon)
|
||||||
Reference in New Issue
Block a user