Initially I sought a way to execute a script as I was logging in via GDM. The numerous methods I found failed to work. .xinitrc, .xsession, .bash_profile, startup and .bashrc all failed to work in some fashion or another. Documented here:
Best way to auto start a program -
http://forums.gentoo.org/viewtopic.php?t=198201
starting applications during X.. how? -
http://forums.gentoo.org/viewtopic.php?t=195934
Starting apps on X startup with GDM -
http://forums.gentoo.org/viewtopic.php?t=189739
It wasn't until I came upon this thread:
~/.xinitrc quick question -
http://forums.gentoo.org/viewtopic.php?t=203258
That I found my first inkling that the traditional methods might be rendered null with the new version of Gnome. The next pertinent thread I found seemed to deal with my exact problem:
Fixing new sessions with GDM 2.6 -
http://forums.gentoo.org/viewtopic.php?t=162521
This did not work precisely as advertised either. As you can see from this code:
Code: Select all
#!/bin/bash
exec xmodmap -e "pointer = 1 2 3 6 7 4 5" &
exec imwheel -p -k -b "000067" -f &
xfce-mcs-manager &
perlpanel &
openbox
Code: Select all
#!/bin/bash
#Chinese Input Method
export XMODIFIERS="@im=SCIM" &
export XIM=scim &
export XIM_PROGRAM=scim &
scim -d &
gnome-session
Code: Select all
# (Sourced by .xsession and .bash_profile)
if ! ps -u $USER | cut -b 25- | grep '^irexec$' &>/dev/null
then
irexec --daemon
fi
Code: Select all
#!/bin/bash
if !(ps -u $USER | cut -b 25- | grep (command to be executed) >/dev/null)
then
(stuff you want to execute)
fi
(your x-session)
To sum up:
In "/usr/share/xsessions/" should be a script that is named "something".desktop ("something" will vary depending on your window manager). Log in as root and make your own, of the format:
Code: Select all
[Desktop Entry]
Encoding=UTF-8
Name=(whatever name you like)
Comment=(some comment)
Exec=(the name of your custom bash script, I used My_Gnome_Session)
TryExec=(again the custom bash script name)
Icon=
Type=Application
Code: Select all
chmod 755 (custom script name)
Edit it with your favorite text editor. Add this bash script:
Code: Select all
#!/bin/bash
if !(ps -u $USER | cut -b 25- | grep (command to be executed) >/dev/null)
then
(stuff you want to execute)
fi
(your x-session)
Of course multiple if's can be used to check for multiple programs, always remeber to add the x-session at the very end of the script. Also you may need to preface some of your execution commands with "exec". Or you may need to add an '&' at the end of a command to "daemonize" it, or spin it off into its own independent process.
I hope this has been of help.
smarm



