I'm trying to run the following script at startup. I am able to see the notification only when I execute the script from the terminal, or when I run it as a program. So the issue is basically when run by the Startup Manager.
Script:
#!/bin/bash
Error log file
ERROR_LOG_FILE="$HOME/onedrive_mount_error_log.txt"
OUTPUT_LOG_FILE="$HOME/script_output_log.txt"
Redirect stdout and stderr to OUTPUT_LOG_FILE
exec > "$OUTPUT_LOG_FILE" 2>&1
Check if rclone is installed
if ! command -v rclone &> /dev/null; then
echo "rclone not found. Exiting script."
exit 1
fi
Mount OneDrive using rclone
rclone --vfs-cache-mode writes mount OneDrive: ~/OneDrive
if [ $? == 0 ] ; then
# If mount is successful, send a notification
/usr/bin/notify-send "OneDrive Connected" "Microsoft OneDrive successfully mounted."
else
# If mount fails, log the error
echo "Failed to mount OneDrive on $(date)" >> $ERROR_LOG_FILE
/usr/bin/notify-send "OneDrive Connection Failed" "Rclone failed to mount OneDrive."
fi
I'm using Ubuntu 23.10
Content of .confing/autostart/onedrive.sh.desktop
[Desktop Entry]
Type=Application
Exec=/home/ernesto/Documents/Scripts/test-message.sh
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
X-GNOME-Autostart-Delay=10
Name[en_US]=Autostart Test message
Name=Autostart Test message
Comment[en_US]=Autostart Test message
Comment=Sync Automatic