본문 바로가기

Com/Etc..

11-11-18 샷에 사용된 긱툴 스크립트

사용방법 : 긱툴 설정에서 shell을 바탕화면으로 끌어서 Properties를 활성화 시킨 후 Commend 입력 창에 code를 넣어주면 됩니다.
덧, 모든 코드는 인터넷에서 구한 후 약간의 짜집기를 가미하였습니다.

한달 달력

echo
echo `cal` |
sed "s/$(date +%e) / $(date +%e | sed 's/.*//g') /" |
sed s'/Su Mo Tu We Th Fr Sa//g' |
sed s'/  */  \|  /g' |
sed s'/^  \|//' | sed s'/  \|//' | sed s'/\|/  /' |
sed s'/\|/•/g' | sed s"/$/       $(date +%A)/"

* 날짜와 시간의 설정이 한글인 경우 4번째 줄의 Su, Mo 등을 일, 월 등으로 수정해야함

시스템 인포

top -l 1 | awk '/PhysMem/ {print "RAM - Use : " $6 " / Free : " $2 " "}';
top -l 2 | awk '/CPU usage/ && NR > 5 {print "CPU - User : " $3 " / Sys : " $5}';
uptime | awk '{if ($5~/[0-9]:[0-9]/) print "Uptime: "$3,$4,$5;else print "Uptime: " $3,$4,$5,$6}' | sed 's/ [0-9] user.*//' | sed 's/,//g' | sed 's/ hr/ hour/' | sed 's/:/ hours /2' | sed 's/ 1 hours/ 1 hour/' | awk '{if ($NF~/[0-6][0-9]/) print $0,"mins";else print $0}' | sed 's/ 00 mins//' | sed 's/01 mins/01 min/'

날씨

왼쪽의 현재 및 내일 온도 (위 현재 온도, 아래 내일의 최고 기온)
curl --silent "http://xml.weather.yahoo.com/forecastrss?p=KSXX0037&u=c" | grep -E '(Current Conditions:|[A-Z]<BR)' | sed -e 's/Current Conditions://' -e 's/<br \/>//' -e 's/<b>//' -e 's/<\/b>//' -e 's/<BR \/>//' -e 's/[A-Z a-z]*, //' -e 's/\(.*\) F/\1 °F/' -e 's/\(.*\) C/\1  °/' | sed 's/ //' | tail -n1
echo
curl --silent "http://xml.weather.yahoo.com/forecastrss?p=KSXX0037&u=c" | grep -E yweather:forecast | tail -1 | sed -e 's/<yweather:forecast //' -e 's/ \/>//' -e 's/"//g' -e 's/ code=34//' -e s/[a-z]*=/value:/g | awk -Fvalue: '{ print ""$5"°"}'

오른쪽의 현재 및 내일의 날씨상태
echo TODAY
curl --silent "http://xml.weather.yahoo.com/forecastrss?p=KSXX0037&u=c" | grep -E '(Current Conditions:|[A-Z]<BR)' | sed -e 's/Current Conditions://' -e 's/<br \/>//' -e 's/<b>//' -e 's/<\/b>//' -e 's/<BR \/>//' -e 's/<description>//' -e 's/<\/description>//' -e 's/, [0-9]* [A-Z]//' | tail -n1
echo -------------
date -v +1d +%a
curl --silent "http://xml.weather.yahoo.com/forecastrss?p=KSXX0037&u=c" | grep -E yweather:forecast | tail -1 | sed -e 's/<yweather:forecast //' -e 's/ \/>//' -e 's/"//g' -e 's/ code=34//' -e s/[a-z]*=/value:/g | awk -Fvalue: '{ print ""$6""}'

날씨 이미지를 위한 스크립트
curl --silent "http://weather.yahoo.com/south-korea/seoul/seoul-1132599/?unit=c" | grep "forecast-icon" | sed "s/.*background\:url(\'\(.*\)\')\;\ _background.*/\1/" | xargs curl --silent -o /Users/***/weather.png\

" " : http://weather.yahoo.com/에 접속한 후 도시 이름 입력, 그 뒤 나오는 창에서 RSS feed의 주소를 적어주면 됨
*** : 개별적인 폴더 설정

 날씨 이미지를 위한 스크립트를 설정 한 후 긱툴 설정에서 이미지를 바탕화면으로 드래그 해 활성화 한 후 URL에 스크립트의 ***에서 설정한 폴더로 가서 weather.png를 선택하여 적용함


iTunes 가사창

osascript <<EOF

if appIsRunning("iTunes") then
 tell application "iTunes" to if player state is playing and lyrics of current track is not "" then name of current track & "\n\n" & lyrics of current track
end if

on appIsRunning(appName)
 tell application "System Events" to (name of processes) contains appName
end appIsRunning
EOF


긱툴에서 사용된 배경 이미지