mathiasbynens / dotfiles

:wrench: .files, including ~/.macos — sensible hacker defaults for macOS
https://mths.be/dotfiles
MIT License
30.04k stars 8.75k forks source link

Add .dock to setup your macOS dock on a new install #866

Open ryanpavlick opened 5 years ago

ryanpavlick commented 5 years ago

Allows you to easily customize your macOS dock on a new install.

Example:

# WARNING: permanently clears your existing dock
clear_dock

add_app_to_dock "System Preferences"
add_app_to_dock "Activity Monitor"
add_spacer_to_dock
add_app_to_dock "Microsoft Outlook"
add_app_to_dock "Google Chrome"
add_app_to_dock "Microsoft Excel"
add_app_to_dock "Microsoft Word"
add_app_to_dock "Microsoft PowerPoint"
add_app_to_dock "kitty"
add_app_to_dock "Visual Studio Code"
add_app_to_dock "SelfControl"
add_app_to_dock "Skype"
add_spacer_to_dock

# refresh your dock to see the changes
 killall Dock
flyingchipmunk commented 5 years ago

nice, thanks for this, hope it gets merged

ghost commented 5 years ago

This is awesome! Thanks for sharing.

ghost commented 4 years ago

When I install in my macOS, always get errors. Could you help to look at why?

ifort: command line warning #10006: ignoring unknown option '-ffree-line-length-none' ifort: command line warning #10006: ignoring unknown option '-ffree-line-length-none' ifort: command line warning #10006: ignoring unknown option '-fdollar-ok' ifort: command line warning #10006: ignoring unknown option '-fdefault-real-8' ./globe/globe_mod_flux.F90(16): error #5082: Syntax error, found IDENTIFIER 'BALANCE' when expecting one of: ( : % [ . = => Energy balance -----------------------------^ ./globe/globe_mod_flux.F90(23): error #5082: Syntax error, found IDENTIFIER 'BALANCE' when expecting one of: ( : % [ . = => Water balance -----------------------------^ ./globe/globe_mod_flux.F90(37): error #5082: Syntax error, found IDENTIFIER 'BALANCE' when expecting one of: ( : % [ . = => Carbon balance -----------------------------^ ./globe/globe_mod_flux.F90(16): error #6274: This statement must not appear in the specification part of a module. Energy balance ----------------------^ ./globe/globe_mod_flux.F90(19): error #6236: A specification statement cannot appear in the executable section. real,allocatable :: fglobe_RADs_as(:) !< short wave radiation ------^ ./globe/globe_mod_flux.F90(20): error #6236: A specification statement cannot appear in the executable section. real,allocatable :: fglobe_RADl_as(:) !< long wave radiation ------^ ./globe/globe_mod_flux.F90(23): error #6274: This statement must not appear in the specification part of a module. Water balance -----------------------^ ./globe/globe_mod_flux.F90(26): error #6236: A specification statement cannot appear in the executable section. real,allocatable :: fglobe_H2Ol_as(:) !< precipitation ------^ ./globe/globe_mod_flux.F90(27): error #6236: A specification statement cannot appear in the executable section. real,allocatable :: fglobe_H2Os_as(:) !< snowfall ------^ ./globe/globe_mod_flux.F90(28): error #6236: A specification statement cannot appear in the executable section. real,allocatable :: fglobe_H2Ol_sv(:) !< root water uptake ------^ ./globe/globe_mod_flux.F90(29): error #6236: A specification statement cannot appear in the executable section. real,allocatable :: fglobe_H2Ol_sr(:) !< saturation excess flow ------^ ./globe/globe_mod_flux.F90(30): error #6236: A specification statement cannot appear in the executable section. real,allocatable :: fglobe_H2Ol_sb(:) !< soil drainage ------^ ./globe/globe_mod_flux.F90(31): error #6236: A specification statement cannot appear in the executable section. real,allocatable :: fglobe_H2Ol_br(:) !< river discharge ------^ ./globe/globe_mod_flux.F90(32): error #6236: A specification statement cannot appear in the executable section. real,allocatable :: fglobe_H2Og_sa(:) !< bare soil evaporation ------^ ./globe/globe_mod_flux.F90(33): error #6236: A specification statement cannot appear in the executable section. real,allocatable :: fglobe_H2Og_sa_pot(:)!< potential evaporation ------^ ./globe/globe_mod_flux.F90(34): error #6236: A specification statement cannot appear in the executable section. real,allocatable :: fglobe_H2Og_va(:) !< transpiration ------^ ./globe/globe_mod_flux.F90(37): error #6274: This statement must not appear in the specification part of a module. Carbon balance ----------------------^ ./globe/globe_mod_flux.F90(40): error #6236: A specification statement cannot appear in the executable section. real,allocatable :: fglobe_CO2d_as(:) !< CO2 dissolved in rain ------^ ./globe/globe_mod_flux.F90(41): error #6236: A specification statement cannot appear in the executable section. real,allocatable :: fglobe_CO2g_sa(:) !< soil-atmosphere gas exchange ------^ ./globe/globe_mod_flux.F90(43): error #6236: A specification statement cannot appear in the executable section. real,allocatable :: fglobe_CO2g_av(:) !< gross carbon uptake ------^ ./globe/globe_mod_flux.F90(44): error #6236: A specification statement cannot appear in the executable section. real,allocatable :: fglobe_CO2g_va(:) !< aboveground respiration ------^ ./globe/globe_mod_flux.F90(45): error #6236: A specification statement cannot appear in the executable section. real,allocatable :: fglobe_CO2g_vs(:) !< belowground respiration ------^ ./globe/globe_mod_flux.F90(46): error #6236: A specification statement cannot appear in the executable section. real,allocatable :: fglobe_CORG_vs(:) !< litter fall ------^ ./globe/globe_mod_flux.F90(47): error #6236: A specification statement cannot appear in the executable section. real,allocatable :: fglobe_Cco_vv(:) !< NPP ------^ ./globe/globe_mod_flux.F90(49): error #6236: A specification statement cannot appear in the executable section. real,allocatable :: fglobe_CO2d_sr(:) !< dissolved carbon export ------^ ./globe/globe_mod_flux.F90(50): error #6236: A specification statement cannot appear in the executable section. real,allocatable :: fglobe_CO2d_sb(:) !< dissolved carbon flow to base ------^ ./globe/globe_mod_flux.F90(51): error #6236: A specification statement cannot appear in the executable section. real,allocatable :: fglobe_CO2d_br(:) !< dissolved carbon groundwater to river ------^ ./globe/globe_mod_flux.F90(52): error #6236: A specification statement cannot appear in the executable section. real,allocatable :: fglobe_CO2d_sv(:) !< dissolved carbon in root uptake ------^ compilation aborted for ./globe/globe_mod_flux.F90 (code 1) make: *** [globe_mod_flux.o] Error 1

Something went wrong! ✘

saving the output of this script... /Users/paleowind/research/github/JeDi/build/testbuild/makejedi_testbuild.log sed: 1: "/Users/paleowind/resear ...": extra characters at the end of p command

vondiggity commented 4 years ago

Allows you to easily customize your macOS dock on a new install.

Example:

# WARNING: permanently clears your existing dock
clear_dock

add_app_to_dock "System Preferences"
add_app_to_dock "Activity Monitor"
add_spacer_to_dock
add_app_to_dock "Microsoft Outlook"
add_app_to_dock "Google Chrome"
add_app_to_dock "Microsoft Excel"
add_app_to_dock "Microsoft Word"
add_app_to_dock "Microsoft PowerPoint"
add_app_to_dock "kitty"
add_app_to_dock "Visual Studio Code"
add_app_to_dock "SelfControl"
add_app_to_dock "Skype"
add_spacer_to_dock

# refresh your dock to see the changes
 killall Dock

I'm guessing this command works only for the logged in user, and isn't system wide?

blaues0cke commented 4 years ago

@lisf1979 Maybe u used the wrong bash to execute the script?

ghost commented 4 years ago

@blaues0cke Thanks for your explain. But what do you mean wrong bash? and how to check it or change it?

s10wen commented 4 years ago

@rpavlick guessing this requires a dependency? Did a quick search but couldn't find it, please could you let me know? Also, might be worth adding to get installed via brew?

kamui545 commented 4 years ago

@s10wen Looking at the diff I do not see any dependency required, am I missing something? Maybe you're thinking about https://github.com/kcrawford/dockutil? Which is not used here

ryanpavlick commented 4 years ago

