[SOLVED] Run terminal automatically after boot

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Post Reply
ApexDestroyer
Level 1
Level 1
Posts: 16
Joined: Wed Feb 14, 2018 3:35 pm

[SOLVED] Run terminal automatically after boot

Post by ApexDestroyer » Mon Feb 19, 2018 9:06 am

How can I open the terminal within a specified directory automatically after boot, run a command and keep the terminal open?

This is for a Google Assistant relay.

Code: Select all

node index.js
Last edited by ApexDestroyer on Tue Feb 20, 2018 8:49 pm, edited 1 time in total.

User avatar
AndyMH
Level 8
Level 8
Posts: 2276
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Run terminal automatically after boot

Post by AndyMH » Mon Feb 19, 2018 9:14 am

In your startup applications (menu > preferences > startup applications) add an entry for

Code: Select all

gnome-terminal
this will give you a terminal window, and if you want to run any commands in it, e.g. cd /xxxx/xxx, alternatively add a script, e.g.

Code: Select all

gnome-terminal myscript.bsh
Homebrew i5-8400+GTX1080 Cinnamon 19.0, 3 x Thinkpad T430 Cinnamon 19.0, i7-3632 , i5-3320, i5-3210, Thinkpad T60 19.0 Mate

ApexDestroyer
Level 1
Level 1
Posts: 16
Joined: Wed Feb 14, 2018 3:35 pm

Re: Run terminal automatically after boot

Post by ApexDestroyer » Tue Feb 20, 2018 10:15 am

I'm doing something wrong.
All I get is the terminal at boot in the default dir.
The script runs correctly outside of startup manager.

startup command:
/home/michael/assistant-relay-master/autostart.bsh

autostart.bsh:

Code: Select all

#! /bin/bash
# script to run Google Assistant APK on startup
gnome-terminal cd /home/michael/assistant-relay-master
node index.js

User avatar
Flemur
Level 16
Level 16
Posts: 6995
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: Run terminal automatically after boot

Post by Flemur » Tue Feb 20, 2018 3:29 pm

ApexDestroyer wrote:
Tue Feb 20, 2018 10:15 am
autostart.bsh:

Code: Select all

#! /bin/bash
# script to run Google Assistant APK on startup
gnome-terminal cd /home/michael/assistant-relay-master
node index.js
http://manpages.ubuntu.com/manpages/xen ... nal.1.html
I think you need this bit:

Code: Select all

OPTIONS
-e, --command=STRING
Execute the argument to this option inside the terminal.
and

Code: Select all

--working-directory=DIRNAME
                 Set the terminal's working directory to DIRNAME.
"cd" can be weird inside scripts - check the DIRNAME param.
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
Mint 19.1 Xfce/fluxbox
Manjaro openbox/fluxbox

ZeckeSZ
Level 1
Level 1
Posts: 15
Joined: Tue May 22, 2012 1:37 am
Location: Salzgitter, Germany

Re: Run terminal automatically after boot

Post by ZeckeSZ » Tue Feb 20, 2018 8:40 pm

Something like this should work:

Code: Select all

gnome-terminal --working-directory=/home/michael/assistant-relay-master -x bash -c "node index.js; bash"

ApexDestroyer
Level 1
Level 1
Posts: 16
Joined: Wed Feb 14, 2018 3:35 pm

Re: Run terminal automatically after boot

Post by ApexDestroyer » Tue Feb 20, 2018 8:47 pm

After a lot of trial and error I found a combination that worked to open gnome terminal in a specific dir and -x the jsn

Code: Select all

#! /bin/bash
# script to run Google Assistant APK on startup
gnome-terminal --working-directory=assistant-relay-master/	-x node "index.js"
I added this to the startup applications and Bob's your Uncle!

Post Reply

Return to “Newbie Questions”