├── .configure.sh ├── LICENSE ├── README.md ├── colors.sh ├── fr.42.lyon.loginscript.users.plist ├── libsession.sh └── main.sh /.configure.sh: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ############################################################# 4 | # # 5 | # Author: Louise Pieri: cpieri@student.42.fr (aka delay) # 6 | # # 7 | ############################################################# 8 | 9 | source colors.sh 10 | 11 | clean() 12 | { 13 | echo "${RED}Clean of the old repo${NONE}" 14 | rm -rf $PermanatePath 15 | rm -rf $LaunchAgentsPath/$LabelName 16 | } 17 | 18 | setup_dir() 19 | { 20 | echo "${YELLOW}Move to the folder home${NONE}" 21 | cd $HOME 22 | echo "${BLUE}Create .scripts_${LOGNAME} folder in the home${NONE}" 23 | mkdir $PermanatePath 24 | } 25 | 26 | copy_files() 27 | { 28 | IncludeColor="${PermanatePath}/colors.sh" 29 | IncludeLib="${PermanatePath}/libsession.sh" 30 | 31 | echo "${CYAN}Copy ${MAGENTA}colors.sh${NONE}${CYAN} file in the permanate folder${NONE}" 32 | cp $InitialPath/colors.sh $PermanatePath/colors.sh 33 | echo "${CYAN}Copy ${MAGENTA}libsession.sh${NONE}${CYAN} file in the permanate folder${NONE}" 34 | cp $InitialPath/libsession.sh $PermanatePath/libsession.sh 35 | sed -e "s/colors.sh/${IncludeColor//\//\/}/g" -i '.bak' $PermanatePath/libsession.sh 36 | rm $PermanatePath/libsession.sh.bak 37 | echo "${CYAN}Copy ${MAGENTA}main.sh${NONE}${CYAN} file in the permanate folder${NONE}" 38 | cp $InitialPath/main.sh $PermanatePath/main.sh 39 | sed -e "s/libsession.sh/${IncludeLib//\//\/}/g" -i '.bak' $PermanatePath/main.sh 40 | rm $PermanatePath/main.sh.bak 41 | echo "${CYAN}Copy ${MAGENTA}${LabelName}${NONE}${CYAN} file in the LaunchAgents folder${NONE}" 42 | cp $InitialPath/fr.42.lyon.loginscript.users.plist $LaunchAgentsPath/$LabelName 43 | chmod -R +x $PermanatePath 44 | } 45 | 46 | configure_plist() 47 | { 48 | echo "${CYAN}Replace MAIN_PATH in ${MAGENTA}${LabelName}${NONE}${CYAN} file${NONE}" 49 | sed -e "s/MAIN_PATH/${MainPath//\//\/}/g" -i '.bak' $LaunchAgentsPath/$LabelName 50 | rm $LaunchAgentsPath/$LabelName.bak 51 | echo "${CYAN}Replace LABEL_NAME in ${MAGENTA}${LabelName}${NONE}${CYAN} file${NONE}" 52 | sed -e "s/LABEL_NAME/${LabelName}/g" -i '.bak' $LaunchAgentsPath/$LabelName 53 | rm $LaunchAgentsPath/$LabelName.bak 54 | echo "${CYAN}Load ${MAGENTA}${LabelName}${NONE}${CYAN} file with launchctl${NONE}" 55 | launchctl load $LaunchAgentsPath/$LabelName 56 | } 57 | 58 | main() 59 | { 60 | InitialPath=$(pwd) 61 | PermanatePath="${HOME}/.scripts_${LOGNAME}" 62 | LaunchAgentsPath="${HOME}/Library/LaunchAgents" 63 | MainPath="${HOME}/.scripts_${LOGNAME}/main.sh" 64 | LabelName="fr.42.lyon.loginscript.${LOGNAME}.plist" 65 | 66 | echo "${PINK}### Starting the configuration ###${NONE}" 67 | clean 68 | setup_dir 69 | copy_files 70 | configure_plist 71 | echo "${RED}Clean of the configuration repo${NONE}" 72 | rm -rf $InitialPath 73 | zsh -i; cd; 74 | echo "${GREEN}The configuration is complete!${NONE}" 75 | } 76 | 77 | main 78 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Louise Pieri 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Scripts for configure your session @42 2 | 3 | 4 |

5 | CodeFactor 6 |

7 | 8 | --- 9 | 10 | Do you find it painful to reset all your preferences every time you change computers? 11 | 12 | That's why I created this directory too. In this directory you will find a set of functions to change your preferences on Macos. 13 | 14 | ## How does it work? 15 | 16 | ### It's very simple ! 17 | 18 | Clone this repository and open the `main.sh` file. 19 | 20 | In the `main.sh` file, write your `main`. 21 | 22 | For exemple: 23 | 24 | ```sh 25 | source libsession.sh #include the library 26 | 27 | main() 28 | { 29 | DockApplications=("App1" "App2" "App3") # All the applications I want in my dock 30 | MenuBarIcons=("Bluetooth" "Keychain") # All the menus I want in my menu bar 31 | 32 | configure_dock buttom 0 # Calling function configure_dock for set my dock in the buttom without the autohide 33 | configure_wallpaper "\"${HOME}/your/path/picture.jpg\"" # Calling function configure_wallpaper for change my wallpaper 34 | configure_screensaver 0 0 # Calling function configure_screensaver for require my password on my screensaver without delay 35 | configure_hotcorners tr 5 # Calling function configure_hotcorners for add one hot corners 36 | configure_keyrepeat # Calling function configure_keyrepeat set the keyrepeat at the minimum delay 37 | configure_menubar # Calling function configure_menubar for add in my menu bar all MenuBarIcons 38 | configure_mousespeed 5 # Calling function configure_mousespeed to set the mousespeed to 5 39 | configure_volume 50 0 # Calling function configure_volume to set the ouput volume at 50% and disable alert volume 40 | } 41 | 42 | main 43 | ``` 44 | 45 | Just launch the command `sh .configure.sh` ! Logout and Re-Login and it's finish :) 46 | 47 | ## Contributors 48 | 49 | [Louise Pieri](https://github.com/lpieri) 50 | 51 | [leonardogb](https://github.com/leonardogb) 52 | 53 | [knona](https://github.com/knona) 54 | 55 | ## I want to contribute to the project! But how? 56 | - Fork this repository 57 | - Clone your repository forked 58 | - Contribute 59 | - Push 60 | - Create a pull request in this repository 61 | - Wait the merged ! 62 | - Be happy 63 | -------------------------------------------------------------------------------- /colors.sh: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ###### 4 | # Author: Louise Pieri: cpieri@student.42.fr (aka delay) 5 | ###### 6 | 7 | NONE="\033[0m" 8 | RED="\033[31m" 9 | GREEN="\033[32m" 10 | YELLOW="\033[33m" 11 | BLUE="\033[34m" 12 | MAGENTA="\033[35m" 13 | CYAN="\033[36m" 14 | PINK="\033[38;5;206m" -------------------------------------------------------------------------------- /fr.42.lyon.loginscript.users.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Label 6 | LABEL_NAME 7 | ProgramArguments 8 | 9 | MAIN_PATH 10 | 11 | RunAtLoad 12 | 13 | 14 | -------------------------------------------------------------------------------- /libsession.sh: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ############################################################# 4 | # # 5 | # Author: Louise Pieri: cpieri@student.42.fr (aka delay) # 6 | # # 7 | ############################################################# 8 | 9 | source colors.sh 10 | 11 | ###### 12 | # Function configure_dock 13 | # This function takes 2 arguments 14 | # @argument OrientationDock 3 options: left, buttom, right !Required 15 | # @argument AutoHideDock 2 options: 0 (for false), 1 (for true) !Required 16 | # @argument DockApplications takes array formated like this: ("ApplicatioName1" "ApplicationName2" "ApplicationName3") !Required 17 | ###### 18 | configure_dock() 19 | { 20 | OrientationDock=$1; 21 | AutoHideDock=$2; 22 | 23 | echo "\n${PINK}### configure_dock function ###${NONE}"; 24 | echo "${BLUE}Setup Orientation of dock${NONE}" 25 | defaults write com.apple.dock orientation $OrientationDock; 26 | echo "${BLUE}Setup AutoHide of dock${NONE}" 27 | defaults write com.apple.Dock autohide -int $AutoHideDock; 28 | echo "${RED}Clean all application save in the dock${NONE}" 29 | defaults write com.apple.dock persistent-apps "()"; 30 | for i in "${DockApplications[@]}"; do 31 | echo "${CYAN}Application add to the dock:${NONE}${MAGENTA} ${i}${NONE}"; 32 | defaults write com.apple.dock persistent-apps -array-add "tile-datafile-data_CFURLString/Applications/${i}.app_CFURLStringType0"; 33 | done 34 | echo "${YELLOW}Restart the Dock${NONE}" 35 | killall Dock; 36 | echo "${GREEN}Configuration of Dock done${NONE}" 37 | } 38 | 39 | ###### 40 | # Function configure_wallpaper 41 | # This function takes 1 argument 42 | # @argument WallpaperPath in format: "\"$HOME/your/path/picture\"" !Required 43 | ###### 44 | configure_wallpaper() 45 | { 46 | WallpaperPath=$1; 47 | 48 | echo "\n${PINK}### configure_wallpaper function ###${NONE}"; 49 | echo "${BLUE}Set your wallpaper${NONE}"; 50 | osascript -e "tell application \"Finder\" to set desktop picture to POSIX file ${WallpaperPath}"; 51 | echo "${GREEN}Configuration of your wallpaper done${NONE}" 52 | } 53 | 54 | ###### 55 | # Function configure_screensaver 56 | # This function takes 2 arguments 57 | # @argument PasswordActive 2 options: 0 (for false), 1 (for true) !Required 58 | # @argument PasswordDelay in seconde !Required 59 | ###### 60 | configure_screensaver() 61 | { 62 | PasswordActive=$1; 63 | PasswordDelay=$2; 64 | 65 | echo "\n${PINK}### configure_screensaver function ###${NONE}"; 66 | echo "${BLUE}Set your screen saver setting${NONE}"; 67 | defaults write com.apple.screensaver askForPassword -int $PasswordActive; 68 | defaults write com.apple.screensaver askForPasswordDelay -int $PasswordDelay; 69 | echo "${GREEN}Configuration of your screen saver setting done${NONE}" 70 | } 71 | 72 | ###### 73 | # Function configure_hotcorners 74 | # configure_hotcorners set only one corner 75 | # This function takes 2 arguments 76 | # @argument Corner 4 options: tl (for Top Left Corner), tr (for Top Right Corner), bl (for Buttom Left Corner), br (for Buttom Right Corner) !Required 77 | # @argument SortCut options: !Required 78 | # - 5 (for Start Screen Saver) 79 | # - 6 (for Disable Screen Saver) 80 | # - 2 (for Mission Control) 81 | # - 3 (for Application Windows) 82 | # - 4 (for Desktop) 83 | # - 7 (for Dashboard) 84 | # - 12 (for Notification Center) 85 | # - 11 (for Launchpad) 86 | # - 10 (for Put Display to Sleep) 87 | # - 1 (for Nothing) 88 | ###### 89 | configure_hotcorners() 90 | { 91 | Corner=$1 92 | SortCut=$2 93 | if [ $SortCut -eq 1 ] 94 | then 95 | Modifier=1048576 96 | else 97 | Modifier=0 98 | fi 99 | 100 | echo "\n${PINK}### configure_hotcorners function ###${NONE}"; 101 | echo "${BLUE}Set your Sortcut ${Corner} Corner setting${NONE}"; 102 | defaults write com.apple.dock "wvous-${Corner}-corner" -int $SortCut; 103 | defaults write com.apple.dock "wvous-${Corner}-modifier" -int $Modifier; 104 | echo "${YELLOW}Restart the Dock${NONE}" 105 | killall Dock; 106 | echo "${GREEN}Configuration of Hot Corners done${NONE}" 107 | } 108 | 109 | ###### 110 | # Function configure_scrolldirection 111 | # This function takes 1 argument 112 | # @argument Direction 2 options: NO (for false), YES (for true) !Required 113 | ###### 114 | configure_scrolldirection() 115 | { 116 | Direction=$1 117 | 118 | echo "\n${PINK}### configure_scrolldirection function ###${NONE}"; 119 | echo "${BLUE}Set your scroll direction${NONE}"; 120 | defaults write -g com.apple.swipescrolldirection -bool $Direction 121 | echo "${GREEN}Configuration of Scroll Direction done${NONE}" 122 | } 123 | 124 | ###### 125 | # Function configure_keyrepeat 126 | # This function takes 0 argument 127 | # configure_keyrepeat set at minimum all keyrepeat 128 | ###### 129 | configure_keyrepeat() 130 | { 131 | Direction=$1 132 | 133 | echo "\n${PINK}### configure_keyrepeat function ###${NONE}"; 134 | echo "${BLUE}Set at minimun value the keyrepeat${NONE}"; 135 | defaults write -g InitialKeyRepeat -int 15 136 | defaults write -g KeyRepeat -int 2 137 | echo "${GREEN}Configuration of KeyRepeat done${NONE}" 138 | } 139 | 140 | ###### 141 | # Function configure_menubar() 142 | # This function takes 0 argument 143 | # MenuBarIcons takes array formated like this: ("Bluetooth" "Keychain" "Clock") !Required 144 | ###### 145 | configure_menubar() 146 | { 147 | echo "\n${PINK}### show_icons_in_menu_bar function ###${NONE}"; 148 | 149 | for i in "${MenuBarIcons[@]}"; do 150 | echo "${CYAN}Icon add to the menu bar:${NONE}${MAGENTA} ${i}${NONE}"; 151 | if [ "$i" = "Keychain" ] 152 | then 153 | PathMenu="/Applications/Utilities/Keychain Access.app/Contents/Resources/Keychain.menu" 154 | else 155 | PathMenu="/System/Library/CoreServices/Menu Extras/${i}.menu" 156 | fi 157 | defaults write com.apple.systemuiserver menuExtras -array-add "${PathMenu}" 158 | done 159 | 160 | echo "${YELLOW}Restart the menu-bar${NONE}" 161 | killall SystemUIServer 162 | echo "${GREEN}Configuration of MenuBar done${NONE}" 163 | } 164 | 165 | ###### 166 | # Function configure_mousespeed() 167 | # This function takes 1 argument 168 | # @argument Speed take an int between 1(low) and 10(fast) 169 | # For now you have to logout/login to changes take effect 170 | ###### 171 | configure_mousespeed() 172 | { 173 | Speed=$1 174 | 175 | case $Speed in 176 | 1) Speed=0 ;; 177 | 2) Speed=0.125 ;; 178 | 3) Speed=0.5 ;; 179 | 4) Speed=0.6875 ;; 180 | 5) Speed=0.875 ;; 181 | 6) Speed=1 ;; 182 | 7) Speed=1.5 ;; 183 | 8) Speed=2 ;; 184 | 9) Speed=2.5 ;; 185 | 10) Speed=3 ;; 186 | *) Speed=1 ;; 187 | esac 188 | 189 | echo "\n${PINK}### configure_mousespeed function ###${NONE}"; 190 | echo "${BLUE}Set your mousespeed $Speed ${NONE}"; 191 | defaults write -g com.apple.mouse.scaling $Speed 192 | echo "${GREEN}Configuration of MouseSpeed done${NONE}" 193 | } 194 | 195 | ##### 196 | # Function configure_volume() 197 | # This function takes 2 arguments 198 | # @argument Output take an int, it represents the percentage of the output volume 199 | # @argument Alert take an int, 0 or 1. Disable or enable the alert volume 200 | ###### 201 | configure_volume() 202 | { 203 | Output=$1 204 | Alert=$2 205 | 206 | echo "\n${PINK}### configure_volume function ###${NONE}"; 207 | echo "${BLUE}Set your volume to $Output %${NONE}"; 208 | osascript -e "set volume output volume $Output" 209 | 210 | if [ $Alert -eq 0 ] 211 | then 212 | echo "${BLUE}Disable alert volume${NONE}"; 213 | #disable alert volume 214 | defaults write -g com.apple.sound.beep.volume 0 215 | #disable user interface sound effects 216 | defaults write -g com.apple.sound.uiaudio.enabled 0 217 | #disable feedback sound when volume is changed 218 | defaults write -g com.apple.sound.beep.feedback 0 219 | fi 220 | 221 | echo "${GREEN}Configuration of Volume done${NONE}" 222 | } -------------------------------------------------------------------------------- /main.sh: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | ###### 4 | # Author: Louise Pieri: cpieri@student.42.fr (aka delay) 5 | ###### 6 | 7 | source libsession.sh 8 | 9 | main() 10 | { 11 | MenuBarIcons=("Bluetooth" "Keychain") 12 | 13 | configure_menubar 14 | } 15 | 16 | main --------------------------------------------------------------------------------