dotfiles/bin/actions/auto-start.sh

38 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
source $HOME/dotfiles/bin/helpers/functions.sh
# Define associative array with app_name => command mapping
declare -A apps=(
["spotify"]="flatpak run com.spotify.Client"
["whatsapp"]="whatsapp-for-linux"
["telegram"]="flatpak run io.github.kukuruzka165.materialgram"
["discord"]="flatpak run com.discordapp.Discord"
["ktailctl"]="flatpak run org.fkoehler.KTailctl"
["1password"]="1password"
["ulauncher"]="ulauncher-wrapped --no-window-shadow --hide-window"
)
# check if screen has any dead sessions
if screen -list | grep -q "Dead"; then
screen -wipe
fi
echo "Starting auto-start applications..."
for app_name in "${!apps[@]}"; do
command="${apps[$app_name]}"
command_binary=$(echo $command | awk '{print $1}')
if [ -x "$(command -v $command_binary)" ]; then
if screen -list | grep -q $app_name; then
printfe "%s\n" "yellow" "$app_name is already running. Skipping..."
continue
fi
printfe "%s\n" "green" "Starting $app_name with command: $command..."
screen -dmS $app_name $command
sleep 1
fi
done
screen -ls