-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathgenerate_ssbs.sh
More file actions
executable file
·73 lines (60 loc) · 2.33 KB
/
generate_ssbs.sh
File metadata and controls
executable file
·73 lines (60 loc) · 2.33 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
# Install yq for parsing YAML if not installed
if ! command -v yq &> /dev/null; then
echo "yq not found, installing..."
brew install yq
fi
# Check for ImageMagick and librsvg dependencies
if ! command -v convert &> /dev/null || ! command -v rsvg-convert &> /dev/null; then
echo "ImageMagick or librsvg not found, installing..."
brew install imagemagick librsvg
fi
CONFIG_FILE="ssb_config.yaml"
LAUNCHER_DIR="$HOME/ssb_launchers"
APPLICATIONS_DIR="$HOME/Applications"
# Define a list of random emojis
EMOJI_LIST=("🌐" "📚" "💻" "📱" "🚀" "🧩" "⚙️" "🔍" "🌈" "🔒" "✨" "📝" "📁")
# Create directories if they don't exist
mkdir -p "$LAUNCHER_DIR" "$APPLICATIONS_DIR"
# Loop over each SSB entry in YAML and generate the launcher
yq e '.ssbs[]' "$CONFIG_FILE" | while IFS= read -r line; do
name=$(echo "$line" | yq e '.name' -)
icon=$(echo "$line" | yq e '.icon' -)
icon_emoji=$(echo "$line" | yq e '.icon_emoji' -)
url=$(echo "$line" | yq e '.url' -)
browser=$(echo "$line" | yq e '.browser' -)
profile=$(echo "$line" | yq e '.profile' -)
# Check if an icon path or emoji is specified
if [[ -z "$icon" && -z "$icon_emoji" ]]; then
# Pick a random emoji if none specified
icon_emoji=${EMOJI_LIST[$RANDOM % ${#EMOJI_LIST[@]}]}
fi
# Generate icon from emoji if no icon path is specified
if [[ -z "$icon" ]]; then
icon="$LAUNCHER_DIR/${name}_icon.png"
convert -background none -fill black -font AppleColorEmoji -pointsize 128 label:"$icon_emoji" "$icon"
icon_icns="${icon%.png}.icns"
sips -s format icns "$icon" --out "$icon_icns"
icon="$icon_icns"
fi
# Create the script for launching the profile
SCRIPT_PATH="$LAUNCHER_DIR/${name}_launcher.sh"
cat > "$SCRIPT_PATH" << EOF
#!/bin/bash
if [ "$browser" == "Firefox" ]; then
open -na "$browser" --args -P "$profile" "$url"
else
open -na "$browser" --args --profile-directory="$profile" "$url"
fi
EOF
# Make the launcher executable
chmod +x "$SCRIPT_PATH"
# Create the app wrapper
osacompile -o "$APPLICATIONS_DIR/$name.app" -e "do shell script \"$SCRIPT_PATH\""
# Add icon if specified
if [[ -f "$icon" ]]; then
cp "$icon" "$APPLICATIONS_DIR/$name.app/Contents/Resources/applet.icns"
touch "$APPLICATIONS_DIR/$name.app"
fi
echo "Generated SSB for $name at $APPLICATIONS_DIR/$name.app"
done