Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use AppleScript version "2.4"
- use scripting additions
- use framework "Foundation"
- use framework "AppKit"
- property itemStatus : missing value
- on run
- init() of me
- end run
- on init()
- set menuList to {"๐ฆ Filter Bad Hosts", "๐ Clean Filters", "", "โช Change Wally", "", "โฌ Update Site", "โฌ Serve MkDocs", "", "โ Transmit", "", "โ BBEdit", "โ Script Editor", "โ Automator", "", "โ CentOS", "โ Windoze", "", "โ Dozer R/W", "โ Dozer Read Only", "โ Mounty", "", "โน Show/Hide Files", "", "โ Eject Disks", "", "โคต AppDelete", "โป Zap Trash", "", "โ Preferences", "โ Quit"}
- set itemStatus to current application's NSStatusBar's systemStatusBar()'s statusItemWithLength:(current application's NSVariableStatusItemLength)
- itemStatus's setTitle:"๐ฆ"
- itemStatus's setHighlightMode:true
- itemStatus's setMenu:(createMenu(menuList) of me)
- repeat
- try
- do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
- itemStatus's setTitle:"๐ฆ"
- on error
- itemStatus's setTitle:"๐"
- end try
- delay 60
- end repeat
- end init
- on createMenu(menuList)
- set theMenu to current application's NSMenu's alloc()'s init()
- set aCount to 1
- repeat with i in menuList
- set j to contents of i
- if j is not equal to "" then
- set menuItem to (current application's NSMenuItem's alloc()'s initWithTitle:j action:"actionHandler:" keyEquivalent:"")
- else
- set menuItem to (current application's NSMenuItem's separatorItem())
- end if
- (menuItem's setTarget:me)
- (menuItem's setTag:aCount)
- (theMenu's addItem:menuItem)
- if j is not equal to "" then
- set aCount to aCount + 1
- end if
- end repeat
- return theMenu
- end createMenu
- on getImage(folderName)
- tell application "Finder"
- return some file of folder ("Pictures:Wallpaper:" & folderName) of home as text
- end tell
- end getImage
- on wally()
- set morning to "Morning"
- set afternoon to "Afternoon"
- set dawn to "DuskDawn"
- set night to "Night"
- set dusk to "DuskDawn"
- set h to hours of (current date)
- set timeNow to morning
- if (h > 8 and h < 12) then
- set timeNow to morning
- else if (h โฅ 12 and h < 18) then
- set timeNow to afternoon
- else if (h โฅ 18 and h < 20) then
- set timeNow to dawn
- else if (h โฅ 20 or h < 5) then
- set timeNow to night
- else if (h โฅ 5 or h < 8) then
- set timeNow to dusk
- end if
- tell application "Finder"
- try
- set displayPicture to my getImage(timeNow)
- set desktop picture to displayPicture
- end try
- end tell
- end wally
- on actionHandler:sender
- set menuTitle to title of sender as string
- if menuTitle is equal to "โ Quit" then
- current application's NSStatusBar's systemStatusBar()'s removeStatusItem:itemStatus
- if (name of current application) is not "Script Editor" then
- tell current application to quit
- end if
- else if menuTitle is equal to "๐ฆ Filter Bad Hosts" then
- do shell script "cp /etc/hosts.full /etc/hosts;dscacheutil -flushcache;killall -HUP mDNSResponder" with administrator privileges
- itemStatus's setTitle:"๐ฆ"
- else if menuTitle is equal to "๐ Clean Filters" then
- do shell script "cp /etc/hosts.clean /etc/hosts;dscacheutil -flushcache;killall -HUP mDNSResponder" with administrator privileges
- itemStatus's setTitle:"๐"
- else if menuTitle is equal to "โช Change Wally" then
- itemStatus's setTitle:"โช"
- wally()
- delay 1
- try
- do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
- itemStatus's setTitle:"๐ฆ"
- on error
- itemStatus's setTitle:"๐"
- end try
- else if menuTitle is equal to "โฌ Update Site" then
- itemStatus's setTitle:"โฌ"
- tell application "WebUp" to activate
- try
- do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
- itemStatus's setTitle:"๐ฆ"
- on error
- itemStatus's setTitle:"๐"
- end try
- else if menuTitle is equal to "โฌ Serve MkDocs" then
- itemStatus's setTitle:"โฌ"
- tell application "ServeMk" to activate
- try
- do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
- itemStatus's setTitle:"๐ฆ"
- on error
- itemStatus's setTitle:"๐"
- end try
- else if menuTitle is equal to "โ Eject Disks" then
- itemStatus's setTitle:"โ"
- set collection_1 to {}
- set diskList to {"All Disks"}
- set mountedDiskName to "Dozer 7"
- set diskIsMounted to false
- tell application "Finder"
- try
- set diskList to diskList & (name of every disk whose ejectable is true)
- on error
- end try
- end tell
- if (count of diskList) is greater than 1 then
- tell application "Finder"
- eject every disk
- end tell
- end if
- tell application "System Events" to set diskNames to name of every disk
- if mountedDiskName is in diskNames then
- set diskIsMounted to true
- end if
- if diskIsMounted then
- do shell script "diskutil unmount /dev/disk0s4"
- end if
- try
- do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
- itemStatus's setTitle:"๐ฆ"
- on error
- itemStatus's setTitle:"๐"
- end try
- else if menuTitle is equal to "โป Zap Trash" then
- itemStatus's setTitle:"โป"
- delay 1
- do shell script "rm -rf ~/.Trash/*" with administrator privileges
- try
- do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
- itemStatus's setTitle:"๐ฆ"
- on error
- itemStatus's setTitle:"๐"
- end try
- else if menuTitle is equal to "โคต AppDelete" then
- itemStatus's setTitle:"โคต"
- do shell script "open /Applications/Tools/AppDelete.app"
- try
- do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
- itemStatus's setTitle:"๐ฆ"
- on error
- itemStatus's setTitle:"๐"
- end try
- else if menuTitle is equal to "โ Script Editor" then
- itemStatus's setTitle:"โ"
- tell application "Script Editor" to activate
- try
- do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
- itemStatus's setTitle:"๐ฆ"
- on error
- itemStatus's setTitle:"๐"
- end try
- else if menuTitle is equal to "โ Automator" then
- itemStatus's setTitle:"โ"
- do shell script "open /Applications/Automator.app"
- try
- do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
- itemStatus's setTitle:"๐ฆ"
- on error
- itemStatus's setTitle:"๐"
- end try
- else if menuTitle is equal to "โ BBEdit" then
- itemStatus's setTitle:"โ"
- do shell script "open /Applications/Editors/BBEdit.app"
- try
- do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
- itemStatus's setTitle:"๐ฆ"
- on error
- itemStatus's setTitle:"๐"
- end try
- else if menuTitle is equal to "โ Transmit" then
- itemStatus's setTitle:"โ"
- do shell script "open /Applications/Network/Transmit.app"
- try
- do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
- itemStatus's setTitle:"๐ฆ"
- on error
- itemStatus's setTitle:"๐"
- end try
- else if menuTitle is equal to "โ CentOS" then
- itemStatus's setTitle:"โ"
- do shell script "/usr/local/bin/VBoxManage startvm CentOS --type gui"
- try
- do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
- itemStatus's setTitle:"๐ฆ"
- on error
- itemStatus's setTitle:"๐"
- end try
- else if menuTitle is equal to "โ Windoze" then
- itemStatus's setTitle:"โ"
- do shell script "/usr/local/bin/VBoxManage startvm Slim7 --type gui"
- try
- do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
- itemStatus's setTitle:"๐ฆ"
- on error
- itemStatus's setTitle:"๐"
- end try
- else if menuTitle is equal to "โ Preferences" then
- itemStatus's setTitle:"โ"
- do shell script "open -a '/Applications/Utilities/Script Editor.app' /Applications/Tools/Controller.app"
- try
- do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
- itemStatus's setTitle:"๐ฆ"
- on error
- itemStatus's setTitle:"๐"
- end try
- else if menuTitle is equal to "โ Dozer R/W" then
- itemStatus's setTitle:"โ"
- do shell script "mkdir /Users/aegon/Desktop/DozerOFF &> /dev/null &"
- do shell script "sudo mount -t ntfs -o rw,auto,nobrowse /dev/disk0s4 /Users/aegon/Desktop/DozerOFF" with administrator privileges
- try
- do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
- itemStatus's setTitle:"๐ฆ"
- on error
- itemStatus's setTitle:"๐"
- end try
- else if menuTitle is equal to "โ Dozer Read Only" then
- itemStatus's setTitle:"โ"
- do shell script "diskutil mount /dev/disk0s4"
- try
- do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
- itemStatus's setTitle:"๐ฆ"
- on error
- itemStatus's setTitle:"๐"
- end try
- else if menuTitle is equal to "โ Mounty" then
- itemStatus's setTitle:"โ"
- do shell script "open /Applications/Tools/Mounty.app"
- try
- do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
- itemStatus's setTitle:"๐ฆ"
- on error
- itemStatus's setTitle:"๐"
- end try
- else if menuTitle is equal to "โน Show/Hide Files" then
- itemStatus's setTitle:"โน"
- set visibility to (do shell script "defaults read com.apple.finder AppleShowAllFiles")
- if visibility is "1" then
- do shell script "defaults write com.apple.finder AppleShowAllFiles 0"
- set resetFinder to display dialog "Restarting Finder in 3 seconds" buttons {"Cancel"} default button "Cancel" with icon stop giving up after 3
- tell application "Finder" to quit
- delay 1
- tell application "Finder" to activate
- else if visibility is "0" then
- do shell script "defaults write com.apple.finder AppleShowAllFiles 1"
- set resetFinder to display dialog "Restarting Finder in 3 seconds" buttons {"Cancel"} default button "Cancel" with icon stop giving up after 3
- tell application "Finder" to quit
- delay 1
- tell application "Finder" to activate
- end if
- try
- do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
- itemStatus's setTitle:"๐ฆ"
- on error
- itemStatus's setTitle:"๐"
- end try
- end if
- end actionHandler:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement