From b0168f8ace960b35be1123bc648630ed940faea8 Mon Sep 17 00:00:00 2001 From: randomuser Date: Sat, 2 Jul 2022 16:30:27 -0500 Subject: [PATCH] add automagic firefox configuration --- .gitignore | 1 + Makefile | 5 +++- firefox_setup | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 firefox_setup diff --git a/.gitignore b/.gitignore index c865d65..4fb8a57 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .environment +.firefox_env bash/hist nvim/.netrwhist bash/bash diff --git a/Makefile b/Makefile index f0b6b1b..6c6ed34 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,8 @@ LOCATION="$(HOME)/.config" DATA="$(HOME)/.local/share" -install_local: install_bspwm install_nvim install_sx install_sxhkd install_zathura install_simplestatus install_bash install_ssh install_git install_tridactyl install_htop install_python +install_local: install_bspwm install_nvim install_sx install_sxhkd install_zathura install_simplestatus install_bash install_ssh install_git install_tridactyl install_htop install_python .firefox_env install: .environment + install_bspwm: ln -sf $(CURDIR)/bspwm $(LOCATION)/bspwm install_nvim: @@ -28,3 +29,5 @@ install_python: ln -sf $(CURDIR)/python $(LOCATION)/python .environment: sh environ +.firefox_env: + sh firefox_setup diff --git a/firefox_setup b/firefox_setup new file mode 100644 index 0000000..0d9dac8 --- /dev/null +++ b/firefox_setup @@ -0,0 +1,67 @@ +#!/bin/sh +verb=0 + +# hooboy this is going to be complicated +# strap in + +get_xpi_for_ext() { + # $1 -- extension name in the store url + # $2 -- download location + + search_for="$(printf %s "$1" | sed 's/-/_/g')" + + final_url=$(curl -s "https://addons.mozilla.org/en-US/firefox/addon/$1/" | + sed 's|\u002F|/|g' | + grep -o "https://addons.mozilla.org/firefox/downloads/file/[[:digit:]]*/"${search_for}"-.[0-9\.]*.xpi") + + [ "$verb" -eq 0 ] && printf "downloaded extension %s\n" "$final_url" + + curl -s "$final_url" -o "$2" +} + +get_xpi_for_ext "umatrix" "firefox/umatrix.xpi" +get_xpi_for_ext "tridactyl-vim" "firefox/tridactyl.xpi" +get_xpi_for_ext "gruvbox-dark" "firefox/gruvbox.xpi" + +# generate the firefox profile directory +# assumes you have the randomuser/utils repo installed +# if not, maybe do that + +[ "$verb" -eq 0 ] && printf "opening firefox, don't focus away\n" +fire & +sleep 10 + +xdotool key ctrl+t +xdotool key ctrl+l +xdotool type "https://example.com" +xdotool key Return +sleep 3 +for i in $(shuf -i 0-5 | tr '\n' ' '); do + xdotool key 'ctrl+w' +done + +cd ~/.local/share/firefox/.mozilla/firefox +cd "$(ls | grep 'default-esr$')" + +pwd + +git clone https://github.com/arkenfox/user.js gituser.js +sed -i "18d;19i cd $(pwd)" gituser.js/prefsCleaner.sh +HOME="/home/usr/.local/share/firefox/" bash gituser.js/prefsCleaner.sh +HOME="/home/usr/.local/share/firefox/" bash gituser.js/updater.sh -l + +cd /home/usr/git/dot/firefox +printf "Please install all the extensions, then close all windows in the browser.\n" +fire https://example.com umatrix.xpi tridactyl.xpi gruvbox.xpi + +curl -fsSl https://raw.githubusercontent.com/tridactyl/native_messenger/master/installers/install.sh -o /tmp/trinativeinstall.sh && HOME="/home/usr/.local/share/firefox" sh /tmp/trinativeinstall.sh 1.22.1 + +fire & +sleep 5 +xdotool key ctrl+l +xdotool type "https://example.com" +xdotool key Return + +# we're done, finally. +# touch a hidden file so the makefile knows we're done +touch .firefox_env