#!/usr/bin/env bash
#
# MNT Reform Powersave Script
#

if [ "on" = "$1" ]; then
  echo "Turning Powersave ON.."

  echo "Stopping Syncthing.."
  systemctl --user stop syncthing
  
  echo "Stopping Bluetooth.."
  sudo systemctl stop bluetooth

  echo "Stopping Wifi"
  sudo systemctl stop wpa_supplicant
  
elif [ "off" = "$1" ]; then
  echo "Turning Powersave OFF.."

  echo "Starting Syncthing.."
  systemctl --user start syncthing
  
  echo "Starting Bluetooth.."
  sudo systemctl start bluetooth

  echo "Starting Wifi.."
  sudo systemctl start wpa_supplicant
  
else
  echo "MNT Reform Powersave Script"
  echo "----------------------------"
  echo "Bluetooth:  `systemctl is-active bluetooth` (`systemctl is-enabled bluetooth`)"
  echo "Wifi:       `systemctl is-active wpa_supplicant` (`systemctl is-enabled wpa_supplicant`)"
  echo "PostgreSQL: `systemctl is-active postgresql` (`systemctl is-enabled postgresql`)"
  echo "Syncthing:  `systemctl --user is-active syncthing` (`systemctl --user is-enabled syncthing`)"
  echo "----------------------------"
  echo "Usage:"
  echo "  powersave off"
  echo "  powersave on"
fi
