Commit dae1e31b043d
Changed files (5)
dots
config
niri
raffi
scripts
home
common
desktop
niri
dots/bin/power-profile-cycle
@@ -1,16 +0,0 @@
-#!/usr/bin/env bash
-# Cycle through tuned power profiles and notify
-set -euo pipefail
-
-current=$(tuned-adm active 2>/dev/null | sed 's/.*: //')
-
-case "$current" in
- powersave) next="balanced-battery" ;;
- balanced-battery) next="balanced" ;;
- balanced) next="latency-performance" ;;
- latency-performance) next="powersave" ;;
- *) next="balanced" ;;
-esac
-
-tuned-adm profile "$next"
-notify-send --icon=battery --category=info "Power: $next"
dots/config/niri/config.kdl
@@ -223,7 +223,6 @@ binds {
Mod+T { spawn "bash" "-c" "notify-send --icon=clock --category=info --urgency=critical \"$(date +\"%I:%M\")\""; }
Mod+B { spawn "bash" "-c" "notify-send --icon=battery --category=info --urgency=critical \"$(acpi)\""; }
- Mod+P hotkey-overlay-title="Cycle Power Profile" { spawn "power-profile-cycle"; }
Mod+Shift+T hotkey-overlay-title="Toggle Color Scheme" { spawn "toggle-color-scheme"; }
Mod+Shift+B { spawn "pkill" "-USR1" "waybar"; }
dots/config/raffi/scripts/power-profile-raffi
@@ -1,47 +1,23 @@
#!/usr/bin/env bash
-# Power profile switcher for raffi script filter.
-# Uses tuned-adm (Fedora CSB) or powerprofilesctl.
+# Power profile switcher via PPD D-Bus API (tuned-ppd or power-profiles-daemon).
set -euo pipefail
query="${1:-}"
+bus="net.hadess.PowerProfiles"
+path="/net/hadess/PowerProfiles"
+iface="net.hadess.PowerProfiles"
+
+active=$(busctl get-property "$bus" "$path" "$iface" ActiveProfile 2>/dev/null | awk '{print $2}' | tr -d '"')
items="[]"
-
-if command -v tuned-adm &>/dev/null; then
- active=$(tuned-adm active 2>/dev/null | sed 's/.*: //')
- while IFS= read -r profile; do
- profile=$(echo "$profile" | sed 's/^- //' | awk '{print $1}')
- [[ -z "$profile" ]] && continue
-
- if [[ -n "$query" ]] && ! echo "$profile" | grep -qi "$query"; then
- continue
- fi
-
- if [[ "$profile" == "$active" ]]; then
- status="โ active"
- else
- status=""
- fi
-
- items=$(jq --arg name "$profile" --arg status "$status" \
- '. + [{"title": $name, "subtitle": $status, "arg": $name}]' <<< "$items")
- done < <(tuned-adm list 2>/dev/null | grep '^- ')
-elif command -v powerprofilesctl &>/dev/null; then
- active=$(powerprofilesctl get 2>/dev/null)
- for profile in power-saver balanced performance; do
- if [[ -n "$query" ]] && ! echo "$profile" | grep -qi "$query"; then
- continue
- fi
-
- if [[ "$profile" == "$active" ]]; then
- status="โ active"
- else
- status=""
- fi
-
- items=$(jq --arg name "$profile" --arg status "$status" \
- '. + [{"title": $name, "subtitle": $status, "arg": $name}]' <<< "$items")
- done
-fi
+for profile in power-saver balanced performance; do
+ if [[ -n "$query" ]] && ! echo "$profile" | grep -qi "$query"; then
+ continue
+ fi
+ status=""
+ [[ "$profile" == "$active" ]] && status="โ active"
+ items=$(jq --arg name "$profile" --arg status "$status" \
+ '. + [{"title": $name, "subtitle": $status, "arg": $name}]' <<< "$items")
+done
jq -n --argjson items "$items" '{"items": $items}'
dots/config/raffi/raffi.yaml
@@ -105,7 +105,7 @@ addons:
keyword: pw
command: ~/.config/raffi/scripts/power-profile-raffi
icon: battery
- action: tuned-adm profile {value} || powerprofilesctl set {value}
+ action: busctl set-property net.hadess.PowerProfiles /net/hadess/PowerProfiles net.hadess.PowerProfiles ActiveProfile s {value}
- name: YubiKey OATH
keyword: otp
command: ~/.config/raffi/scripts/yubikey-oath-raffi
home/common/desktop/niri/waybar.nix
@@ -110,14 +110,16 @@
};
"custom/tuned" = {
"exec" = pkgs.writeShellScript "waybar-tuned" ''
+ bus="net.hadess.PowerProfiles"
+ path="/net/hadess/PowerProfiles"
+ iface="net.hadess.PowerProfiles"
while true; do
- profile=$(tuned-adm active 2>/dev/null | sed 's/.*: //')
+ profile=$(busctl get-property "$bus" "$path" "$iface" ActiveProfile 2>/dev/null | awk '{print $2}' | tr -d '"')
case "$profile" in
- powersave) icon="๐"; class="powersave" ;;
- balanced-battery) icon="๐"; class="balanced-battery" ;;
- balanced) icon="โก"; class="balanced" ;;
- throughput-*|performance*) icon="๐"; class="performance" ;;
- *) icon="โ"; class="unknown" ;;
+ power-saver) icon="๐"; class="powersave" ;;
+ balanced) icon="โก"; class="balanced" ;;
+ performance) icon="๐"; class="performance" ;;
+ *) icon="โ"; class="unknown" ;;
esac
printf '{"text": "%s %s", "tooltip": "Power: %s", "class": "%s"}\n' "$icon" "$profile" "$profile" "$class"
sleep 10
@@ -127,14 +129,16 @@
"format" = "{}";
"tooltip" = true;
"on-click" = pkgs.writeShellScript "tuned-cycle" ''
- current=$(tuned-adm active 2>/dev/null | sed 's/.*: //')
+ bus="net.hadess.PowerProfiles"
+ path="/net/hadess/PowerProfiles"
+ iface="net.hadess.PowerProfiles"
+ current=$(busctl get-property "$bus" "$path" "$iface" ActiveProfile 2>/dev/null | awk '{print $2}' | tr -d '"')
case "$current" in
- powersave) next="balanced-battery" ;;
- balanced-battery) next="balanced" ;;
- balanced) next="throughput-performance" ;;
- *) next="powersave" ;;
+ power-saver) next="balanced" ;;
+ balanced) next="performance" ;;
+ *) next="power-saver" ;;
esac
- tuned-adm profile "$next"
+ busctl set-property "$bus" "$path" "$iface" ActiveProfile s "$next"
'';
};
"niri/language" = {
@@ -272,10 +276,6 @@
color: #50fa7b;
}
- #custom-tuned.balanced-battery {
- color: #8be9fd;
- }
-
#custom-tuned.balanced {
color: #f1fa8c;
}