Re-establishing the concept:
(1) My favorite “slave” view remains list view, but is easy to change to icon view
(2) The disadvantage of the repeat-loop might be nihilized using “repeat 1” (but it stresses me to set things straight)
(3) Implementing it as an applet adding a few “try” statements leaves both Finder and some related Apps free for other tasks, making things work relatively independant even when Finder is completely busy with other tasks. Changing the scope of windows was indeed flaky.
(4) One problem remains: as the script creates a new Finder window, that one carries my machines’ sharing name that I can’t in any way translate into a Finder object to be targeted by the slave window. Therefore, I am using the startup disk as a starting point for the time being.
(5) The applet will work for half an hour, enough for my daily Finder housekeeping. When bringing it to the front, it will quit immediately.
Note, as a bonus, when selecting nothing, all windows are now temporarily minimized offering a better view over the users’ desktop.
Make this script into an applet:
global madeSmall, sveBounds, tView, oldtheSel, currDate, sveBounds, screen_height, screen_width, slaveWindow, sharingname
set sb to bounds of (item 1 of (screen list)) -- Jon's xcmd
set screen_height to item 4 of sb -- 768
set screen_width to item 3 of sb --1024
set slaveWindow to {}
set sn to do shell script "hostname"
set sharingname to sn
if ".local" is in sn then
set sharingname to ""
repeat with g in characters of sn
if "." is in (g as string) then exit repeat
set sharingname to (sharingname & g) as string
end repeat
end if
tell application "Finder"
activate
set tView to list view
set oldtheSel to ""
set currDate to current date
set sveBounds to {{}}
set madeSmall to false
repeat until (current date) - currDate > 1000
set kp to (keys pressed)
if kp contains {"command"} and kp contains {"."} then exit repeat
tell application "System Events" to set fApp to name of (some application process whose frontmost is true)
set myName to name of (info for (path to me))
if ".app" is in myName then set myName to text from character 1 to character -5 of myName
if myName contains "script" then -- when run from editor
my follow()
else
if fApp is in myName then
exit repeat
else
try
my follow()
end try
end if
end if
tell me to do shell script "sleep 4"
set kp to (keys pressed)
if kp contains {"command"} and kp contains {"."} then exit repeat
end repeat
end tell
on follow()
tell application "Finder"
try
set masterWindow to (first Finder window whose current view is column view and collapsed is false)
on error
set masterWindow to make new Finder window
set masterWindow's toolbar visible to true
set masterWindow's current view to column view
set masterWindow's target to alias ((name of startup disk & ":") as string) --target of MasterWindow kan folder "sharing name" zijn
end try
if not masterWindow's toolbar visible then set masterWindow's toolbar visible to true
if masterWindow = {} then
set masterWindow to make new Finder window
set masterWindow's toolbar visible to true
set masterWindow's current view to column view
set masterWindow's target to alias ((name of startup disk & ":") as string) --target of MasterWindow kan folder "sharing name" zijn
end if
--select MasterWindow
set theSel to the selection --MasterWindow
if (keys pressed) contains {"option"} then display dialog theSel as string
if theSel = {} then
if not madeSmall then
my Expose(true)
set madeSmall to true
end if
else
if madeSmall then
my Expose(false)
set madeSmall to false
end if
if theSel = {} then set theSel to alias ((name of startup disk & ":") as string)
(* if sharingname is in ((item 1 of theSel)) then -- als theSel = folder sharingname ---> geen Finder object
set selName to sharingname
else
set selName to name of (item 1 of theSel)
end if*)
try
set selName to name of (item 1 of theSel)
on error
set selName to name of startup disk
end try
set tg to target of masterWindow
set wdid to id of masterWindow
set bds to bounds of masterWindow
set clps to collapsed of masterWindow
set nwit3 to (item 3 of bds) + 460 -- 600
if nwit3 > screen_width - 100 then set nwit3 to screen_width - 100
set slaveBounds to {(item 3 of bds) + 6, (item 2 of bds) - 38, ¬
nwit3 + 2, (item 4 of bds) + 3}
set slaveWindow to {}
set listIDs to {}
try
set listIDs to (id of Finder windows whose current view = list view)
set slaveWindow to first Finder window whose current view = list view
on error
repeat with fWd in listIDs
set bds2 to bounds of Finder window id (fWd as string)
if bds2 = slaveBounds then set slaveWindow to Finder window id fWd
end repeat
if slaveWindow = {} then set slaveWindow to make new Finder window
my setView(slaveWindow, list view)
set listIDs to (id of Finder windows whose current view = list view)
set oldtheSel to "" -- trigger list wd update
select masterWindow
end try
if not madeSmall then
set bounds of slaveWindow to slaveBounds
end if
if window 1 = masterWindow and oldtheSel ≠theSel and not madeSmall then
try
set target of slaveWindow to tg
on error
set sel to startup disk
set target of slaveWindow to tg
end try
select slaveWindow
try
select item selName of slaveWindow --tg
end try
set current view of slaveWindow to tView
set calculates folder sizes of the list view options of slaveWindow to true
set width of column name column of list view options of slaveWindow to 130
set width of column modification date column of list view options of slaveWindow to 90
set width of column kind column of list view options of slaveWindow to 100 --120
set width of column size column of list view options of slaveWindow to 80
set oldtheSel to theSel
select masterWindow
end if
end if
end tell
end follow
on setView(slaveWindow, tView)
tell application "Finder"
tell slaveWindow
set toolbar visible to false
set current view to tView --list view--icon view
end tell
tell slaveWindow's icon view options
set icon size to "128"
-- set shows icon preview to true
set arrangement to arranged by kind
end tell
end tell
end setView
on Expose(x)
if x and not madeSmall then
tell application "Finder"
set wList to (the Finder windows)
set numwList to number of items of wList
set sveBounds to {{}}
repeat with ww from 1 to numwList
if (item ww of wList) ≠slaveWindow then
set bds to bounds of item ww of wList
set ll to position of item ww of wList
set expBounds to {item 1 of ll, item 2 of ll, (item 1 of ll) + 200, (item 2 of ll) + 200}
set bounds of (item ww of wList) to expBounds
set sveBounds to sveBounds & {{item ww of wList, bds, expBounds}}
end if
end repeat
if slaveWindow ≠{} then ¬
set bounds of slaveWindow to {-100, -100, -50, -50}
end tell
else
if sveBounds ≠{{}} then
repeat with ww from 2 to number of items of sveBounds
try
set lastbounds to bounds of (item 1 of item ww of sveBounds)
set WereminimizedBounds to (item 3 of item ww of sveBounds)
if lastbounds = WereminimizedBounds then ¬
set bounds of (item 1 of item ww of sveBounds) to (item 2 of item ww of sveBounds)
end try
end repeat
end if
end if
end Expose
Browser: Safari 312
Operating System: Mac OS X (10.3.9)