LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices



Reply
 
Search this Thread
Old 02-02-2007, 01:25 PM   #1
aboaventura
LQ Newbie
 
Registered: Dec 2006
Location: Brazil
Distribution: Slackware
Posts: 3

Rep: Reputation: 0
How can I script an autologin, automatically call kde(or simillar) and call an app


Hi all,

I have an application that should start without user interference.
We'd like to make an automatic login with an user without password, start kde and call the application. And, if it it's possible, when my application is finished, ask if shutdown the system will be done.

Can I write these instructions at rc.local, for example ?

Thanks.
 
Old 02-02-2007, 02:13 PM   #2
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 30
Try it in rc.local. You might find these complications:

1. When you start kde, you'll have to figure out a way to know it's all the way up before running the application. I can't help you with that. Maybe you can time how long it normally takes kde to come up, and double that just to be sure.

2. Once you know that kde is up, don't just start the application. Wrap a script around that which (1) runs your application, and (2) asks whether the system should be shut down. Step 2 should be done so that the question is visible on the kde screen. To do that, put the asking of that question in a separate script (let's assume that the script is called fred), and run that by doing something like this:
Code:
xterm -e /bin/bash -c /fullpath/fred
Note that the -c option is for bash, and the -e option is for xterm. If you decide to give xterm any additional options, they must be before the -e; if you decide to give bash any additional options, they must be before the -c.

3. If your application is to run as anything other than root, instead of just running the application, you'll need to explicitly run it as the intended user. Since you're already root when you're running rc.local, you won't need to supply a password. Just use the sudo command:
Code:
sudo -u username /fullpath/application_name
4. Before the sudo command, you'll need to do things which login normally does for you. The two most obvious ones are cd'ing to the desired home directory, and setting environment variables. There are a whole bunch of them. It might be that not all of them are necessary, but some of the necessary ones might not be obvious. To see a list of ones which are set, log in to the same user who will be running the application (whether root or not), and
Code:
env | sort | less
Use that as a guide for which environment variables to set in your script. If you don't know whether to include a particular environment variable, I recommend you throw it in there unless you know of a good reason not to.

5. If you do everything exactly as outlined above, you'll have yet another problem: you don't want to hang out in rc.local forever while the application is running; you want it to run to completion before the system comes up. In face, you'll probably want it to run to completion before you start your application.

To make sure that it doesn't wait around for your application to exit before rc.local continues (and eventually exits), place everything described above except the starting of kde in a separate script, and call that from rc.local as follows:
Code:
/etc/rc.d/rc.startmyapplication &
The ampersand at the end of that means that control will return to rc.local almost immediately, rather than waiting for your application to run and exit.

To make sure that rc.local is effectively finished before you run your application, place all of this (except possibly the startup of kde) at the very end of your rc.local.

Obviously, you should remember to make all your scripts executable:
Code:
chmod 700 /etc/rc.d/whateverscript
At any rate, I must compliment you on your choice of Linux distributions!

Hope this helps.

Last edited by wjevans_7d1@yahoo.co; 02-02-2007 at 03:42 PM.
 
Old 02-02-2007, 02:56 PM   #3
aboaventura
LQ Newbie
 
Registered: Dec 2006
Location: Brazil
Distribution: Slackware
Posts: 3

Original Poster
Rep: Reputation: 0
Hi !

First of all, thank you very much for your support about my doubts.

I believe it will help me lot. But I will need to study and analize your post with care. I a beginner, so...

Thanks.
 
Old 02-02-2007, 03:42 PM   #4
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 30
Caution: I have corrected my usage of the "sudo" command.
 
Old 02-03-2007, 03:59 AM   #5
acummings
Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 615

Rep: Reputation: 49
id:3:initdefault:

That line in /etc/inittab

if U change it to

id:4:initdefault:

Then it will auto load into run level 4, auto starting your default WM

if u using KDE as your default WM (desktop, whatever) then, now (after the /etc/inittab change) u logon via KDM (KDE desktop display manager)

Next, in KDE go to its control center wherein you can opt to auto logon a user (user doesn't need to enter username and password to logon) -- to opt for this, it will prompt u for super user mode or u opt for super user mode then enter the root password in order to make these changes.

al@P3box ~$ cd .kde
al@P3box ~/.kde $ pwd
/home/al/.kde
al@P3box ~/.kde $ ls | grep Auto
/Autostart

In that Autostart folder underneath the .kde folder -- any .desktop (dot_desktop) put in that folder autostarts the corresponding app

Now boots, auto logs on the user to KDE, auto starts desired app

(Do not do this at a business where you do not want other people having access to your files/data (desktop).

--
Alan.
 
Old 02-03-2007, 08:26 AM   #6
TSquaredF
Member
 
Registered: Dec 2005
Location: "The South Coast of Texas"
Distribution: Slackware64-current
Posts: 492
Blog Entries: 1

Rep: Reputation: 55
Alans ideas above are good, except I wouldn't use a .desktop file to start the program. I would use something like
Quote:
#!/bin/sh
/path/to/program
sudo shutdown -h now
This would allow you to automagically shutdown as you wanted. It would also require that your autologgedon user be added to the sudoers file to use shutdown. See man sudo or man sudoers.
Regards,
Bill

Last edited by TSquaredF; 02-03-2007 at 10:39 PM.
 
Old 02-03-2007, 01:49 PM   #7
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269
Note that a bash script should almost always begin with

Code:
#!/bin/sh
NOT

Code:
#!/bin/bash
for portability reasons. /bin/sh links to whatever Bourne-compatible shell you might have installed (usually but not always /bin/bash).
 
Old 02-03-2007, 10:46 PM   #8
TSquaredF
Member
 
Registered: Dec 2005
Location: "The South Coast of Texas"
Distribution: Slackware64-current
Posts: 492
Blog Entries: 1

Rep: Reputation: 55
OK, I've changed my post above, but just for that post. I never use any shell except bash, & I'm sure that most newbs don't either, so /bin/bash will work for a large majority of us all the time. But we must satisfy the nitpickers.
Regards,
Bill
 
Old 02-04-2007, 12:00 AM   #9
acummings
Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 615

Rep: Reputation: 49
Oh, (sorry) I missed the part about the OP request to shutdown the system.

If all you want to do is autostart a few apps, then, copied from the KDE help center:

kdesktop in its turn automatically starts applications stored in $KDEHOME/Autostart. kdesktop will automatically open any files stored in this directory including documents, binary files or applications in the form of .desktop files.


KDE Internals
KSMServer

That's the relevant section where I copied from the KDE help center.

--
Alan.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to call an app from my c++ code? Puckaroo Programming 1 10-30-2006 11:28 AM
what is the call to determine the app you are running in erwinfletch Programming 3 01-11-2006 10:52 AM
call another script and have the inital script exit mjtice Programming 1 09-11-2005 12:54 PM
What do you call your remote control? I call mine... RHLinuxGUY General 19 10-18-2004 07:23 AM
Looking for app/applet don't know what to call it? Palin Linux - Newbie 3 02-15-2003 02:33 AM


All times are GMT -5. The time now is 07:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration