2010年7月12日星期一

新博客

建了个独立博客,位于前方右转301米处
http://sycx.info/

update:
info不好看,改了地址

http://sycx.me/

2010年4月22日星期四

Mac不用第三方软件实现闹钟功能

  • 在iTunes创建一个播放列表wakeup,列表中添加当闹钟的音乐文件
  • Automator创建一个应用程序,实现启动iTunes播放wakeup列表
  • iCal设定事件,定好提醒时间,提醒方式选择打开上一步创建的程序
  • 最后,设置自动开机时间,比提醒时间早个5分钟左右
为了避免年纪轻轻就得心脏病,我需要声音能由小到大有个渐变过程
一开始我在Automator流程里加了几个设置音量并暂停的重复操作
但是这样的实现方式看着就不舒服,而且声音变化不够平滑
正好在学objective-C,试着写一个小程序实现,可惜我这个门外汉实在搞不懂设置系统音量应该调用什么函数
用google搜索资料倒是意外得到了一个shell命令
osascript -e "set Volume 0"
Volume值范围是 0.0-10.0
于是改用shell脚本实现
shell脚本代码如下
for((i=0;i<=100;++i))
do
osascript -e "set Volume $i/10"
sleep 0.1
done


2010年4月12日星期一

添加一个”Services"-Translate with Google

依照笑来老师的教程添加了几个Services
今天试图添加一个Translate with Google的时候却遇到了点问题

Google translate的Prefix是这样的
"http://translate.google.cn/#auto|zh-CN|"
按教程到了Display Webpages步骤却会将网址编码转换为
"http://translate.google.cn/%23auto%7Czh-CN%7C"

问题在于Google translate不支持编码后的‘#’

研究了下于是用AppleScript解决

以下是代码
on run {input, parameters}
set thePre to "http://translate.google.cn/#auto|zh-CN|"
set theUrl to thePre & input
tell application "Safari"
activate
make new document
set the URL of front document to theUrl
end tell
return input
end run