Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: [SOLVED] How to run a command at login

  1. #1
    Join Date
    Jul 2007
    Location
    East Anglia, UK
    Beans
    76
    Distro
    Ubuntu 12.04 Precise Pangolin

    [SOLVED] How to run a command at login

    I want my laptop to run this code at login:
    Code:
    xmodmap -e 'keycode 12 = 3 sterling'
    However I have no idea what scripts run at login to get this code to execute, Please can someone tell me how I can get this code to run at login?

  2. #2
    Join Date
    Mar 2006
    Beans
    Hidden!

    Re: How to run a command at login

    Put it in a script, then open up /etc/rc.local write the path to the script and save. Reboot and script should run on login.

    So:

    Code:
    gedit myscript.sh
    in gedit write as follows:
    Code:
    #! /bin/bash
    xmodmap -e 'keycode 12 = 3 sterling'
    save
    Change permissions
    Code:
    sudo chmod +x ~/myscript.sh
    then edit rc.local
    Code:
    sudo gedit /etc/rc.local
    above the exit 0 line add the following replacing your user name as necessary:
    Code:
    /home/yourusername/myscript.sh
    Restart
    No longer participating......

  3. #3
    Join Date
    Jul 2007
    Location
    East Anglia, UK
    Beans
    76
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How to run a command at login

    OK, that didn't work. It didn't run that command.

  4. #4
    Join Date
    Jan 2007
    Location
    $here ? $here : $there
    Beans
    3,717
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: How to run a command at login

    I don't think xmodmap will run properly in rc.local because no DISPLAY variable has been set. You should be able to go to System->Preferences->Session and add the command you want to the startup commands.
    Don't try to make something "fast" until you are able to quantify "slow".

  5. #5
    Join Date
    Mar 2006
    Beans
    Hidden!

    Re: How to run a command at login

    Quote Originally Posted by vor View Post
    I don't think xmodmap will run properly in rc.local because no DISPLAY variable has been set. You should be able to go to System->Preferences->Session and add the command you want to the startup commands.
    If that's the case, sorry, but you get the idea of how to run a script at boot, even if in this case xmodmap won't run
    No longer participating......

  6. #6
    Join Date
    Jul 2007
    Location
    East Anglia, UK
    Beans
    76
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How to run a command at login

    Quote Originally Posted by vor View Post
    I don't think xmodmap will run properly in rc.local because no DISPLAY variable has been set. You should be able to go to System->Preferences->Session and add the command you want to the startup commands.
    That's worked brilliantly. Thank you.

    Quote Originally Posted by Jose Catre-Vandis View Post
    If that's the case, sorry, but you get the idea of how to run a script at boot, even if in this case xmodmap won't run
    No problems. Useful if I want to run anything else though. When exactly in the boot process does that script run?

  7. #7
    Join Date
    Jan 2007
    Location
    $here ? $here : $there
    Beans
    3,717
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: How to run a command at login

    It runs right at the end of the boot procedure. Probably very near the time the login screen comes up.
    Don't try to make something "fast" until you are able to quantify "slow".

  8. #8
    Join Date
    Jul 2007
    Location
    East Anglia, UK
    Beans
    76
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How to run a command at login

    Quote Originally Posted by vor View Post
    It runs right at the end of the boot procedure. Probably very near the time the login screen comes up.
    Ah, ok. I thought it was a login script. Is there one that runs at login that you can edit?

  9. #9
    Join Date
    Jan 2007
    Location
    $here ? $here : $there
    Beans
    3,717
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: How to run a command at login

    I believe you can still create a script called .xinitrc that runs at login time but, it's probably better to go the System->Preferences->Session method just to keep everything consolidated in one place.
    Don't try to make something "fast" until you are able to quantify "slow".

  10. #10
    Join Date
    Jul 2007
    Location
    East Anglia, UK
    Beans
    76
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How to run a command at login

    Quote Originally Posted by vor View Post
    I believe you can still create a script called .xinitrc that runs at login time but, it's probably better to go the System->Preferences->Session method just to keep everything consolidated in one place.
    OK, thank you for your help.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •