#!/usr/bin/env bash

function sync() {
  if [ "$(powerprofilesctl get)" = "power-saver" ]; then
    hyprctl --batch "\
        keyword animations:enabled 0;\
        keyword decoration:shadow:enabled 0;\
        keyword decoration:blur:enabled 0;\
        keyword decoration:active_opacity 1;\
        keyword decoration:inactive_opacity 1;\
        keyword general:gaps_in 0;\
        keyword general:gaps_out 0;\
        keyword general:border_size 1;\
        keyword decoration:rounding 0;\
        keyword source ~/.config/hypr/land/monitors-powersave.conf;"
  else
    hyprctl reload
  fi

  hyprctl hyprpaper reload ,~/Pictures/wallpaper.png
}
function toggle() {
  if [ "$(powerprofilesctl get)" = "power-saver" ]; then
    powerprofilesctl set performance
  else
    powerprofilesctl set power-saver
  fi

  sync
}

if [ "$#" -ne 1 ]; then
  echo "Usage: $0 {toggle|sync}"
  exit 1
fi

case "$1" in
toggle)
  toggle
  ;;
sync)
  sync
  ;;
*)
  echo "Invalid option: $1"
  echo "Usage: $0 {toggle|sync}"
  exit 1
  ;;
esac
