It's a type of Planche
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

13 lines
766B

  1. #!/usr/bin/env bash
  2. # homeassistant_access_token=""
  3. homeassistant_url="http://homeassistant.natrinicle.com:8123/api/states"
  4. homeassistant_screensaver_binary_sensor="${homeassistant_url}/binary_sensor.$(hostname | tr -s '-' '_' | tr '[:upper:]' '[:lower:]')_screen_locked"
  5. ps -e -o stat,command,pid | grep '^T' | grep -P "(firefox|atom)" | awk '{print $NF}' | xargs -P0 -I {} kill -CONT {}
  6. # Update Homeassistant
  7. if [ -n "${homeassistant_access_token}" ] && [ -n "${homeassistant_screensaver_binary_sensor}" ]; then
  8. curl -X POST -H "Authorization: Bearer ${homeassistant_access_token}" -H "Content-Type: application/json" -d "{\"state\": \"off\", \"attributes\": {\"friendly_name\": \"$(hostname) Screensaver\"}}" "${homeassistant_screensaver_binary_sensor}"
  9. fi