change refresh rate from 120hz to 60hz in battery mode and revert back

udev rules

#/etc/udev/rules.d/90-hyprland-onbattery.rules
SUBSYSTEM=="power_supply", KERNEL=="ACAD", ACTION=="change", ATTR{online}=="0", RUN+="/bin/runuser -u teraflops /usr/local/bin/hypr-monitor-switch.sh disconnected"

#/etc/udev/rules.d/91-hyprland-onpower.rules
SUBSYSTEM=="power_supply", KERNEL=="ACAD", ACTION=="change", ATTR{online}=="1", RUN+="/bin/runuser -u teraflops /usr/local/bin/hypr-monitor-switch.sh connected"
#!/bin/bash
# /usr/local/bin/hypr-monitor-switch.sh
read -r signature < /tmp/hyprland_instance_signature
export HYPRLAND_INSTANCE_SIGNATURE="$signature"
export XDG_RUNTIME_DIR="/run/user/1000"
export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus"
LOCKFILE="/tmp/hypr-monitor-switch.lock"

exec 200>$LOCKFILE
flock -n 200 || exit 1

if [[ "$1" == "disconnected" ]]; then
    hyprctl keyword monitor "eDP-1,2880x1800@60,0x0,1.5"
    echo "Set to 60Hz" >> /tmp/udev-hypr-monitor.log
elif [[ "$1" == "connected" ]]; then
    hyprctl keyword monitor "eDP-1,2880x1800@120,0x0,1.5,vrr,1,bitdepth,10"
    echo "Set to 120Hz" >> /tmp/udev-hypr-monitor.log
fi

you have to export the signature of the hyprland instance to the /tmp/hyprlandinstancesignature file.

# ~/.config/hypr/conf/autostart.conf
exec-once = echo $HYPRLAND_INSTANCE_SIGNATURE > /tmp/hyprland_instance_signature