Giter Club home page Giter Club logo

cpu-activity-touchbar's Introduction

CPU-Activity-Touchbar

Utilities to enable CPU Activity as a touchbar widget

screenshot example

This allows the touchbar to display a graph of the CPU activity over the last 100 seconds by interval of 5 seconds.

cpuActivity

This utility simply returns the CPU activity in percent (%) beware that this is the sum of the activity percentage of each of your cores, so if you have 4 cores. Your maximum activity is 400%

cpuHistory

This utility add the current CPU activity to the /tmp/cpu.log file and only keep the last 20 entries. It also prints the content of the file to stdout.

cpuGraph

This script reads off the /tmp/cpu.log file, parses it, and generates a graph in heic format at location /tmp/cpulogimage.heic. It also prints out the JSON file that will be interpreted by BTT in order to update the icon in the touchbar with the new image.

Since my own laptop has 4 cores I divide the percentage by 400. If you have more (or less) cores you might want to change the "coreCount" variable in this file.

Installation

Pull the project with

git pull https://github.com/andrevidela/CPU-Activity-Touchbar.git

Then go into its directory

cd CPU-Activity-Touchbar

Here, you can use the install.sh script to symlink those utilities to your location of your preference by giving it the path as argument. I personally put them in /usr/local/bin. Which means I use the script like that

sh install.sh /usr/local/bin

Better Touch Tool installation

In order for this to work you will need BetterTouchTool and you will have to add a new button in your touchbar.

  1. First create a new TouchBar trigger
  2. Select TouchBar Widget and then Shell script/Task widget
  3. In the Script field enter the following program:
cpuHistory > /dev/null
cpuGraph

You can tweak the refresh rate by selecting another time interval.

cpu-activity-touchbar's People

Contributors

andrevidela avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

cpu-activity-touchbar's Issues

Line 7 of install.sh incorrectly calling cpuGraph.sh instead of cpuGraph.swift

When initially following installation steps, hit an issue that cpuGraph.swift was not found:

$ sh install.sh /usr/local/bin
chmod: /Users/anthony/git/CPU-Activity-Touchbar/cpuGraph.sh: No such file or directory

Modified line 7 of the install.sh to rename cpuGraph.sh to CpuGraph.swift to fix:

#!/bin/bash
BIN_LOCATION=$1;
CURRENT=$(PWD)

chmod +x $PWD/cpuActivity.sh
chmod +x $PWD/cpuHistory.sh
chmod +x $PWD/cpuGraph.swift

ln -s $PWD/cpuActivity.sh $BIN_LOCATION/cpuActivity
ln -s $PWD/cpuHistory.sh $BIN_LOCATION/cpuHistory
ln -s $PWD/cpuGraph.swift $BIN_LOCATION/cpuGraph

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.