Upgrade to Leopard mostly smooth, but has small glitch

Bill Hernandez ms at mac-specialist.com
Sat Mar 8 19:48:40 PST 2008


On Mar 8, 2008, at 1:35 AM, paul beard wrote:

> and as a hint, if you install BBedit's command line tools, you can
> simply type "edit <filename>" instead of all that other stuff. Or use
> TextWrangler, for those who are short of coin. It has the same
> facility.


I included two very handy scripts for Leopard at the bottom, if you  
don't like them, please ignore them.

"edit <filename>" didn't work for me using a shell worksheet

port installed > ~/installed_ports.txt
edit ~/installed_ports.txt
-bash: line 4: edit: command not found

instead of using :
open -a /Applications/BBEdit.app ~/installed_ports.txt

I should have used an existing shell script

# shell script : bh_open
# ------------------------------------------------
#!/bin/bash

if [ -a /Applications/BBEdit.app ]; then
	open -a /Applications/BBEdit.app $1
elif [ -a ~/Applications/BBEdit.app ]; then
	open -a ~/Applications/BBEdit.app $1
else
	open -a /Applications/TextEdit.app $1
fi
# ------------------------------------------------

and just call it from the Terminal :

bh_open ~/installed_ports.txt

The following ports are currently installed:
   apache2 @2.2.4_1 (active)
   apr @1.2.9_0 (active)
   apr-util @1.2.8_2 (active)
   bison @2.3_0 (active)
   bzip2 @1.0.4_1 (active)
   curl @7.16.4_0+darwin_8 (active)
   cyrus-sasl2 @2.1.21_0+kerberos (active)
   db44 @4.4.20_1+darwin_8 (active)
   expat @2.0.1_0 (active)
   fontconfig @2.4.2_0+macosx (active)
   freetype @2.3.5_0 (active)
   gd2 @2.0.35_0 (active)
   gettext @0.16.1_0 (active)
   jpeg @6b_2 (active)
   libiconv @1.11_4+darwin_8 (active)
   libmcrypt @2.5.8_0+darwin_8 (active)
   libpng @1.2.18_0+darwin_8 (active)
   libtool @1.5.24_0 (active)
   libxml2 @2.6.28_1 (active)
   libxslt @1.1.20_0 (active)
   m4 @1.4.9_0 (active)
   mhash @0.9.9_0+darwin_8 (active)
   mysql5 @5.0.45_0+darwin_8+server (active)
   ncurses @5.6_0+darwin_8 (active)
   ncursesw @5.6_0+darwin_8 (active)
   openldap @2.3.35_0 (active)
   openssl @0.9.8e_0+darwin_8 (active)
   pcre @7.2_0+utf8 (active)
   perl5.8 @5.8.8_0+darwin_8 (active)
   php5 @5.2.3_0+apache2+darwin_8+fastcgi+ipc+macosx+mysql5+pcntl+pear 
+postgresql+sqlite+tidy (active)
   pkgconfig @0.22_0 (active)
   postgresql82 @8.2.4_0+darwin_8 (active)
   postgresql82-server @8.2.4_0 (active)
   readline @5.2.001_0 (active)
   rpl @1.4.0_0 (active)
   sqlite3 @3.4.2_0+darwin_8 (active)
   tidy @20051026_0+darwin_8 (active)
   tiff @3.8.2_0+darwin_8 (active)
   zlib @1.2.3_1 (active)

Even though this did not launch Apache :

2008.07.03](01:59PM) -> [username] ~ $ sudo launchctl load -w /Library/ 
LaunchDaemons/org.macports.apache2.plist
Password:

launchctl: Dubious ownership on file (skipping): /Library/ 
LaunchDaemons/org.macports.apache2.plist
nothing found to load

    --> And that didn't work so well, so I tried :

[2008.07.03](02:07PM) -> [username] ~ $ sudo /opt/local/apache2/bin/ 
apachectl -k start
Password:
/opt/local/apache2/bin/apachectl: line 70: ulimit: open files: cannot  
modify limit: Invalid argument

Even though there was an error on line 70, it launched Apache and php  
seemed to be working fine, I am sure you are absolutely correct, and  
at some point I will begin having problems, so you are right, I will  
bite the bullet and delete the /opt directory, and start over again.

Thanks very much to all who responded.

There were a few of things I did not like about Leopard :

( 1 ) Blue/White background stripes in the Finder window (fixed in  
script finder_utility.scpt)
( 2 ) Translucent Menu Bar (fixed in script finder_utility.scpt)
( 3 ) Borderless Windows
( 4 ) Inability to close the Sidebar without closing the Toolbar  
(fixed in script stack_windows.scpt)
( 5 ) Lost hierarchical menus on {folders. disks} on the Dock (fixed  
in OS X upgrade 10.5.2)

I know I will probably be criticized for posting these but they have  
turned out very helpful for me, and hopefully they will help someone  
else on the board. The problem with the sidebar causes the windows to  
take up too much room, causing a lot of clutter if you are working  
with several open windows. The second script somewhat addresses the  
problem.

I hope this doesn't make anyone angry that I contributed these, even  
though it is not the right board...

This script takes care of items ( 1 ) and ( 2 )
-- +---------+---------+---------+---------+---------+--------- 
+---------+---------+
on bh_a_script_title()
	(*
		Author			: Bill Hernandez

		ProjectNo		: 407
		ProjectName		: finder_utility (Leopard)

		FileName			: finder_utility.scpt
		FilePath			: ~/user_scripts/user/projects/finder/finder_utility.scpt

		Version			: 1.0.0
		VersionDate		: [ 2008_03_08 ]
		Standardized		: [ 2008_03_08 ]

		Created			: 3/8/08 ( 9:14 PM )
		Updated			: Saturday, March 8, 2008 ( 9:15 PM )
	*)
end bh_a_script_title
-- +---------+---------+---------+---------+---------+--------- 
+---------+---------+---------+---------+
property user_name : ""
-- +---------+---------+---------+---------+---------+--------- 
+---------+---------+---------+---------+
on run
	set aList to {}
	copy "( 1 ) Show Stripes in List View ?" to the end of aList
	copy "( 2 ) Make the menu bar solid white, or solid gray, instead of  
translucent ?" to the end of aList

	set aDefault to item 2 of aList

	set aResult to choose from list aList default items aDefault
	if (aResult is not equal to false) then
		set which_choice to item 1 of aResult
	end if

	if which_choice is (item 1 of aList) then
		toggle_list_view_stripes()
	else if which_choice is (item 2 of aList) then
		toggle_menubar_background()
	end if
end run
-- +---------+---------+---------+---------+---------+--------- 
+---------+---------+---------+---------+
on toggle_list_view_stripes()
	set user_pwd to ""
	set b1 to "Cancel"
	set b2 to "Show Stripes"
	set b3 to "Don't Show Stripes"
	try
		set aResult to display dialog "OS X - Leopard" & return & "Show  
Stripes in List View ?" buttons {b1, b2, b3} default button {b3}
	on error
		-- DO NOTHING, USER CANCELLED
	end try
	set which_choice to button returned of aResult
	if which_choice is b3 then
		do shell script "defaults write com.apple.finder FXListViewStripes - 
bool FALSE; killall Finder"
	else
		do shell script "defaults write com.apple.finder FXListViewStripes - 
bool TRUE; killall Finder"
	end if
end toggle_list_view_stripes
-- +---------+---------+---------+---------+---------+--------- 
+---------+---------+---------+---------+
on toggle_menubar_background()
	set user_pwd to ""

	set aList to {}
	copy "( 1 ) Make the menu bar solid white ?" to the end of aList
	copy "( 2 ) Make the menu bar solid gray ?" to the end of aList
	copy "( 3 ) Make the menu translucent ?" to the end of aList

	set aDefault to item 1 of aList

	set aResult to choose from list aList default items aDefault
	if (aResult is not equal to false) then
		set which_choice to item 1 of aResult
	end if

	try
		set the_result to display dialog "Please enter your short login  
name ?" default answer user_name
		set user_name to text returned of the_result as string
		try
			set the_result to display dialog "Please enter your admin  
password ?" default answer user_pwd with hidden answer
			set user_pwd to text returned of the_result as string
		on error
			set user_pwd to ""
		end try
	on error
		set user_name to ""
	end try

	if ((user_name is not equal to "") and (user_name is not equal to "")  
as string) then
		if which_choice is (item 1 of aList) then --> White Menubar BackGround
			set RunCmd to "sudo defaults write /System/Library/LaunchDaemons/ 
