[SOLVED] Run terminal automatically after boot

Quick to answer questions about finding your way around Linux Mint as a new user.
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. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
ApexDestroyer

[SOLVED] Run terminal automatically after boot

Post by ApexDestroyer »

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 LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
AndyMH
Level 21
Level 21
Posts: 13728
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Run terminal automatically after boot

Post by AndyMH »

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
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
ApexDestroyer

Re: Run terminal automatically after boot

Post by ApexDestroyer »

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 20
Level 20
Posts: 10096
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: Run terminal automatically after boot

Post by Flemur »

ApexDestroyer wrote: Tue Feb 20, 2018 10:15 amautostart.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?
ZeckeSZ
Level 1
Level 1
Posts: 31
Joined: Tue May 22, 2012 1:37 am
Location: Salzgitter, Germany

Re: Run terminal automatically after boot

Post by ZeckeSZ »

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

Re: Run terminal automatically after boot

Post by ApexDestroyer »

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!
Locked

Return to “Beginner Questions”