SuperCard Shell Essentials

 

defaults example

Page history last edited by DCS 3 yrs ago

Application defaults

 

See the 'defaults' man page for details Command Documentation

 

This is an example of using the defaults command to find out some information about your dock.

function dockProperties
put "pinning,showhidden,showshadow,tilesize,trash-full,version,autohide,largesize,launchanim,"& ¬
"magnification,mineffect,mod-count,orientation" into docpProperties
repeat with x = 1 to 13
--this could be one linereplace it by shell on line 2
get shell(merge("defaults read com.apple.dock [[item x of docpProperties]]"))
put item x of docpProperties&COLON&SPACE &it into line x of tReturn
end repeat
return  tReturn
end dockProperties

 

Same as above except builds all the commands, with formatting inline, then executes at once.

Throws errors to console if a property doesn't exist.

 

on mouseup
put "pinning,showhidden,showshadow,tilesize,trash-full,version,autohide,largesize,launchanim,"& ¬
"magnification,mineffect,mod-count,orientation" into dockProperties
repeat with x = 1 to the number of items in dockProperties
put merge("printf [[item x of dockProperties]]`: ` ; ") after cmd
--format property name label
put merge("defaults read com.apple.dock [[item x of dockProperties]] || ") after cmd
--get the property value
put "printf `n` ;" after cmd
--if the property doesnt exist add a linefeed
end repeat
put merge(cmd) into cmd
get shell(cmd)
ask list it
--display result
end mouseup

 

This version reads entire plist then uses grep to select entries.

Wont return property arrays, but avoids errors.

on mouseup
put "pinning,showhidden,showshadow,tilesize,trash-full,version,autohide,largesize,launchanim,"& ¬
"magnification,mineffect,mod-count,orientation" into propList
put replace(propList,comma,"|") into propList
--make item list a regex 'or' expression
trace
put "defaults read com.apple.dock | " after cmd
--get entire plist
put "grep -E '[[propList]]' | " after cmd
-- --grep down to propList
put "perl -pe 's/^[ ]*//' | " after cmd
--strip leading spaces
put "perl -pe 's/^_/r_/' | " after cmd
put "tr -d ` ; " after cmd
--strip quotes 
put "perl -pe 's/ =/; /' | " after cmd
--space = with colon space
put merge(cmd) into cmd
--merge cmd syntax
get shell(cmd)
--execute
ask list  it prompt "Dockprops"
--display result
end mouseup

Comments (0)

You don't have permission to comment on this page.