Accessing system information with ease using Python (battery, cpu, gpu, disk, memory, and network).

While working to create a complete redesign of the Touch Bar I came to the dismaying realization that there is no "one-solution-for-all" for easy access to critical system information. With this realization in mind I decided to build a very simple Python project that allows the user to easily pull system information without much hassle within BetterTouchTool.

The project is mainly a wrapper for psutil and iStats, but once installed it makes the life of anyone trying to display system information in the Touch Bar extremely easy. The project is called Tocco, and you can view its source code directly here. With Tocco, you can pull the following information with easy:

import tocco

# Battery
print(tocco.battery.percent)
print(tocco.battery.hours_left)

# CPU
print(tocco.cpu.percent)
print(tocco.cpu.temperature.C)
print(tocco.cpu.temperature.F)

# GPU
print(tocco.gpu.temperature.C)
print(tocco.gpu.temperature.F)

# Fan
print(tocco.fans.rpm)

# Disk
print(tocco.disk.total)
print(tocco.disk.used)
print(tocco.disk.free)
print(tocco.disk.percent)

# Memory
print(tocco.memory.total)
print(tocco.memory.available)
print(tocco.memory.used)
print(tocco.memory.free)
print(tocco.memory.active)
print(tocco.memory.inactive)
print(tocco.memory.wired)
print(tocco.memory.percent)

# Network
print(tocco.network.sent_last_sec)
print(tocco.network.received_last_sec)

Installing

To install Tocco you may either do so via the express installation here or by doing the following:

  1. Install iStats via gem, sudo gem install iStats
  2. Install Brew via brew.sh
  3. Install Python3 via brew, brew install python3
  4. Install Tocco via Python3, /usr/local/bin/python3 -m pip install git+http://github.com/synchronizing/Tocco

Using

After proper installation (detailed below) you are a step away from adding any of the above to your Touch Bar; simply add a "Shell Script/Task Widget" and use the following script with your own designated refresh rate:

/usr/local/bin/python3 -c "import tocco; print(tocco.battery.hours_left)"

Like so:

Simple as that. Your widget will now refresh with information every second! I recommend to be mindful of the refresh rate and only put low refresh time in utilities that are worthy (CPU percent, memory usage, etc) -- stuff like battery percent does not need a 1 second refresh rate.

Imprint | Privacy Policy