How to run a command after x-session has finished loading?

view story

http://askubuntu.com – I have Ubuntu installed on an Imac. I have a spanish keyboard and the the keys "<" and "º" are inverted. I can solve this issue with the following command: xmodmap -e 'keycode 94=masculine ordfeminine backslash brokenbar backslash brokenbar' -e 'keycode 49=less greater' I have put this command in /etc/init.d/rc.local and in the xfce startup application utility. The command executes both times but it doesn't swap the keys! Maybe the keyboard layout loads later than this command? I wonder how I could run this command at the end of the starting of xfce (or gnome) session. (HowTos)