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

View file

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