|
|
#1 | |
|
Problems creating my first custom script
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 Quote:
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
http://img651.imageshack.us/img651/8...0103alle17.png I simply want CPU.scpt working in order to have a circle like the hdd capacity indicator |
||
|
|
0
|
|
|
#2 |
|
up
|
|
|
|
0
|
|
|
#3 |
|
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
|
|
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
All times are GMT -5. The time now is 01:54 AM.






Linear Mode