com.apple.WindowServer 'EnvironmentVariables' -dict-add  
'CI_NO_BACKGROUND_IMAGE' 1"
		else if which_choice is (item 2 of aList) then --> Gray Menubar  
BackGround
			set RunCmd to "sudo defaults write /System/Library/LaunchDaemons/ 
com.apple.WindowServer 'EnvironmentVariables' -dict-add  
'CI_NO_BACKGROUND_IMAGE' 0"
		else --> Translucent Menubar BackGround
			set RunCmd to "sudo defaults delete /System/Library/LaunchDaemons/ 
com.apple.WindowServer 'EnvironmentVariables'"
		end if
		try
			do shell script RunCmd user name user_name password user_pwd with  
administrator privileges
			display dialog "You need to restart the computer for the change in  
the MenuBar background color to take effect..."
		on error
			display dialog "There was an error setting the MenuBar background  
color..."
		end try
	end if
end toggle_menubar_background
-- +---------+---------+---------+---------+---------+--------- 
+---------+---------+---------+---------+

This script takes care of items ( 1 ) and ( 2 )
-- +---------+---------+---------+---------+---------+--------- 
+---------+---------+
on bh_a_script_title()
	(*
		Author			: Bill Hernandez

		ProjectNo		: 408
		ProjectName		: stack_windows (Leopard)

		FileName			: stack_windows.scpt
		FilePath			: ~/user_scripts/user/projects/finder/stack_windows.scpt

		Version			: 1.0.0
		VersionDate		: [ 2008_03_08 ]
		Standardized		: [ 2008_03_08 ]

		Created			: 3/6/08 ( 9:06 AM )
		Updated			: Saturday, March 8, 2008 ( 9:34 PM )
		Note			: Assign a Quickey to launch this script anytime the desktop  
get cluttered
	*)
end bh_a_script_title
-- +---------+---------+---------+---------+---------+--------- 
+---------+---------+
on run
	tell application "Finder"
		set windows_per_row to 4
		set max_window_width to 330
		
		set show_toobar to false
		if (show_toobar) then
			set w_header_height to 80
		else
			set w_header_height to 24
			
		end if
		
		set menubar_height to 46
		set dock_height to 60
		set left_spacer to 20
		set right_spacer to 80
		set col_spacer to 4
		
		set screen_bounds to bounds of window of desktop
		set screen_width to item 3 of screen_bounds
		set screen_height to item 4 of screen_bounds
		
		set aWindows to get every window
		set no_of_windows to count of aWindows
		set no_of_rows to no_of_windows / windows_per_row
		set nor_mod to (no_of_rows mod windows_per_row) mod 1
		set no_of_rows to no_of_windows div windows_per_row
		if (nor_mod > 0) then
			set no_of_rows to no_of_rows + 1
		end if
		
		set w_height to (screen_height - menubar_height - dock_height) -  
(w_header_height * no_of_rows) as integer
		set w_width to ((screen_width - left_spacer - right_spacer) /  
windows_per_row) as integer
		if (w_width > max_window_width) then
			set w_width to max_window_width
		end if
		set col_no to 0
		set row_no to 0
		repeat with w_ref in aWindows
			set col_no to col_no + 1
			if (col_no > windows_per_row) then
				set col_no to 1
				set row_no to row_no + 1
			end if
			set w_left to left_spacer + ((col_no - 1) * w_width)
			set w_top to (menubar_height + (row_no * w_header_height))
			set w_right to w_left + w_width - col_spacer
			set w_bottom to w_top + w_height
			set w_props to properties of w_ref
			-- set sidebar width of w_ref to 0
			set properties of w_ref to {sidebar width:0}  -- DOES NOT WORK EITHER
			set properties of w_ref to {toolbar visible:show_toobar} -- ALL  
THREE OF THESE COULD BE JOINED TOGETHER
			set properties of w_ref to {current view:list view}
			set properties of w_ref to {bounds:{w_left, w_top, w_right,  
w_bottom}}
			select w_ref
			set x to col_no
		end repeat
	end tell
end run
-- +---------+---------+---------+---------+---------+--------- 
+---------+---------+


Bill Hernandez
ms at mac-specialist.com





More information about the macports-users mailing list