Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

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

wants to merge 1 commit into from

Conversation

ryanpavlick
Copy link

@ryanpavlick ryanpavlick commented Mar 4, 2019

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
Copy link

nice, thanks for this, hope it gets merged

@ghost
Copy link

ghost commented Apr 11, 2019

This is awesome! Thanks for sharing.

@ghost
Copy link

ghost commented Jul 23, 2019

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
Copy link

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
Copy link

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

@ghost
Copy link

ghost commented Aug 11, 2019

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

@s10wen
Copy link
Contributor

s10wen commented Oct 18, 2019

@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
Copy link
Contributor

@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
Copy link
Author

ryanpavlick commented Oct 20, 2019 via email

@dstroot
Copy link

dstroot commented Oct 20, 2019

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
Copy link
Contributor

kamui545 commented Oct 21, 2019

@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
Copy link

dstroot commented Oct 21, 2019

@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
Copy link
Contributor

s10wen commented Oct 21, 2019

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
Copy link
Contributor

kamui545 commented Oct 24, 2019

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
Copy link

dstroot commented Dec 2, 2019

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
}

@mathiasbynens mathiasbynens changed the base branch from master to main June 16, 2020 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants