Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Mac Community > Picture Gallery > UI Customization

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 3, 2013, 10:54 AM   #1
kiercardo
macrumors newbie
 
Join Date: Jan 2013
Location: Rome, IT
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:
d13t

110923

Inspired by & adapted script from midnighttokerkate's [Circle Volume Indicator](http://www.macosxtips.co.uk/geeklets...ume-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/8...0103alle17.png

I simply want CPU.scpt working in order to have a circle like the hdd capacity indicator
kiercardo is offline   0 Reply With Quote
Old Jan 6, 2013, 04:01 PM   #2
kiercardo
Thread Starter
macrumors newbie
 
Join Date: Jan 2013
Location: Rome, IT
up
kiercardo is offline   0 Reply With Quote
Old Jan 8, 2013, 05:57 PM   #3
Ap0ks
macrumors regular
 
Join Date: Aug 2008
Location: 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
Ap0ks is offline   0 Reply With Quote
Old Feb 5, 2014, 04:24 AM   #4
franzg
macrumors newbie
 
Join Date: Feb 2014
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
franzg is offline   0 Reply With Quote

Reply
MacRumors Forums > Mac Community > Picture Gallery > UI Customization

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Creating a Custom iOS 7 Text Tone asleep iOS 7 8 Dec 6, 2013 10:50 PM
creating a custom ios app hassoon iPhone/iPad Programming 5 Apr 14, 2013 11:08 PM
Creating an Automator Script to Send Email Jetheat OS X 3 Oct 29, 2012 01:47 PM
Creating custom vibrations kmichalec iOS 6 6 Oct 19, 2012 01:02 PM
creating a custom 10.8 recovery HD kingweaver88 MacBook Pro 3 Aug 18, 2012 11:14 AM

Forum Jump

All times are GMT -5. The time now is 02:48 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC