1

I am trying to launch a script after a user has loged into the computer using the GUI. This script requires user input through the terminal. I have tried the following

.desktop file in ~/.config/autostart --> Does not work

When using this the output is not the same as that of the script running in the terminal. It closes the opened applications and vpn breaks the network connection. Neither of these occurr using the normal terminal.

My desktop enviroment is xubuntu version 20.04.


#!/bin/bash

echo "........ Start Up Script ........." echo "sudo priveledges necessary for VPN"

#Connect VPN to Server in Czech Republic sudo protonvpn c --cc CZ

#Prompt To Mount Encrypted Files read -p 'Mount Encrypted Files? [ y/n ] ' encryptedmount case $encryptedmount in [Yy]* ) veracrypt -t -k "" --pim=0 --protect-hidden=no /media/peterthegreat/Main_Data/Files /media/veracrypt1; break;; [Nn]* ) ;; esac

Prompt To Update Packages

read -p 'Upgrade and Update System? [ y/n ] ' upgradeandupdate case $upgradeandupdate in [Yy]* ) apt-get update && apt-get upgrade; break;; [Nn]* ) ;; esac

#Prompt to Open Tilix read -p 'Open Tilix? [ y/n ] ' til case $til in [Yy]* ) cd /home/peterthegreat; tilix --session=~/Documents/Start_Up/TilixSetup.json -e &;; [Nn]* ) ;; esac disown %1

#Prompt to Open Firefox read -p 'Open Firefox? [ y/n ] ' firefox case $firefox in [Yy]* ) firefox &;; [Nn]* ) ;; esac disown %1

echo "....... Done ......."

Thanks

  • Welcome to AskUbuntu, the command should be a full path and regex in bash, abbreviations may not work. – Sadaharu Wakisaka Sep 07 '20 at 01:55
  • I don understand the second part of yout comment about regex and abreviations. Could you rephrase? – Billy Case Sep 07 '20 at 22:52
  • sudo is supposed to be executed as root. You can imitate on the running terminal. I think a better explanation here https://askubuntu.com/questions/889632/startup-script-with-sudo-in-ubuntu-16-10 – Sadaharu Wakisaka Sep 08 '20 at 04:00
  • I tried the suggestion of the command line in the question you link but it only opened the terminal for 10 seconds and did not run the rest of the commands. This .desktop does run but it does so differently than if the script were run from the terminal [Desktop Entry] Encoding=UTF-8 Version=0.9.4 Type=Application Name=Start Up Comment=Set Up of Workspace Exec=/home/peterthegreat/Bash\\ Scripts/StartUp.sh OnlyShowIn=XFCE; RunHook=0 StartupNotify=false Terminal=true Hidden=false – Billy Case Sep 08 '20 at 07:59
  • Well, to make it simple, why don't you put this StartUp.sh into .bashrc or something automatically loads and executes all inside a file when you get to login a desktop? – Sadaharu Wakisaka Sep 08 '20 at 22:27
  • I have added it to my path temporally but hoped to find a solution. – Billy Case Sep 08 '20 at 22:47

1 Answers1

0

Have a look at .desktop file spec -- its not expecting a bash script.

Your .desktop file needs to look something like

[Desktop Entry]
Type=Application
Exec=<path to your bash script>
Terminal=True
X-GNOME-Autostart-enabled=true
NoDisplay=false
Hidden=false
Name[en_GB]=VPN
Comment[en_GB]=Creates a VPN
X-GNOME-Autostart-Delay=9

where "path to your bash script" points to the script that you show in the question (probably best saved in /usr/local/bin)

Nick Sillito
  • 1,596
  • I have tried your fix my desktop file is now [Desktop Entry] Type=Application Exec=/usr/local/bin/StartUp.sh Terminal=true NoDisplay=false Hidden=false Name[en_GB]=startup Comment[en_GB]=Run frequent start up commands but still has the same issues. I have not incluede the lines with GNOME since my environment is XFCE. – Billy Case Sep 06 '20 at 23:33
  • Gdk-Message: 21:20:51.996: tilix: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.0. is the error return when using nohup on nohup.out – Billy Case Sep 07 '20 at 10:54