#!/usr/bin/env bash

error() {
  local err="Error! $@"
  echo "$err"
  notify-send "Steam-Gamescope" "$err"

  exit 1
}

dependencies=(steam gamescope jq hyprctl notify-send)
for dep in "${dependencies[@]}"; do
  if command -v "$dep" >/dev/null 2>&1; then
    continue
  fi

  error "Missing dependency '$dep'"
done


read -r name width height _ < <(
    hyprctl -j monitors | jq -j '.[] | select(.focused) | .name, " ", .width, " ", .height, "\u0000"'
)

notify-send "Steam" "Launching on $name."
powerprofilesctl launch -p performance -- gamescope -w "$width" -h "$height"  -ef --adaptive-sync -- steam -gamepadui -steamos3


  
  
