From 9442cba1583a493fb3dbfcf819d7f945d4ef1f0e Mon Sep 17 00:00:00 2001 From: Menno van Leeuwen Date: Mon, 20 Jan 2025 11:01:26 +0100 Subject: [PATCH] reworked auto-start to support name=command mapping --- bin/actions/auto-start.sh | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/bin/actions/auto-start.sh b/bin/actions/auto-start.sh index ecbdd4e..edb8ee1 100755 --- a/bin/actions/auto-start.sh +++ b/bin/actions/auto-start.sh @@ -1,17 +1,15 @@ #!/usr/bin/env bash +source $HOME/dotfiles/bin/helpers/functions.sh -apps=( - "spotify" - "whatsapp-for-linux" - "telegram-desktop" - "vesktop" - "trayscale" - "1password" - "ulauncher-wrapped --no-window-shadow --hide-window" - "polkit-agent" - "swaync" - "nm-applet" - "blueman-applet" +# 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" + ["trayscale"]="trayscale" + ["1password"]="1password" + ["ulauncher"]="ulauncher-wrapped --no-window-shadow --hide-window" ) # check if screen has any dead sessions @@ -20,18 +18,20 @@ if screen -list | grep -q "Dead"; then fi echo "Starting auto-start applications..." -for app in "${apps[@]}"; do - app_name=$(echo $app | awk '{print $1}') - app_params=$(echo $app | cut -d' ' -f2-) +for app_name in "${!apps[@]}"; do + command="${apps[$app_name]}" + command_binary=$(echo $command | awk '{print $1}') - if [ -x "$(command -v $app_name)" ]; then + if [ -x "$(command -v $command_binary)" ]; then if screen -list | grep -q $app_name; then - echo "$app_name is already running. Skipping..." + printfe "%s\n" "yellow" "$app_name is already running. Skipping..." continue fi - echo "Starting $app_name with parameters $app_params..." - screen -dmS $app_name $app_name $app_params + printfe "%s\n" "green" "Starting $app_name with command: $command..." + screen -dmS $app_name $command sleep 1 fi done + +screen -ls