This commit is contained in:
Adithya 2023-03-17 00:15:25 +05:30
parent 27a77c6ddd
commit fc366d7bf2
No known key found for this signature in database
GPG key ID: 0C7F35F4F821290F
2 changed files with 41 additions and 40 deletions

View file

@ -70,45 +70,45 @@
sudo = "/run/wrappers/bin/sudo"; sudo = "/run/wrappers/bin/sudo";
cpupower = "${osConfig.boot.kernelPackages.cpupower}/bin/cpupower"; cpupower = "${osConfig.boot.kernelPackages.cpupower}/bin/cpupower";
powerprofilesctl = "${pkgs.power-profiles-daemon}/bin/powerprofilesctl"; powerprofilesctl = "${pkgs.power-profiles-daemon}/bin/powerprofilesctl";
in { in
executable = true; {
text = '' executable = true;
#!/bin/sh text = ''
#!/bin/sh
set -eu set -eu
POWER_PROFILE_FILE="$HOME/.cache/power_profile" POWER_PROFILE_FILE="$HOME/.cache/power_profile"
POWER_PROFILE="powersave" POWER_PROFILE="powersave"
if [ -f "$POWER_PROFILE_FILE" ]; then if [ -f "$POWER_PROFILE_FILE" ]; then
POWER_PROFILE="$(<$POWER_PROFILE_FILE)" POWER_PROFILE="$(<$POWER_PROFILE_FILE)"
fi fi
case "$1" in case "$1" in
"toggle") "toggle")
if [ "$POWER_PROFILE" == "powersave" ]; then if [ "$POWER_PROFILE" == "powersave" ]; then
${sudo} ${cpupower} frequency-set --governor performance > /dev/null ${sudo} ${cpupower} frequency-set --governor performance > /dev/null
${powerprofilesctl} set performance ${powerprofilesctl} set performance
POWER_PROFILE="performance" POWER_PROFILE="performance"
elif [ "$POWER_PROFILE" == "performance" ]; then elif [ "$POWER_PROFILE" == "performance" ]; then
${sudo} ${cpupower} frequency-set --governor powersave > /dev/null ${sudo} ${cpupower} frequency-set --governor powersave > /dev/null
${powerprofilesctl} set power-saver ${powerprofilesctl} set power-saver
POWER_PROFILE="powersave" POWER_PROFILE="powersave"
fi fi
echo $POWER_PROFILE > $POWER_PROFILE_FILE echo $POWER_PROFILE > $POWER_PROFILE_FILE
;; ;;
"icon") "icon")
if [ "$POWER_PROFILE" == "powersave" ]; then if [ "$POWER_PROFILE" == "powersave" ]; then
echo "󰌪" echo "󰌪"
elif [ "$POWER_PROFILE" == "performance" ]; then elif [ "$POWER_PROFILE" == "performance" ]; then
echo "󰓅" echo "󰓅"
fi fi
;; ;;
*) *)
;; ;;
esac esac
'';
''; };
};
}; };
} }

View file

@ -91,13 +91,14 @@
"custom/power_profile" = "custom/power_profile" =
let let
script = "${config.xdg.configHome}/scripts/power_profile.sh"; script = "${config.xdg.configHome}/scripts/power_profile.sh";
in { in
exec = "${script} icon"; {
on-click = "${script} toggle"; exec = "${script} icon";
format = "{}"; on-click = "${script} toggle";
tooltip = false; format = "{}";
interval = "10"; tooltip = false;
}; interval = "10";
};
}; };
}; };
} }