Advertisement
plirof2

default search engine in Google Chrome

Mar 3rd, 2024
876
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Here is a script that you can use to set DuckDuckGo as the default search engine in Google Chrome on Linux using the command line:
  2.  
  3.  
  4. #!/bin/bash
  5.  
  6. # Path to the Chrome preferences file
  7. PREFS_FILE="$HOME/.config/google-chrome/Default/Preferences"
  8.  
  9. # Search engine settings to add to the Chrome preferences
  10. SEARCH_ENGINE='{"default_search_provider":{"enabled":true,"encodings":{"query":"UTF-8","search_url":"UTF-8"},"favicon_url":"https://duckduckgo.com/favicon.ico","id":"1","image_url":"https://duckduckgo.com/assets/logo.icon.svg","image_url_post_params":"","instant_url":"","keyword":"duckduckgo.com","name":"DuckDuckGo","search_url":"https://duckduckgo.com/?q={searchTerms}","suggest_url":""}}'
  11.  
  12. # Check if the Chrome preferences file exists
  13. if [ ! -f "$PREFS_FILE" ]; then
  14.   echo "Error: Chrome preferences file not found"
  15.   exit 1
  16. fi
  17.  
  18. # Update the Chrome preferences file with DuckDuckGo as the default search engine
  19. sed -i 's%"default_search_provider":{[^}]*}%'$SEARCH_ENGINE'%' "$PREFS_FILE"
  20.  
  21. echo "Success: DuckDuckGo set as the default search engine in Google Chrome"
  22. Save this script to a file, for example, set_default_search_engine.sh, make it executable with chmod +x set_default_search_engine.sh, and run it in the terminal. This script will update the Chrome preferences file with DuckDuckGo as the default search engine.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement