~alexdavid/dotfiles

ref: 1eaa9658ff9e593c83db56a000afb6c035d08b8c dotfiles/firefox/launch -rwxr-xr-x 1.1 KiB
1eaa9658 — Alex David Replace qutebrowser with firefox again 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env bash

PROFILES_DIR=~/.local/share/firefox-profiles

mkdir -p "$PROFILES_DIR"

URL="$2"

function launchff {
  if [ -d "$1" ]; then
    export MOZ_ENABLE_WAYLAND=1
    firefox-developer-edition --profile "$1" "$URL"
  else
    exec swaynag -m "No such profile '$1'"
  fi
}

SELECTED_PROFILE=$1
if [ -z "$SELECTED_PROFILE" ]; then
  SELECTED_PROFILE=$({
    ls "$PROFILES_DIR"
    echo
    echo New Profile
    echo New Temporary Profile
  } | bemenu -i --prompt "Profile")
fi

if [ "$SELECTED_PROFILE" = "New Profile" ]; then
  NEW_PROFILE_NAME=$(echo | bemenu --prompt "Enter name:" | sed -e 's/^ *\| *$//g')
  [ -z "$NEW_PROFILE_NAME" ] && exit
  ~/.config/firefox/new-profile-gen/generate "$PROFILES_DIR/$NEW_PROFILE_NAME" "$NEW_PROFILE_NAME"
  launchff "$PROFILES_DIR/$NEW_PROFILE_NAME"
elif [ "$SELECTED_PROFILE" = "New Temporary Profile" ]; then
  PROFILE="$(mktemp -d /tmp/firefox.XXXXXXXXXX)"
  ~/.config/firefox/new-profile-gen/generate "$PROFILE" "$PROFILE"
  launchff "$PROFILE"
  rm -rf "$PROFILE"
elif [ -n "$SELECTED_PROFILE" ]; then
  launchff "$PROFILES_DIR/$SELECTED_PROFILE"
fi