-- Clean up Desktop 3.3
-- Skripti järjestää työpöydän: Käynnistyslevy oikealle ylhäälle, muut levyt/osiot kahteen pystysarakkeeseen, kansiot ja lopuksi tiedostot.
-- Finder Mac OS 8.5.1:ssa järjestää työpöydän levyt käytetyn levytilan mukaan .
-- Näin tapahtuu riippumatta käyttäjän valinnasta (ts. järjestä nimen, merkin jne mukaan). Tämän täytyy olla bugi.
-- 2000 Tuomas Rosberg <vanhentunut>
-- Public Domain. Kirjoittaja ei tietenkään vastaa ohjelman toimivuudesta tai sopimisesta tiettyyn tarkoitukseen.
--Muuttujia:
set gridInPixels to 54 --Kuvakkeiden etäisyydeksi toisistaan.
set y to 30 --Aloituskohta y-akselilla.
set theDisks to list disks --Vaatii scripting additionin.
set limit to (round (count of theDisks) / 2) --On nollaa suurempi kokonaisluku. Taltioiden kuvakkeet pinotaan nyt kahteen sarakkeeseen.
tell application "Finder"
clean up desktop by name --Finderin "Järjestä" laittaa mm. Roskakorin siististi.
set posTrash to position of trash
set theWidth to item 1 of posTrash --Roskakorin x-koordinaatti kertoo näytön vaakaresoluutiosta ja asettaa aloituskohdan x-akselilla.
set theHeight to item 2 of posTrash --Roskakorin y-koordinaatti kertoo näytön pystyresoluutiosta.
set theFolders to {} --Tyhjä lista.
set everyFolder to name of every folder in desktop
repeat with aFolder in everyFolder
if aFolder is not in theDisks then
set theFolders to theFolders & aFolder --Lista kansioista työpöydällä, jätetään levyt pois.
end if
end repeat
set theFiles to {}
try
set theFiles to name of every file in desktop
on error
end try
end tell
set theList to theFolders & theFiles
--
--Järjestetään levyt:
set posX to theWidth
set posY to y
set countUp to 0
repeat with aDisk in theDisks
tell application "Finder"
set aDisk to aDisk as string --Muuttujan tyyppi Finderin ymmärtämään muotoon.
set position of disk aDisk to {posX, posY}
end tell
set countUp to countUp + 1 --Toistojen lukumäärä.
if countUp < limit then
set posY to posY + gridInPixels --Seuraavan kuvakkeen y-koordinaatti.
else if countUp = limit then --Aloitetaan uusi kuvakesarake.
set y to y + 12 --Estetään kuvakkeiden nimien peittyminen limittämällä.
set posY to y
set posX to posX - gridInPixels --Seuraavan sarakkeen x-koordinaatti.
set countUp to 0
end if
end repeat
--
--Järjestetään kansiot ja tiedostot.
if countUp is not in {0, limit} then --Edellinen moduli ei ole aloittanut uutta saraketta, aloitetaan nyt.
set posX to posX - gridInPixels
set y to y + 12
set posY to y
end if
repeat with anItem in theList
tell application "Finder"
set anItem to anItem as string --Muuttujan tyyppi Finderin ymmärtämään muotoon.
set anItem to item anItem of application "Finder" --Muuttujan tyyppi Finderin ymmärtämään muotoon.
if posY < theHeight then
if anItem is not the trash then
set position of anItem to {posX, posY}
set posY to posY + gridInPixels
end if
else
set posX to posX - gridInPixels
set y to y + 12
set posY to y
if anItem is not the trash then
set position of anItem to {posX, posY}
set posY to posY + gridInPixels
end if
end if
end tell
end repeat