[Solved] Setting up programs to run on startup

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
Cammo
Level 2
Level 2
Posts: 59
Joined: Tue Apr 08, 2014 8:19 pm

[Solved] Setting up programs to run on startup

Post by Cammo »

Hi all,

I'm trying to get several programs to run on startup, and I've discovered that I can do this by editing my rc.local file.

I've been running

Code: Select all

sudo gedit /etc/rc.local
to bring up the file and have made the following changes:

Code: Select all

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
rfkill block bluetooth
redshift -l [my latitude]:[my longitude]
jitsi

exit 0
So what I'm trying to do is first shut down my bluetooth (that works fine), then run redshift (a cool little utility for adjusting the colour brightness with the time of day), then fire up jitsi.

So far, it's definitely shutting down my BT as the light's gone off, but it doesn't seem to be running the other two lines. Running them manually in the console works fine, so it isn't a problem with the command itself. Any thoughts?

Thanks,

Cammo
Last edited by Cammo on Wed Apr 23, 2014 9:20 pm, edited 1 time in total.

User avatar
kukamuumuka
Level 16
Level 16
Posts: 6676
Joined: Tue Sep 03, 2013 4:51 am
Location: Finland
Contact:

Re: Setting up programs to run on startup

Post by kukamuumuka »

Here ya go:
Code:
user@ubuntu:~$rfkill list
0: phy0: Wireless LAN
Soft blocked: no
Hard blocked: no
1: hci0: Bluetooth
Soft blocked: no
Hard blocked: no
Script will be very helpful. How did you learn about this useful little command?

-- until I hear from you with the script, I tried
Code:
sudo rfkill block bluetooth
http://ubuntuforums.org/showthread.php?t=1381674&page=2

User avatar
karlchen
Level 21
Level 21
Posts: 12731
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: Setting up programs to run on startup

Post by karlchen »

Hello, Cammo.

Code: Select all

rfkill blocck bluetooth
is a command which will be and which needs to be run with root privileges. Therefore it will work.
I assume, however, that the next 2 commands

Code: Select all

redshift -l [my latitude]:[my longitude]
jitsi
are supposed to be run under your normal user account. Correct?
Moreover the executable files or scripts redshift and jitsi may not be found following the search PATH variable.

Provided redshift and jitsi should really be launched under your normal account and whenever you have logged in, then I will recommend taking them out of rc.local and adding them to your personal "Startup Applications".

Kind regards,
Karl
Image
Linux Mint 19.2 64-bit Cinnamon, Total Commander 9.22a 64-bit
Haß gleicht einer Krankheit, dem Miserere, wo man vorne herausgibt, was eigentlich hinten wegsollte. (Goethe)

Cammo
Level 2
Level 2
Posts: 59
Joined: Tue Apr 08, 2014 8:19 pm

Re: Setting up programs to run on startup

Post by Cammo »

Hello Karl,

Thanks for your super speedy reply! I'll give it a whirl and let you know...

I didn't realise rc.local ran it as root. Just wondering, why would running it as root not work if it runs fine under my user account, which has limited privileges?
If I run the commands from the console as su, they still work fine.

Total noob question - when you refer to a PATH variable, what's that?

Also, what criteria would you recommend using to discriminate between commands to add to rc local vs startup applications?

Thanks for all your help,

Cammo

Cammo
Level 2
Level 2
Posts: 59
Joined: Tue Apr 08, 2014 8:19 pm

Re: Setting up programs to run on startup

Post by Cammo »

Hi Karl,

Thanks! It worked perfectly. One last thing before I mark the thread as solved - I'd like Jitsi to open up on my Workspace #2 (called "Internet", if that helps). It has a big splash screen that, while informative, is not something I want to see every time I log in on my Workspace #1. However, I added it to my startup apps so that it's pre-loaded and ready to go for when I need it.

Do you know if it's possible to make the startup program run on one of the other workspaces?

Thanks again,

Cammo

Cammo
Level 2
Level 2
Posts: 59
Joined: Tue Apr 08, 2014 8:19 pm

Re: Setting up programs to run on startup

Post by Cammo »

administrollaattori wrote: sudo rfkill block bluetooth
@administrollaattori, thanks for your reply. Apologies if my OP was ambiguous on this point, but that part of my rc.local had been working fine for me - what I'd had problems with was running redshift and jitsi on the lines after it. I followed karlchen's advice, taking them out of rc.local and adding it to my user's startup applications. This has given rise to a sub-issue of wanting to try and get jitsi to start up on Workspace #2 (called "Internet", if it helps). So, I'm asking the forum gurus if anyone knows how I could achieve this.

Thanks,

Cammo

User avatar
karlchen
Level 21
Level 21
Posts: 12731
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: Setting up programs to run on startup

Post by karlchen »

Hello, Cammo.

Though only a side issue, your question about the variable PATH:
The PATH variable is one of the things which serve the same goal on Windows and on Linux. PATH enumerates a list of (sub)folders. This list of sub-folders will be searched whenever you launch a programme by simply giving its name without prefixing the complete pathname to it.
Example:
You execute the command

Code: Select all

firefox
Linux will go through the list of folders in PATH to find an executable file named firefox. If it finds one it will be launched.

Code: Select all

$ echo $PATH
/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
$ which firefox                                                       |
/usr/bin/firefox .....................................................|
About launching a programme on a particular workspace automatically:
This has been asked before. Yet, I admit I have never tried to do so myself and do not know the answer. - So I will have to search around a bit myself now ...

KDE has got a dedicated function for it, xenopeek mentioned somewhere, but sadly did not elaborate in that post.
So the answer to the problem depends on the desktop environment: Mate, Cinnamon, xfce, KDE.
(search going on ...)

Cheers,
Karl
Image
Linux Mint 19.2 64-bit Cinnamon, Total Commander 9.22a 64-bit
Haß gleicht einer Krankheit, dem Miserere, wo man vorne herausgibt, was eigentlich hinten wegsollte. (Goethe)

Cammo
Level 2
Level 2
Posts: 59
Joined: Tue Apr 08, 2014 8:19 pm

Re: Setting up programs to run on startup

Post by Cammo »

Hi all,

@karlchen - thanks for explaining the PATH variable for me. I guess it's one of those things that must exist to make the console work, but I'd never given any thought to. Much appreciated!

@all - I've found a workaround that works ok in Cinnamon (I'm guessing because it's an offshoot of Gnome?)
http://stackoverflow.com/questions/3351 ... s-in-gnome

I had to install wmctrl, and ran a script similar to the one on the website:

Code: Select all

#!/bin/bash
wmctrl -n 3

firefox &
jitsi
sleep 15

wmctrl -r firefox -t 0
wmctrl -r jitsi -t 1 
wmctrl -r java -t 1 
#third wmctrl as jitsi splash screen labelled JavaEmbeddedFrame, so that gets moved too
Simply called that from my startup applications, and worked like a charm. Not quite what I was looking for, but an adequate workaround. Although, if anyone finds out how to do this from within Cinnamon itself, I'd be much obliged if they shared it. Nevertheless, I think it's time to mark this thread as solved. Thanks for all your help, Karl.

Cheers,

Cammo

Post Reply

Return to “Newbie Questions”