add power scripts

This commit is contained in:
Kopatz
2024-11-18 14:57:26 +01:00
parent 141c8f891c
commit 34c3537d68
4 changed files with 28 additions and 2 deletions

View File

@@ -115,7 +115,7 @@ in {
#blur_passes = 1
#blur_new_optimizations = on
shadow = {
shadow = {
enabled = true;
range = 4;
render_power = 3;
@@ -277,6 +277,7 @@ in {
##! Disable window flicker when autocomplete or tooltips appear
#"nofocus,class:^(jetbrains-.*)$,title:^(win.*)$,floating:1"
##"immediate, class:^(Risk.*)$"
"stayfocused,class:(steam_app_107410)"
];
exec-once = [

View File

@@ -88,6 +88,7 @@ in {
xarchiver # archive tool
ani-cli
mangal
gnome.adwaita-icon-theme
];
};
}

View File

@@ -8,8 +8,30 @@ in
enable = mkEnableOption "Enables cli-tools";
};
config = mkIf cfg.enable {
config = let
getTotalPowerUsed = pkgs.writeShellScriptBin "total-power" ''
echo "$(sudo cat /sys/class/powercap/*/energy_uj | awk 'BEGIN { sum = 0; } { sum += $1; } END { print sum; }' "$@") / 1000000" | bc | xargs -I _ echo "_ W"
'';
watchCurrentPowerUsed = pkgs.writeShellScriptBin "watch-current-power" ''
function getCurrentPowerUsed() {
local energy_uj=$(sudo cat $energy_path | awk 'BEGIN { sum = 0; } { sum += $1; } END { print sum; }' "$@")
echo "scale=2; $energy_uj / 1000000" | bc
}
energy_path=$(grep package /sys/class/powercap/*/name | sed 's/name.*$/energy_uj/')
power_prev=0
power_curr=$(getCurrentPowerUsed)
while true; do
power_prev=$power_curr
sleep 1
power_curr=$(getCurrentPowerUsed)
echo "scale=2; ($power_curr - $power_prev) / 1" | bc | xargs -I _ echo "_ W"
done
'';
in mkIf cfg.enable {
environment.systemPackages = with pkgs; [
getTotalPowerUsed
watchCurrentPowerUsed
fzf # fuzzy finder
bat # fancy cat
fd # nicer find

View File

@@ -81,6 +81,8 @@
nixpkgs.config.permittedInsecurePackages =
[ "electron-28.3.3" "electron-27.3.11" ];
networking.firewall.allowedTCPPorts = [ 6567 ]; # mindustry
networking.firewall.allowedUDPPorts = [ 6567 ]; # mindustry
mainUser.layout = "de";
mainUser.variant = "us";
age.identityPaths = [ /home/kopatz/.ssh/id_rsa ];