Skip to content

Instantly share code, notes, and snippets.

@endolith
Last active September 16, 2016 03:42
Show Gist options
  • Select an option

  • Save endolith/794e0659db9f2b64af8d6d544369e722 to your computer and use it in GitHub Desktop.

Select an option

Save endolith/794e0659db9f2b64af8d6d544369e722 to your computer and use it in GitHub Desktop.
Turn off BOINC if it's hot outside

My new computer uses ~100 W running BOINC at full tilt.
This script checks the weather temperature and turns on BOINC only when it's cold outside.

When I get a USB thermometer I intend to regulate based on indoor temperature, instead.

Also would be good to throttle BOINC rather than turn it fully on or off.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import subprocess
import re
weather = subprocess.check_output(['inxi', '-w'])
temp = int(re.search('\((\D?\d+) C\)', weather).groups()[0])
if temp > 15:
subprocess.call(['systemctl', 'stop', 'boinc-client'])
else:
subprocess.call(['systemctl', 'start', 'boinc-client'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment