From fc366d7bf269f684c2634cb2872303c6a0038f56 Mon Sep 17 00:00:00 2001 From: Adithya Nair Date: Fri, 17 Mar 2023 00:15:25 +0530 Subject: [PATCH] format --- home/scripts.nix | 66 ++++++++++++++++++------------------ home/sway/waybar/default.nix | 15 ++++---- 2 files changed, 41 insertions(+), 40 deletions(-) diff --git a/home/scripts.nix b/home/scripts.nix index c8f5738..29313c3 100644 --- a/home/scripts.nix +++ b/home/scripts.nix @@ -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 + ''; + }; }; } diff --git a/home/sway/waybar/default.nix b/home/sway/waybar/default.nix index 42d3759..b4c4dc7 100644 --- a/home/sway/waybar/default.nix +++ b/home/sway/waybar/default.nix @@ -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"; + }; }; }; }