Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

kiercardo

macrumors newbie
Original poster
Jan 3, 2013
4
0
Rome, IT
Hi
I literally fallen in love with this geekleet and i'm trying to make something similar for cpu, but it simply doesn't work

This is the original tutorial for the diskspace
d13t

110923

Inspired by & adapted script from midnighttokerkate's [Circle Volume Indicator](http://www.macosxtips.co.uk/geeklets/system/circle-volume-indicator/)

INSTRUCTIONS
------------

1. Move DiskCapacityMeter folder to your preferred directory, eg to **Documents/Geektool/**

2. Edit the PATH variable in DCM.scpt to match the path of the DiskCapacityMeter folder,
eg **/Users/YOURUSERNAME/Documents/GeekTool/DiskCapacityMeter/**

3. Open GeekTool/NerdTool and set up a shell geeklet to do:

`osascript /PATH/DCM.scpt`

Where PATH is the path from step 2.

4. Then set up an image geeklet with image:

`file://localhost/PATH/temp.png`

Where PATH is the path from step 2. I placed the image geeklet bottom center of my screen and the 'blind' shell geeklet right under it. This is not ideal and somebody could make all this work without AppleScript… but hey, it works!

5. Set refresh rate of the geeklets to what you like, I prefer 3600 seconds.


and the original DCM.scpt
Code:
-- @d13t
-- 110923

-- Inspired by & adapted script from midnighttokerkate's Circle Volume Indicator
-- http://www.macosxtips.co.uk/geeklets/system/circle-volume-indicator/

-- In GeekTool/NerdTool set up shell geeklet with: osascript /Users/d/Documents/GeekTool/DiskCapacityMeter/DCM.scpt
-- In GeekTool/NerdTool set up  image geeklet with image: file://localhost/Users/d/Documents/GeekTool/DiskCapacityMeter/temp.png
-- Set refresh rate to what you like, I prefer 3600 seconds

on run
	-- Set the path to the directory of the DiskCapacityMeter folder
	-- For example: ""
	set pathName to "/Users/me/Documents/Geektool/DiskCapacityMeter/"
	
	-- df -hl | grep 'disk0s2' | awk '{sub(/%/, "");print $5}'
	-- Substitute % with ""
	set usedSpace to (do shell script "df -hl | grep 'disk1s2' | awk '{sub(/%/, \"\");print $5}'") as integer
	
	-- Getting the rounded number
	set theNumber to (round (usedSpace / 5)) * 5
	
	-- Replacing the image
	do shell script ("cp " & pathName & "/img/" & theNumber & ".png " & pathName & "/temp.png")
end run


this is my script

Code:
on run
	
	set usedSpace to (do shell script "top -l 1 | awk 'CPU usage' | awk '{sub(/%/, \"\"); print $7}'") as integer
	
	
	-- Getting the rounded number
	set theNumber to (round (usedSpace / 5)) * 5
	
	-- Replacing the image
	do shell script ("cp " & pathName & "/img/" & theNumber & ".png " & pathName & "/temp.png")
end run

and my desktop
http://img651.imageshack.us/img651/8803/schermata20130103alle17.png

I simply want CPU.scpt working in order to have a circle like the hdd capacity indicator
 

Ap0ks

macrumors 6502
Aug 12, 2008
316
93
Cambridge, UK
I too couldn't get your script to work initially, but after a little bit of tweaking I managed to bash something together that seems to work

Code:
on run
	-- Folder containing files
	set pathName to "/Users/chollis/Documents/Geeklets/DCM"
	
	-- Get user CPU usage from top
	set usedCPU to (do shell script "top -l 1 | grep 'CPU usage'| awk '{sub(/%/, \"\");print $3}'") as integer
	
	-- Get the rounded number
	set theNumber to (round (usedCPU / 5)) * 5
	
	-- Replace the temp image
	set cpuUsage to pathName & "/img/" & theNumber & ".png"
	set tempImage to pathName & "/temp.png"
	do shell script ("cp " & cpuUsage & " " & tempImage)
end run

Hope that helps you achieve the final effect you're after :)
 

franzg

macrumors newbie
Feb 5, 2014
1
0
problem with reinstalling a deleted script

hi, i would really appreciate any help :) i'm new to writing script and learning how to delete things properly. The problem i am having is that i wrote a command in a shell, lets say something like date +"%b %d" then i closed the shell by pressing the X button because i didn't want the shell. I realized it looked good, so i open a shell and write the exact same command as before, but this time there's nothing in the shell. I've checked to make sure the font is large and in a visible colour and this does not resolve the issue.

thank you for any advice or help
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.