diff --git a/bin/actions/startup-runner.sh b/bin/actions/startup-runner.sh new file mode 100755 index 0000000..0216454 --- /dev/null +++ b/bin/actions/startup-runner.sh @@ -0,0 +1,2 @@ +#!/bin/sh +x-terminal-emulator -e $HOME/dotfiles/bin/actions/startup.sh $@ diff --git a/bin/actions/startup.sh b/bin/actions/startup.sh index b62cb1d..f92a943 100755 --- a/bin/actions/startup.sh +++ b/bin/actions/startup.sh @@ -11,6 +11,24 @@ countdown() { } run_startup_scripts() { + logo continue + echo "" + local time_of_day + # Time of day (morning, afternoon, evening, night) + case $(date +%H) in + 0[0-9]|1[0-1]) + time_of_day="morning" + ;; + 1[2-7]) + time_of_day="afternoon" + ;; + 1[8-9]|2[0-3]) + time_of_day="evening" + ;; + esac + printfe "%s" "cyan" "Welcome and good $time_of_day $(whoami)!" + echo "" + # Initialize array to hold commands local startup_commands=() @@ -37,10 +55,25 @@ run_startup_scripts() { printfe "%s" "green" "'... (" printfe "%s" "blue" "$command" printfe "%s\n" "green" ")" + + # Check if a screen with the same name already exists, if so log it and don't run the command + if screen -list | grep -q $command_key; then + printfe "%s" "red" " - Screen session already exists: " + printfe "%s" "blue" "$command_key" + printfe "%s\n" "red" "" + continue + fi # Run the command in a new screen session named after the command_key screen -dmS $command_key zsh -c "eval $command" + # Check if command is ok, if not log that it failed + if [ $? -ne 0 ]; then + printfe "%s" "red" " - Command failed: " + printfe "%s" "blue" "$command" + printfe "%s\n" "red" "" + fi + # Wait for the delay between commands sleep $(echo "scale=2; $delay_between_ms / 1000" | bc) done diff --git a/bin/dotf b/bin/dotf index dd2badd..533dce5 100755 --- a/bin/dotf +++ b/bin/dotf @@ -73,8 +73,7 @@ case $1 in secrets $@ ;; "startup") - # Run $HOME/dotfiles/bin/actions/startup.sh $@ in a new terminal window (Use the default terminal emulator x-terminal-emulator) (Ensure the terminal closes after the script is done) - x-terminal-emulator -e $HOME/dotfiles/bin/actions/startup.sh $@ + $HOME/dotfiles/bin/actions/startup-runner.sh $@ ;; "term") $HOME/dotfiles/bin/actions/term.sh $@ diff --git a/bin/helpers/git.sh b/bin/helpers/git.sh old mode 100644 new mode 100755 diff --git a/config/config.yaml b/config/config.yaml index e4357fc..cb4d0d5 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -79,7 +79,7 @@ config: # Commands to run after login startup: - delay: 5 + delay: 1 delay_between_ms: 500 commands: 1password: 1password diff --git a/config/dotf-autostart.desktop b/config/dotf-autostart.desktop old mode 100644 new mode 100755 index 3d499b5..f105073 --- a/config/dotf-autostart.desktop +++ b/config/dotf-autostart.desktop @@ -1,7 +1,7 @@ [Desktop Entry] Type=Application Name=Startup Script -Exec=~/dotfiles/bin/actions/startup.sh +Exec=/home/menno/dotfiles/bin/actions/startup-runner.sh X-GNOME-Autostart-enabled=true NoDisplay=false Comment=Run startup script when logging into Cinnamon