Do you realize you are commenting on a pull request for a script that adds that functionality?

https://github.com/mathiasbynens/dotfiles/pull/866/commits/6dd53c003cb286916f9af90072aae2467c41a1a5

On Sun, Oct 20, 2019 at 10:14 AM Dan Stroot notifications@github.com wrote:

Yes, there is clearly a missing dependency. Commands such as this "add_app_to_dock" are not native to macOS.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mathiasbynens/dotfiles/pull/866?email_source=notifications&email_token=AABVI35N6JQMM3J55Q7FYNLQPSGYDA5CNFSM4G3VDN3KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBYO4LI#issuecomment-544271917, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABVI32WIQYHYFA3VXRCN23QPSGYDANCNFSM4G3VDN3A .

dstroot commented 4 years ago

Works fantastic on Mojave, Not so much on Catalina. For some reason it is running much more slowly and picking up xcode stuff:

/System/Applications/Launchpad.app added to the Dock.
/Applications/Google Chrome.app added to the Dock.
/Applications/Safari.app added to the Dock.
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Applications/MobileMail.app added to the Dock.
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Applications/Contacts.app added to the Dock.

add "Xcode.app" to the grep exclusions cleared it up:

app_path=$(${launchservices_path} -dump | grep -o "/.*${app_name}.app" | grep -v -E "Backups|Caches|TimeMachine|Temporary|Xcode.app|/Volumes/${app_name}" | uniq | sort | head -n1)
kamui545 commented 4 years ago

@dsroot I think it would be safer and better for performance to remove (or make optional / another command?) the "searching for app path" feature.

And instead just declare the absolute path of the apps you want to install:

declare -a apps=(
    '/System/Applications/Utilities/Terminal.app'
    '/System/Applications/Music.app'
    '/Applications/Google Chrome.app'
    '/Applications/PhpStorm.app'
    '/System/Applications/System Preferences.app'
);

Note: For those upgrading to Catalina, macOS apps moved to /System/Applications like declared above

dstroot commented 4 years ago

@kamui545 - I am sure your method is faster and clearer. I think the original author above wanted to make it easier on people and was trying to search for the location of the app you wanted to add for you. I hope someone combines your ideas and the point that macOS Catalina moves the apps to /System/Applications so this can be a "Catalina ready" feature.

s10wen commented 4 years ago

Do you realize you are commenting on a pull request for a script that adds that functionality? 6dd53c0

Ahhh, I didn't sorry, I missed that, nice.

In that case maybe move this section to a config file .dock-apps so folks can update as they'd like and away from the functionality? https://github.com/mathiasbynens/dotfiles/pull/866/files#diff-e65ca6f45462e25a6dc7054f9dd43b10R43-R55

Just a thought, nice one though, I've been wanting this a while :)

kamui545 commented 4 years ago

Hey, finally had some time to implement this on my own dotfiles and drop dockutil. I noticed the reset_dock function did not work for me (macOS Catalina), there's one param missing.

Here's the fixed version using defaults delete:

function reset_dock {
    defaults delete com.apple.dock
    killall Dock
}

I also added some features, here's a gist: https://gist.github.com/kamui545/c810eccf6281b33a53e094484247f5e8

Feel free to cherry pick for the PR, in case you're interested : )

dstroot commented 4 years ago

This function works much better on Catalina:

function add_app_to_dock {
    app_name="${1}"
    app_path=""

    # places to look for an application
    declare -a paths=(
    "/System/Applications"
    "/Applications"
    "$HOME/Applications"
    );

    # check the paths for the app
    for path in "${paths[@]}"; do
        app=$(ls "${path}" | grep -o "${app_name}.app" | uniq | sort | head -n1)
        if [[ -n "${app}" ]]; then
            app_path="${path}/${app}"
        fi
    done

    if open -Ra "${app_path}"; then
        echo "Dock: $app_path added to the Dock."

        defaults write com.apple.dock persistent-apps -array-add "<dict>
            <key>tile-data</key>
            <dict>
                <key>file-data</key>
                <dict>
                    <key>_CFURLString</key>
                    <string>${app_path}</string>
                    <key>_CFURLStringType</key>
                    <integer>0</integer>
                </dict>
            </dict>
        </dict>"
    else
        echo "ERROR: Application $1 not found." 1>&2
    fi
}