2.1 KiB
2.1 KiB
1. State Management and Control Script
- 1.1 Create the state directory
~/.local/stateif it doesn't exist. - 1.2 Create the control script
scripts/power-profile.sh. - 1.3 Implement logic in the script to read and write the current profile to
~/.local/state/power-profile. - 1.4 Implement
nextandprevlogic to cycle throughnormal,caffeinated, andheadless. - 1.5 Add logic to kill existing
swayidleprocesses. - 1.6 Add logic to start
swayidlewith profile-specific arguments. - 1.7 Add logic to send a signal to Waybar to refresh the module (
pkill -RTMIN+8 waybar).
2. NixOS and Home Manager Configuration
- 2.1 Create a new Nix module
modules/power-profiles.nixfor the feature. - 2.2 In the module, define the three
swayidleservice configurations. - 2.3 Package the
power-profile.shscript usingpkgs.writeShellScriptBin. - 2.4 Add the script package to
home.packages. - 2.5 Ensure the state directory is created using
home.file.
3. Waybar Integration
- 3.1 Add a
custom/power-profilemodule to the Waybar configuration inconfig/waybar/config. - 3.2 Configure the module's
execto a script that reads the state file and outputs JSON with the correct icon and tooltip. - 3.3 Configure
on-clickto callpower-profile.sh next. - 3.4 Configure
on-click-rightto callpower-profile.sh prev. - 3.5 Add styles for the module in
config/waybar/style.css. - 3.6 Define the real-time signal number for updates (e.g.,
signal: 8).
4. Hyprland Integration
- 4.1 Add a keybinding to
config/hypr/hyprland.confto callpower-profile.sh next. - 4.2 Add a keybinding to call
power-profile.sh prev.
5. Verification
- 5.1 Rebuild the system with
home-manager switch. - 5.2 Verify that the Waybar module appears and shows the default
normalstate. - 5.3 Test the keybindings to cycle through the profiles and observe the icon change.
- 5.4 Check that
swayidleprocesses are restarted correctly with each profile change. - 5.5 Verify the behavior of each profile (e.g., no suspension in
caffeinatedmode).