move power-profiles script to package
This commit is contained in:
parent
90999017a1
commit
43e9c908bc
3 changed files with 42 additions and 49 deletions
|
@ -65,51 +65,5 @@ in
|
||||||
;;
|
;;
|
||||||
esac'';
|
esac'';
|
||||||
};
|
};
|
||||||
"scripts/power_profile.sh" =
|
|
||||||
let
|
|
||||||
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
|
|
||||||
|
|
||||||
set -eu
|
|
||||||
|
|
||||||
POWER_PROFILE_FILE="$HOME/.cache/power_profile"
|
|
||||||
POWER_PROFILE="powersave"
|
|
||||||
|
|
||||||
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
|
|
||||||
${notify-send} -u normal "Power Profile" "Switched to $POWER_PROFILE mode."
|
|
||||||
;;
|
|
||||||
"icon")
|
|
||||||
if [ "$POWER_PROFILE" == "powersave" ]; then
|
|
||||||
echo ""
|
|
||||||
elif [ "$POWER_PROFILE" == "performance" ]; then
|
|
||||||
echo ""
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,19 @@
|
||||||
{ lib, stdenvNoCC, makeWrapper, libnotify, rofi-wayland }:
|
{ lib, stdenvNoCC, makeWrapper, libnotify, rofi-wayland, power-profiles-daemon, cpupower }:
|
||||||
stdenvNoCC.mkDerivation {
|
stdenvNoCC.mkDerivation {
|
||||||
pname = "scripts";
|
pname = "scripts";
|
||||||
version = "1.0";
|
|
||||||
src = ./.;
|
src = ./.;
|
||||||
|
|
||||||
nativeBuildInputs = [ makeWrapper ];
|
nativeBuildInputs = [ makeWrapper ];
|
||||||
buildInputs = [ ];
|
buildInputs = [ libnotify rofi-wayland power-profiles-daemon cpupower ];
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
cp power-menu.sh $out/bin/power-menu
|
cp power-menu.sh $out/bin/power-menu
|
||||||
chmod +x $out/bin/power-menu
|
chmod +x $out/bin/power-menu
|
||||||
wrapProgram $out/bin/power-menu --prefix PATH : ${lib.makeBinPath [ libnotify rofi-wayland ]}
|
wrapProgram $out/bin/power-menu --prefix PATH : ${lib.makeBinPath [ libnotify rofi-wayland ]}
|
||||||
|
|
||||||
|
cp power-profiles.sh $out/bin/power-profiles
|
||||||
|
chmod +x $out/bin/power-profiles
|
||||||
|
wrapProgram $out/bin/power-profiles --prefix PATH : ${lib.makeBinPath [ libnotify power-profiles-daemon cpupower ]}
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
36
packages/scripts/power-profiles.sh
Normal file
36
packages/scripts/power-profiles.sh
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
POWER_PROFILE_FILE="$HOME/.cache/power_profile"
|
||||||
|
POWER_PROFILE="powersave"
|
||||||
|
|
||||||
|
if [ -f "$POWER_PROFILE_FILE" ]; then
|
||||||
|
POWER_PROFILE="$(<$POWER_PROFILE_FILE)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
"toggle")
|
||||||
|
if [ "$POWER_PROFILE" == "powersave" ]; then
|
||||||
|
cpupower frequency-set --governor performance > /dev/null
|
||||||
|
powerprofilesctl set performance
|
||||||
|
POWER_PROFILE="performance"
|
||||||
|
elif [ "$POWER_PROFILE" == "performance" ]; then
|
||||||
|
cpupower frequency-set --governor powersave > /dev/null
|
||||||
|
powerprofilesctl set power-saver
|
||||||
|
POWER_PROFILE="powersave"
|
||||||
|
fi
|
||||||
|
echo $POWER_PROFILE > $POWER_PROFILE_FILE
|
||||||
|
notify-send -u normal "Power Profile" "Switched to $POWER_PROFILE mode."
|
||||||
|
;;
|
||||||
|
"icon")
|
||||||
|
if [ "$POWER_PROFILE" == "powersave" ]; then
|
||||||
|
echo ""
|
||||||
|
elif [ "$POWER_PROFILE" == "performance" ]; then
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
Loading…
Reference in a new issue