From e65154f02b9afea4c6476dedee6d2a4c53b8ada8 Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Tue, 5 Nov 2024 17:37:36 +0000 Subject: [PATCH] Devcontainer support. --- .devcontainer/devcontainer.json | 14 +++ {.gitpod => .devcontainer}/installation.sh | 99 ++++++++++++++++------ .gitpod.yml | 4 +- .gitpod/user.js | 8 -- 4 files changed, 88 insertions(+), 37 deletions(-) create mode 100644 .devcontainer/devcontainer.json rename {.gitpod => .devcontainer}/installation.sh (52%) delete mode 100644 .gitpod/user.js diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..42a6b47 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,14 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu +{ + "name": "Firefoxes", + "image": "mcr.microsoft.com/devcontainers/base:jammy", + "features": { + "ghcr.io/devcontainers/features/desktop-lite:1": { + "password": "noPassword" + } + }, + "forwardPorts": [6080], + "postCreateCommand": "bash .devcontainer/installation.sh", + "remoteUser": "root" +} diff --git a/.gitpod/installation.sh b/.devcontainer/installation.sh similarity index 52% rename from .gitpod/installation.sh rename to .devcontainer/installation.sh index 4a03ce1..14756f7 100755 --- a/.gitpod/installation.sh +++ b/.devcontainer/installation.sh @@ -1,8 +1,53 @@ #! /bin/bash -sudo apt-get remove -y firefox +create_desktop_entry() { + local version="$1" + local path="$2" -mkdir -p ~/.local/share/applications + cat << EOF > "${path}/${version}.desktop" +[Desktop Entry] +Version=1.0 +Name=${version} +GenericName=Web Browser +Exec=/opt/${version}/firefox -P ${version} %u +Icon=/opt/${version}/browser/chrome/icons/default/default128.png +Terminal=false +Type=Application +MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;x-scheme-handler/http;x-scheme-handler/https; +StartupNotify=true +Categories=Network;WebBrowser; +Keywords=web;browser;internet; +EOF +} + +create_user_settings() { + local path="$1" + + cat << EOF > "${path}/user.js" +// Used by Gitpod or a dev env to setup Firefox for UserStyle debugging. +user_pref("toolkit.legacyUserProfileCustomizations.stylesheets", true); +user_pref("browser.compactmode.show", true); +user_pref("browser.toolbars.bookmarks.visibility", "always"); +user_pref("devtools.debugger.remote-enabled", true); +user_pref("devtools.chrome.enabled", true); +user_pref("browser.uidensity", 1); +user_pref("browser.tabs.inTitlebar", 0); +EOF +} + +OP_PATH="${1:-$PWD}" + +mkdir -p $HOME/.local/share/applications +mkdir -p $HOME/Desktop + +# For Fluxbox +FLUXBOX_MENU="$HOME/.fluxbox/menu" +if [[ -f "$FLUXBOX_MENU" ]]; then + echo "Fluxbox detected - prepping menu edits." + TMPFLUXMENU="/tmp/ff_fluxmenu" + > "$TMPFLUXMENU" + echo " [submenu] (Firefox Variants) {}" >> "$TMPFLUXMENU" +fi # In case a prior installation has failed. sudo rm -rf /opt/firefox @@ -10,12 +55,12 @@ sudo rm -rf /opt/firefox declare -A firefox_versions=( ["firefox-regular"]="firefox-latest" ["firefox-esr"]="firefox-esr-latest" - ["firefox-nightly"]="firefox-nightly-latest" - ["firefox-developer"]="firefox-devedition-latest" + ["firefox-nightly"]="firefox-nightly-latest" + ["firefox-developer"]="firefox-devedition-latest" ) for version in "${!firefox_versions[@]}"; do - product=${firefox_versions[$version]} + product=${firefox_versions[$version]} existed=0 echo "" @@ -37,10 +82,10 @@ for version in "${!firefox_versions[@]}"; do fi echo "> sudo tar -xjf \"/opt/${version}.tar.bz2\" -C /opt" - sudo tar -xjf "/opt/${version}.tar.bz2" -C /opt + sudo tar -xjf "/opt/${version}.tar.bz2" -C /opt echo "> sudo mv /opt/firefox \"/opt/${version}\"" - sudo mv /opt/firefox "/opt/${version}" + sudo mv /opt/firefox "/opt/${version}" if [ $existed -eq 0 ]; then echo "> ln -sf \"/opt/${version}/firefox\" \"/usr/local/bin/${version}\"" @@ -52,31 +97,21 @@ for version in "${!firefox_versions[@]}"; do exit_status=$? if [ $exit_status -eq 0 ]; then - DIR="$(find ~/.mozilla/firefox -maxdepth 1 -type d -name "*.${version}")" + DIR="$(find $HOME/.mozilla/firefox -maxdepth 1 -type d -name "*.${version}")" - echo "> cp .gitpod/user.js \"${DIR}\"" - cp .gitpod/user.js "${DIR}" + create_user_settings $DIR - echo "> ln -sf \"${GITPOD_REPO_ROOTS}/IE6/chrome\" \"${DIR}/chrome\"" - ln -sf "${GITPOD_REPO_ROOTS}/IE6/chrome" "${DIR}/chrome" + echo "> ln -sf \"${OP_PATH}/IE6/chrome\" \"${DIR}/chrome\"" + ln -sf "${OP_PATH}/IE6/chrome" "${DIR}/chrome" - cat << EOF > ~/Desktop/${version}.desktop -[Desktop Entry] -Version=1.0 -Name=${version} -GenericName=Web Browser -Exec=/opt/${version}/firefox -P ${version} %u -Icon=/opt/${version}/browser/chrome/icons/default/default128.png -Terminal=false -Type=Application -MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;x-scheme-handler/http;x-scheme-handler/https; -StartupNotify=true -Categories=Network;WebBrowser; -Keywords=web;browser;internet; -EOF + # For Fluxbox + if [[ -f "$FLUXBOX_MENU" ]]; then + echo " [exec] ($version) {/opt/${version}/firefox -P ${version}}" >> "$TMPFLUXMENU" + fi - sudo chmod +x ~/Desktop/${version}.desktop - cp ~/Desktop/${version}.desktop ~/.local/share/applications/${version}.desktop + create_desktop_entry $version $HOME/Desktop + sudo chmod +x $HOME/Desktop/${version}.desktop + cp $HOME/Desktop/${version}.desktop $HOME/.local/share/applications/${version}.desktop else echo "❌ A problem occurred during profile creation. Skipping ${version}..." fi @@ -85,5 +120,13 @@ EOF fi done +if [[ -f "$FLUXBOX_MENU" ]]; then + echo "Editing fluxbox menu." + echo " [end]" >> "$TMPFLUXMENU" + sed -i "/^\[begin\] (\s*Application Menu\s*)/r $TMPFLUXMENU" "$FLUXBOX_MENU" + rm "$TMPFLUXMENU" +fi + echo "" echo "🚀 Script has concluded - Firefox (of various variants) installed!" + diff --git a/.gitpod.yml b/.gitpod.yml index e466893..946dca2 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -1,7 +1,9 @@ image: gitpod/workspace-full-vnc tasks: - - command: bash .gitpod/installation.sh + - command: | + sudo apt-get remove -y firefox + bash .devcontainer/installation.sh ports: - port: 5900 diff --git a/.gitpod/user.js b/.gitpod/user.js deleted file mode 100644 index d553114..0000000 --- a/.gitpod/user.js +++ /dev/null @@ -1,8 +0,0 @@ -// Used by Gitpod or a dev env to setup Firefox for UserStyle debugging. -user_pref("toolkit.legacyUserProfileCustomizations.stylesheets", true); -user_pref("browser.compactmode.show", true); -user_pref("browser.toolbars.bookmarks.visibility", "always"); -user_pref("devtools.debugger.remote-enabled", true); -user_pref("devtools.chrome.enabled", true); -user_pref("browser.uidensity", 1); -user_pref("browser.tabs.inTitlebar", 0); \ No newline at end of file