adds brave browser
adds brave browser search engine inject script adds sqlite and sqlitebrowser updates wireguard vpn peers updates dash-to-dock fav apps adds plexamp updates update.sh to show slightly more logging updates auto-start to clear dead screens before starting stuff
This commit is contained in:
132
config/home-manager/packages/workstation/brave-search-engines.sh
Executable file
132
config/home-manager/packages/workstation/brave-search-engines.sh
Executable file
@ -0,0 +1,132 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
BRAVE_DIR="$HOME/.config/BraveSoftware/Brave-Browser/Default"
|
||||
MAX_ATTEMPTS=30 # Maximum number of seconds to wait
|
||||
|
||||
# Function to kill all Brave processes
|
||||
kill_brave() {
|
||||
# Store whether Brave was running
|
||||
if pgrep -x "brave" > /dev/null; then
|
||||
echo "Brave was running, will restart after completion"
|
||||
export BRAVE_WAS_RUNNING=1
|
||||
else
|
||||
export BRAVE_WAS_RUNNING=0
|
||||
fi
|
||||
|
||||
echo "Closing all Brave browser instances..."
|
||||
pkill -x "brave" || true
|
||||
sleep 2 # Give it a moment to clean up
|
||||
|
||||
# Force kill if any processes remain
|
||||
if pgrep -x "brave" > /dev/null; then
|
||||
echo "Force closing remaining Brave processes..."
|
||||
pkill -9 -x "brave" || true
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to check if database is locked
|
||||
is_db_locked() {
|
||||
local db_file="$1"
|
||||
if lsof "$db_file" >/dev/null 2>&1; then
|
||||
return 0 # true, db is locked
|
||||
else
|
||||
return 1 # false, db is not locked
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if profile exists
|
||||
if [ ! -d "$BRAVE_DIR" ]; then
|
||||
echo "Brave profile directory doesn't exist. Please run Brave at least once."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if Web Data exists
|
||||
if [ ! -f "$BRAVE_DIR/Web Data" ]; then
|
||||
echo "Web Data file doesn't exist. Please run Brave at least once."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Kill any running Brave instances
|
||||
kill_brave
|
||||
|
||||
# Wait for database to be unlocked
|
||||
attempts=0
|
||||
while is_db_locked "$BRAVE_DIR/Web Data" && [ $attempts -lt $MAX_ATTEMPTS ]; do
|
||||
echo "Database is locked. Waiting... ($attempts/$MAX_ATTEMPTS)"
|
||||
sleep 1
|
||||
attempts=$((attempts + 1))
|
||||
done
|
||||
|
||||
if is_db_locked "$BRAVE_DIR/Web Data"; then
|
||||
echo "Database is still locked after $MAX_ATTEMPTS seconds. Please ensure Brave is completely closed and try again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Setting up search engines..."
|
||||
|
||||
# Create temporary file for SQL commands
|
||||
SQLCOMMANDS=$(mktemp)
|
||||
|
||||
cat > $SQLCOMMANDS << 'ENDSQL'
|
||||
DELETE FROM keywords WHERE keyword NOT IN ('@bookmarks', '@history');
|
||||
|
||||
INSERT INTO keywords (
|
||||
short_name, keyword, favicon_url, url, safe_for_autoreplace,
|
||||
date_created, usage_count, input_encodings, suggest_url, prepopulate_id,
|
||||
sync_guid, alternate_urls, last_visited, is_active
|
||||
) VALUES
|
||||
(
|
||||
'Brave', ':br',
|
||||
'https://cdn.search.brave.com/serp/v2/_app/immutable/assets/favicon.acxxetWH.ico',
|
||||
'https://search.brave.com/search?q={searchTerms}&source=desktop',
|
||||
1, 0, 0, 'UTF-8',
|
||||
'https://search.brave.com/api/suggest?q={searchTerms}&rich=true&source=desktop',
|
||||
550, '485bf7d3-0215-45af-87dc-538868000550', '[]', 13376052494948729, 0
|
||||
),
|
||||
(
|
||||
'Google', ':g',
|
||||
'https://www.google.com/images/branding/product/ico/googleg_alldp.ico',
|
||||
'{google:baseURL}search?q={searchTerms}&{google:RLZ}{google:originalQueryForSuggestion}{google:assistedQueryStats}{google:searchFieldtrialParameter}{google:language}{google:prefetchSource}{google:searchClient}{google:sourceId}{google:contextualSearchVersion}ie={inputEncoding}',
|
||||
1, 0, 0, 'UTF-8',
|
||||
'{google:baseSuggestURL}search?{google:searchFieldtrialParameter}client={google:suggestClient}&gs_ri={google:suggestRid}&xssi=t&q={searchTerms}&{google:inputType}{google:omniboxFocusType}{google:cursorPosition}{google:currentPageUrl}{google:pageClassification}{google:clientCacheTimeToLive}{google:searchVersion}{google:sessionToken}{google:prefetchQuery}sugkey={google:suggestAPIKeyParameter}',
|
||||
1, '485bf7d3-0215-45af-87dc-538868000001', '[]', 0, 0
|
||||
),
|
||||
(
|
||||
'DuckDuckGo', ':d',
|
||||
'https://duckduckgo.com/favicon.ico',
|
||||
'https://duckduckgo.com/?q={searchTerms}&t=brave',
|
||||
1, 0, 0, 'UTF-8',
|
||||
'https://ac.duckduckgo.com/ac/?q={searchTerms}&type=list',
|
||||
501, '485bf7d3-0215-45af-87dc-538868000501', '[]', 0, 0
|
||||
),
|
||||
(
|
||||
'NixOS', 'nix',
|
||||
'https://search.nixos.org/favicon.png',
|
||||
'https://search.nixos.org/packages?query={searchTerms}',
|
||||
1, 13376052510404586, 1, '',
|
||||
'',
|
||||
0, 'bea7b4cd-8693-40d8-8bd0-7f59e0f0eb8d', '[]', 13376052522458505, 1
|
||||
),
|
||||
(
|
||||
'GoLink', 'go',
|
||||
'https://tailscale.com/favicon.ico',
|
||||
'http://go/{searchTerms}',
|
||||
1, 13376052510404586, 1, '',
|
||||
'',
|
||||
0, 'bef7b3cd-8693-40d8-8bd0-5f59e0f0eb8d', '[]', 13376052522458505, 1
|
||||
);
|
||||
ENDSQL
|
||||
|
||||
# Execute SQL commands
|
||||
sqlite3 "$BRAVE_DIR/Web Data" < $SQLCOMMANDS
|
||||
|
||||
# Cleanup
|
||||
rm $SQLCOMMANDS
|
||||
|
||||
echo "Search engines setup completed successfully!"
|
||||
|
||||
# Restart Brave if it was running before
|
||||
if [ "$BRAVE_WAS_RUNNING" = "1" ]; then
|
||||
echo "Restarting Brave..."
|
||||
brave &> /dev/null &
|
||||
fi
|
38
config/home-manager/packages/workstation/brave.nix
Normal file
38
config/home-manager/packages/workstation/brave.nix
Normal file
@ -0,0 +1,38 @@
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
{
|
||||
# Copy search engine configuration script
|
||||
home.file.".local/bin/brave-search-engines.sh" = {
|
||||
source = ./brave-search-engines.sh;
|
||||
executable = true;
|
||||
};
|
||||
|
||||
# Run search engine configuration script
|
||||
home.activation = {
|
||||
setBraveSearchEngines = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||
PATH="${pkgs.procps}/bin:${pkgs.sqlite}/bin:$PATH" $HOME/.local/bin/brave-search-engines.sh
|
||||
'';
|
||||
};
|
||||
|
||||
programs.chromium = {
|
||||
enable = true;
|
||||
package = pkgs.brave;
|
||||
extensions = [
|
||||
{ id = "cjpalhdlnbpafiamejdnhcphjbkeiagm"; } # ublock origin
|
||||
{ id = "aeblfdkhhhdcdjpifhhbdiojplfjncoa"; } # 1password
|
||||
{ id = "oldceeleldhonbafppcapldpdifcinji"; } # language tool
|
||||
{ id = "mnjggcdmjocbbbhaepdhchncahnbgone"; } # sponsor block
|
||||
{ id = "gebbhagfogifgggkldgodflihgfeippi"; } # return youtube dislike
|
||||
{ id = "neebplgakaahbhdphmkckjjcegoiijjo"; } # keepa
|
||||
{ id = "dnhpnfgdlenaccegplpojghhmaamnnfp"; } # augmented steam
|
||||
{ id = "fihnjjcciajhdojfnbdddfaoknhalnja"; } # I don't care about cookies
|
||||
{ id = "gphhapmejobijbbhgpjhcjognlahblep"; } # gnome shell integration
|
||||
{ id = "eadndfjplgieldjbigjakmdgkmoaaaoc"; } # xdebug helper
|
||||
];
|
||||
commandLineArgs = [ ];
|
||||
};
|
||||
}
|
@ -1,7 +1,10 @@
|
||||
{ ... }:
|
||||
|
||||
let
|
||||
files = builtins.removeAttrs (builtins.readDir ./.) [ "default.nix" ];
|
||||
files = builtins.removeAttrs (builtins.readDir ./.) [
|
||||
"default.nix"
|
||||
"brave-search-engines.sh"
|
||||
];
|
||||
|
||||
# Import all other .nix files as modules
|
||||
moduleFiles = builtins.map (fname: ./. + "/${fname}") (builtins.attrNames files);
|
||||
|
@ -13,6 +13,7 @@
|
||||
gnome-frog # OCR tool
|
||||
gnome.gnome-boxes # Virtual machine manager
|
||||
deja-dup # Backup tool
|
||||
sqlitebrowser # SQLite database manager
|
||||
|
||||
## Chat Apps
|
||||
telegram-desktop
|
||||
|
@ -40,10 +40,10 @@
|
||||
};
|
||||
|
||||
# Pinned apps
|
||||
# add more by listing them with `gsettings list-recursively | grep favorite-apps`
|
||||
# add more by listing them with `gsettings list-recursively | grep favorite-apps | sed "s/,//g; s/'/\"/g"` then copy pasting the output here
|
||||
"org/gnome/shell" = {
|
||||
favorite-apps = [
|
||||
"io.github.zen_browser.zen.desktop"
|
||||
"brave-browser.desktop"
|
||||
"code.desktop"
|
||||
"org.telegram.desktop.desktop"
|
||||
"spotify.desktop"
|
||||
|
@ -4,11 +4,11 @@
|
||||
xdg.mimeApps = {
|
||||
enable = true;
|
||||
defaultApplications = {
|
||||
# Zen Browser
|
||||
"application/xhtml+xml" = [ "io.github.zen_browser.zen.desktop" ];
|
||||
"text/html" = [ "io.github.zen_browser.zen.desktop" ];
|
||||
"x-scheme-handler/http" = [ "io.github.zen_browser.zen.desktop" ];
|
||||
"x-scheme-handler/https" = [ "io.github.zen_browser.zen.desktop" ];
|
||||
# Brave Browser
|
||||
"application/xhtml+xml" = [ "brave-browser.desktop" ];
|
||||
"text/html" = [ "brave-browser.desktop" ];
|
||||
"x-scheme-handler/http" = [ "brave-browser.desktop" ];
|
||||
"x-scheme-handler/https" = [ "brave-browser.desktop" ];
|
||||
|
||||
# Geary
|
||||
"x-scheme-handler/mailto" = [ "org.gnome.Geary.desktop" ];
|
||||
|
@ -12,6 +12,7 @@
|
||||
user-themes
|
||||
weather-oclock
|
||||
native-window-placement
|
||||
kimpanel
|
||||
]
|
||||
++ (with pkgs-unstable.gnomeExtensions; [
|
||||
tiling-shell
|
||||
@ -55,6 +56,7 @@
|
||||
"org/gnome/shell" = {
|
||||
disable-user-extensions = false;
|
||||
enabled-extensions = [
|
||||
"kimpanel@kde.org"
|
||||
"lilypad@shendrew.github.io"
|
||||
"tilingshell@ferrarodomenico.com"
|
||||
"gsconnect@andyholmes.github.io"
|
||||
@ -94,6 +96,8 @@
|
||||
|
||||
# Configure dash-to-dock
|
||||
"org/gnome/shell/extensions/dash-to-dock" = {
|
||||
pressure-threshold = 250;
|
||||
require-pressure-to-show = false;
|
||||
apply-custom-theme = false;
|
||||
apply-glossy-effect = false;
|
||||
autohide-in-fullscreen = true;
|
||||
|
Reference in New Issue
Block a user