Difference between revisions of "Automatic Icon Positioning (Packaging)"

From Apache OpenOffice Wiki
Jump to: navigation, search
m
 
(2 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
<pre>
 
<pre>
 
on run argv
 
on run argv
set argv to POSIX file (item 1 of argv)
+
try
tell application "Finder"
+
set argv to POSIX file (item 1 of argv)
set fichiers to items of folder argv
+
on error
set i to 0
+
set argv to choose folder
repeat with myItem in fichiers
+
end try
set i to i + 1
+
try
+
tell application "Finder"
set itemProperties to (properties of myItem)
+
set fichiers to items of folder argv
set itemPos to position of itemProperties
+
set i to 0
set myName to name of itemProperties
+
repeat with myItem in fichiers
+
set i to i + 1
if i is 1 then set position of myItem to {332, 191} -- in alphabetic order "Applications"
+
if i is 2 then set position of myItem to {97, 62} -- LICENSEs
+
set itemProperties to (properties of myItem)
if i is 3 then set position of myItem to {101, 191} -- OpenOffice*
+
set itemPos to position of itemProperties
if i is 4 then set position of myItem to {304, 61} -- READMEs
+
set myName to name of itemProperties
end repeat
+
quit
+
if i is 1 then set position of myItem to {332, 191} -- in alphabetic order "Applications"
end tell
+
if i is 2 then set position of myItem to {97, 62} -- LICENSEs
 +
if i is 3 then set position of myItem to {101, 191} -- OpenOffice*
 +
if i is 4 then set position of myItem to {304, 61} -- READMEs
 +
end repeat
 +
end tell
 +
end try
 +
tell application "System Events" to quit application "Finder"
 
return argv as string
 
return argv as string
 
end run
 
end run
Line 26: Line 32:
  
 
To use it, assuming you called it ''ooo_pack_finalizer.scpt'', just type :
 
To use it, assuming you called it ''ooo_pack_finalizer.scpt'', just type :
$ osascript ooo_pack_finalizer.scpt
+
<pre>$ osascript ooo_pack_finalizer.scpt ''path to install folder''</pre>
  
 
To use it, from a remote host, you will need to sudo to access the WindowServer :
 
To use it, from a remote host, you will need to sudo to access the WindowServer :
$ sudo osascript ooo_pack_finalizer.scpt
+
<pre>$ sudo osascript ooo_pack_finalizer.scpt ''path to install folder''</pre>
  
Notice than executing that script will starts the Finder with root rights, and any user with physical access to the computer will be able to use Finder during the script execution (until quit). In order to avoid security problem, make sure the Finder is really quit either by issuing ''$ sudo osascript -e "tell application \"Finder\" to quit"'' or using ''sudo kill''. This way potential attackers will have access to Finder only few seconds.
+
Notice than executing that script will starts the Finder with root rights, and any user with physical access to the computer will be able to use Finder during the script execution (until quit request from System Events).
  
 
For better security, it should be possible to lock the user interface during the execution of the script by developping a simple app which captures all mouse and keyboard events in order to disallow access to Finder.   
 
For better security, it should be possible to lock the user interface during the execution of the script by developping a simple app which captures all mouse and keyboard events in order to disallow access to Finder.   

Latest revision as of 01:11, 20 May 2007

Here is an Apple Script allowing to automatically place correctly the icons in OpenOffice installation folder :

on run argv
	try
		set argv to POSIX file (item 1 of argv)
	on error
		set argv to choose folder
	end try
	try
		tell application "Finder"
			set fichiers to items of folder argv
			set i to 0
			repeat with myItem in fichiers
				set i to i + 1
				
				set itemProperties to (properties of myItem)
				set itemPos to position of itemProperties
				set myName to name of itemProperties
				
				if i is 1 then set position of myItem to {332, 191} -- in alphabetic order "Applications"
				if i is 2 then set position of myItem to {97, 62} -- LICENSEs
				if i is 3 then set position of myItem to {101, 191} -- OpenOffice*
				if i is 4 then set position of myItem to {304, 61} -- READMEs
			end repeat
		end tell
	end try
	tell application "System Events" to quit application "Finder"
	return argv as string
end run

To use it, assuming you called it ooo_pack_finalizer.scpt, just type :

$ osascript ooo_pack_finalizer.scpt ''path to install folder''

To use it, from a remote host, you will need to sudo to access the WindowServer :

$ sudo osascript ooo_pack_finalizer.scpt ''path to install folder''

Notice than executing that script will starts the Finder with root rights, and any user with physical access to the computer will be able to use Finder during the script execution (until quit request from System Events).

For better security, it should be possible to lock the user interface during the execution of the script by developping a simple app which captures all mouse and keyboard events in order to disallow access to Finder.

Personal tools