LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE
User Name
Password
SUSE / openSUSE This Forum is for the discussion of Suse Linux.

Notices


Reply
  Search this Thread
Old 09-11-2006, 11:14 PM   #1
EFiNi7
LQ Newbie
 
Registered: Jul 2006
Posts: 14

Rep: Reputation: 0
Run command automatically when xsession starts??


I require a particular command to run as soon as my xsession starts. I am using KDE on my Suse 10.1 box.

I am running synergy on my Suse 10.1 linux box so that i can share my mouse and keyboard between my Windows XP (synergy server) and my Suse 10.1 (synergy client) boxes.

At present to get this working, i make sure my XP machine is running with the synergy server service also running. I then boot up my Suse 10.1 machine and use the keyboard and mouse connected to that PC to log in to my KDE session. Once i am in the KDE session i open terminal and run the following command after running SU command:

# cd /usr/bin
# ./synergyc -f --daemon 161.50.17.154


This command connects the synergy client to my synergy windows xp server service and i can then put aside the keyboard and mouse connected to my linux box and use the keyboard and mouse connected to my XP machine to control both desktops.

How do i automate these commands as soon as the xsession starts. If i can get it to run as soon as the xsession login page comes up that would be totally awesome and would mean i can discard the keyboard and mouse completely on my linux box.

Please help!! If you have to spell out the exact procedure for a dummy like me i would be totally appreciative. Im sure this is such an easy thing to do but im still new to all this. Please help me remove this clutter from my desk!!
 
Old 09-12-2006, 04:23 AM   #2
liaty
Member
 
Registered: Oct 2005
Distribution: openSuse 10.1
Posts: 129

Rep: Reputation: 15
Find the directory /home/[username]/.kde/autostart/
now in this directory make a shell script. If you are using gui use kate or similar and enter the following:

#!/bin/bash
/usr/bin/./synergyc -f --daemon 161.50.17.154

now save as /home/[username]/.kde/autostart/synergyc
Next in konqueror right click on the new file created and under permissions tab check the 'is executable' box. Or from command line run:
chmod +x /home/[username]/.kde/autostart/synergyc

Last edited by liaty; 09-12-2006 at 04:24 AM.
 
Old 09-12-2006, 04:38 AM   #3
berbae
Member
 
Registered: Jul 2005
Location: France
Distribution: Arch Linux
Posts: 540

Rep: Reputation: Disabled
Hi EFiNi7
I think that if you need root privileges to launch the synergic daemon, the liaty method will not work, unless you use sudo.
But I think that using a shell script in the /etc/init.d directory is better, for at this time the script has already root privileges.
So you may create a shell script in /etc/init.d, using the 'skeleton' script as a model.
Then run YaST and go to System/Run Level Editor
you should find your script there in the list where you can enable it, and in 'expert mode' choose the runlevels you want to launch it in.
This method is a good way to learn about the boot procedure in Linux.
But it's all your choice.
 
Old 09-12-2006, 05:07 AM   #4
liaty
Member
 
Registered: Oct 2005
Distribution: openSuse 10.1
Posts: 129

Rep: Reputation: 15
Sorry missed the su in first post.
I wondered why there was no rc.local script.

Last edited by liaty; 09-12-2006 at 05:09 AM.
 
Old 09-12-2006, 08:22 PM   #5
EFiNi7
LQ Newbie
 
Registered: Jul 2006
Posts: 14

Original Poster
Rep: Reputation: 0
OK, thanks for your help guys.

I realised i dont need to be super user to run this command.

So i tried your way Berbae and this command runs but only after i log in, go into YAST and open the runlevel editor. As soon as i open the run level editor it runs. Very strange. Do you know why this happens? I tried all sorts of enabling and runlevel options with no success.

So then i tried Liaty method putting the script in .kde/autostart and this worked automatically as soon as KDE started.

However what i really need is for this script to run as soon as the username and password login page appears. At the moment i still need to use the other keyboard and mouse to enter my username and password.

Any further tips/ideas?
 
Old 09-12-2006, 08:46 PM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Any further tips/ideas?
Maybe check out /etc/X11/kdm (if it's that similar to gdm) for any subdir named "presession" which should contain a "default" file to which you can add commands. this file will be run each time when a session (needs to | will) be started.
 
Old 09-12-2006, 09:37 PM   #7
EFiNi7
LQ Newbie
 
Registered: Jul 2006
Posts: 14

Original Poster
Rep: Reputation: 0
Had a look and there is nothing along those lines for KDE
 
Old 09-12-2006, 10:14 PM   #8
gurl4sh25
Member
 
Registered: Apr 2006
Distribution: SuSE, RedHat, Fedora, CentOS, BSD
Posts: 115

Rep: Reputation: 15
Hi guys,

Please try also the boot.local on Suse same as rc.local of redhat =)

Regards,
gurl4sh25
 
Old 09-13-2006, 05:00 AM   #9
liaty
Member
 
Registered: Oct 2005
Distribution: openSuse 10.1
Posts: 129

Rep: Reputation: 15
The problem with boot.local is that it is executed before the run level scripts. It,s worth a try, but if any services that are needed by synergyc are started in runlevel it will not work.

The problem with berbae's solution may well be a dependency one. If synergyc requires network for example, it may be executed before network is finished loading.
You could try making the synergyc pause before executing by adding:

#!/bin/bash
sleep 10
/usr/bin/./synergyc -f --daemon 161.50.17.154

Or, is auto-loggin not an option?

Last edited by liaty; 09-13-2006 at 05:17 AM.
 
Old 09-13-2006, 05:57 AM   #10
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Had a look and there is nothing along those lines for KDE
Way too terse reply.

Look for /etc/kde/kdm/Xsession. It should be linked to /etc/X11/xdm/Xsession which is run as root before a session starts, satisfying requirement wrt login screen. Adding a line to start a command as lesser privileged user should be trivial. Else switch to Gdm. At least it has a clearly labelled /etc/X11/gdm/PreSession/Default in which you can add the command.
 
Old 09-13-2006, 12:14 PM   #11
SkippyBoy
Member
 
Registered: Oct 2005
Distribution: Suse10.2
Posts: 65

Rep: Reputation: 15
This sounds a lot like remote login. Have you checked out NX/FreeNX? I don't know what the synergy app is - but with NX you can open a session from one computer in a window on another computer.
You could also try VNC.

Disregard this if it doesn't apply to what you are trying to do.
 
Old 09-13-2006, 12:56 PM   #12
killy9999
Member
 
Registered: Feb 2005
Location: Poland
Distribution: openSUSE 11.3/11.4 x64
Posts: 114

Rep: Reputation: 15
read the friendly manual: http://synergy2.sourceforge.net/autostart.html
 
Old 09-19-2006, 12:57 AM   #13
EFiNi7
LQ Newbie
 
Registered: Jul 2006
Posts: 14

Original Poster
Rep: Reputation: 0
Ok i got it working. I added the command to my Xsetup file under /etc/X11/xdm/

It now works as soon as the login screen appears. Fantastic!

Thanks all for your help and guidance!!
 
  


Reply



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
Run Command on boot automatically qqcoisa Linux - Hardware 1 03-20-2006 12:27 AM
run command evertime linux starts up GUIPenguin Linux - General 8 11-13-2004 02:06 AM
How can I run a command automatically at startup? luwigie Linux - General 8 08-26-2004 09:05 PM
Run programs automatically when KDE starts koyi Linux - General 2 09-01-2003 06:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE

All times are GMT -5. The time now is 02:24 AM.

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
Open Source Consulting | Domain Registration