nix/module/powerlimit/Script.nix

35 lines
524 B
Nix
Raw Normal View History

{ controlFileMax
, controlFileMin
, onMax
, onMin
, offMax
, offMin
, ... }: {
script = ''
function toggle() {
if status; then
echo ${offMax} > ${controlFileMax}
echo ${offMin} > ${controlFileMin}
else
echo ${onMin} > ${controlFileMin}
echo ${onMax} > ${controlFileMax}
fi
true
}
function waybar() {
status || echo -n ""
}
function status() {
local current=$(cat ${controlFileMax})
local enabled="${onMax}"
[[ "''${current}" = "''${enabled}" ]]
}
''${@}
'';
}