Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: autorun a shell at/before startup?

  1. #1
    Join Date
    Nov 2010
    Location
    Shanghai, China
    Beans
    19
    Distro
    Ubuntu 10.10 Maverick Meerkat

    autorun a shell at/before startup?

    I need to run a shell to enable pseudo-multitouch on my touchpad using a shell which automatically configs synclient.
    Code:
    #!/bin/bash
    export DISPLAY=:0.0
    
    synclient \
    EmulateTwoFingerMinZ=50 \
    EmulateTwoFingerMinW=6 \
    VertTwoFingerScroll=1 \
    HorizTwoFingerScroll=1 \
    VertScrollDelta=75 \
    HorizScrollDelta=100 \
    RTCornerButton=2 \
    RBCornerButton=0 \
    LTCornerButton=0 \
    LBCornerButton=0 \
    TapButton1=1 \
    TapButton2=3 \
    TapButton3=0 \
    ;
    I put this file under /home/<username>/, and also put this to the Session manager under system menu. But it doesn't work. I've already used chmod command to make sure that the file is executable, and, I also put this:
    Code:
    PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/include:/usr/local/bin:$HOME/bin"
    in $HOME/.bashrc. Now this file looks like this:
    Code:
    # ~/.bashrc: executed by bash(1) for non-login shells.
    # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
    # for examples
    
    PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/include:/usr/local/bin:$HOME/bin"
    
    # If not running interactively, don't do anything
    [ -z "$PS1" ] && return
    
    # don't put duplicate lines in the history. See bash(1) for more options
    # ... or force ignoredups and ignorespace
    HISTCONTROL=ignoredups:ignorespace
    
    # append to the history file, don't overwrite it
    shopt -s histappend
    
    # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
    HISTSIZE=1000
    HISTFILESIZE=2000
    
    # check the window size after each command and, if necessary,
    # update the values of LINES and COLUMNS.
    shopt -s checkwinsize
    
    # make less more friendly for non-text input files, see lesspipe(1)
    [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
    
    # set variable identifying the chroot you work in (used in the prompt below)
    if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
        debian_chroot=$(cat /etc/debian_chroot)
    fi
    
    # set a fancy prompt (non-color, unless we know we "want" color)
    case "$TERM" in
        xterm-color) color_prompt=yes;;
    esac
    
    # uncomment for a colored prompt, if the terminal has the capability; turned
    # off by default to not distract the user: the focus in a terminal window
    # should be on the output of commands, not on the prompt
    #force_color_prompt=yes
    
    if [ -n "$force_color_prompt" ]; then
        if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
    	# We have color support; assume it's compliant with Ecma-48
    	# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
    	# a case would tend to support setf rather than setaf.)
    	color_prompt=yes
        else
    	color_prompt=
        fi
    fi
    
    if [ "$color_prompt" = yes ]; then
        PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    else
        PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
    fi
    unset color_prompt force_color_prompt
    
    # If this is an xterm set the title to user@host:dir
    case "$TERM" in
    xterm*|rxvt*)
        PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
        ;;
    *)
        ;;
    esac
    
    # enable color support of ls and also add handy aliases
    if [ -x /usr/bin/dircolors ]; then
        test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
        alias ls='ls --color=auto'
        #alias dir='dir --color=auto'
        #alias vdir='vdir --color=auto'
    
        alias grep='grep --color=auto'
        alias fgrep='fgrep --color=auto'
        alias egrep='egrep --color=auto'
    fi
    
    # some more ls aliases
    alias ll='ls -alF'
    alias la='ls -A'
    alias l='ls -CF'
    
    # Add an "alert" alias for long running commands.  Use like so:
    #   sleep 10; alert
    alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
    
    # Alias definitions.
    # You may want to put all your additions into a separate file like
    # ~/.bash_aliases, instead of adding them here directly.
    # See /usr/share/doc/bash-doc/examples in the bash-doc package.
    
    if [ -f ~/.bash_aliases ]; then
        . ~/.bash_aliases
    fi
    
    # enable programmable completion features (you don't need to enable
    # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
    # sources /etc/bash.bashrc).
    if [ -f /etc/bash_copletion ] && ! shopt -oq posix; then
        . /etc/bash_completion
    fi
    But still no works. I'm using ASUS Eee PC 1005PE, ubuntu 10.10 Desktop version(32-bit), what shall I do?

  2. #2
    Join Date
    Oct 2009
    Beans
    Hidden!
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    Re: autorun a shell at/before startup?

    Did you add it to start up applications?
    Come to #ubuntuforums! We have cookies! | Basic Ubuntu Security Guide

    Tomorrow's an illusion and yesterday's a dream, today is a solution...

  3. #3
    James78's Avatar
    James78 is offline Extra Foam Sugar Free Ubuntu
    Join Date
    Sep 2008
    Beans
    Hidden!

    Re: autorun a shell at/before startup?

    Gnome and KDE have some startup folders you could try. Just drop whatever scripts into them.

    Gnome: ~/.config/autostart
    KDE: Only for .desktop files I think: ~/.kde/Autostart
    And for other scripts, like .sh: ~/.kde/env

    Note: The Gnome startup folder might require .desktop files instead of scripts. So you should try both ways. Also, I think the ~/.config/autostart folder works for both Gnome and KDE at the same time, but I'm not 100% sure.

    If you don't want to do all this manually, you can just go to the respective application/system area in both desktop environments.
    Gnome: Desktop Preferences -> Sessions
    KDE: System Settings -> Startup and Shutdown
    Last edited by James78; November 20th, 2010 at 01:27 PM.

  4. #4
    Join Date
    Nov 2010
    Location
    Shanghai, China
    Beans
    19
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: autorun a shell at/before startup?

    Quote Originally Posted by CharlesA View Post
    Did you add it to start up applications?
    Yes I did, isn't that located in System-Preferences-Session(or autorun application, whatever) Manager? (Well I don't know the exact name since I'm using the Chinese version, sorry)

  5. #5
    Join Date
    Nov 2010
    Location
    Shanghai, China
    Beans
    19
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: autorun a shell at/before startup?

    Quote Originally Posted by James78 View Post
    Gnome and KDE have some startup folders you could try. Just drop whatever scripts into them.

    Gnome: ~/.config/autostart
    KDE: Only for .desktop files I think: ~/.kde/Autostart
    And for other scripts, like .sh: ~/.kde/env

    Note: The Gnome startup folder might require .desktop files instead of scripts. So you should try both ways. Also, I think the ~/.config/autostart folder works for both Gnome and KDE at the same time, but I'm not 100% sure.

    If you don't want to do all this manually, you can just go to the respective application/system area in both desktop environments.
    Gnome: Desktop Preferences -> Sessions
    KDE: System Settings -> Startup and Shutdown
    Yeah, it seems that I already have a file named "touchpad.sh.desktop" in this directory, and it goes like this:
    Code:
    [Desktop Entry]
    Type=Application
    Exec=/home/wilsonmess/touchpad.sh
    Hidden=false
    NoDisplay=false
    X-GNOME-Autostart-enabled=true
    Name[zh_CN]=触控板设置
    Name=触控板设置 ##touchpad configurations
    Comment[zh_CN]=使触控板支持多点触控
    Comment=使触控板支持多点触控 ##enable pseudo-multitouch on the touchpad
    So... Is there anything wrong in this file? Thanks!

  6. #6
    Join Date
    Oct 2009
    Beans
    Hidden!
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    Re: autorun a shell at/before startup?

    Does the script work if you run it manually?

    I'm curious as to what the "\" characters are used for.
    Come to #ubuntuforums! We have cookies! | Basic Ubuntu Security Guide

    Tomorrow's an illusion and yesterday's a dream, today is a solution...

  7. #7
    Join Date
    Oct 2009
    Location
    Elgin, IL USA
    Beans
    3,363
    Distro
    Ubuntu 16.10 Yakkety Yak

    Re: autorun a shell at/before startup?

    Note that if you add a bin directory to your home directory, that should "automatically" be included in your path the next time you login into X.

    echo $PATH
    /home/efflandt/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

    But the question is whether you put that script in your /home/<username>/bin/, because you said "I put this file under /home/<username>/", which is NOT in your PATH (and probably should not be).

  8. #8
    Join Date
    Nov 2010
    Location
    Shanghai, China
    Beans
    19
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: autorun a shell at/before startup?

    Quote Originally Posted by CharlesA View Post
    Does the script work if you run it manually?

    I'm curious as to what the "\" characters are used for.
    Yes it prompts me to choose whether to open the file or to execute it.
    Actually I didn't write the shell, I found this when I was troubleshooting the touchpad (which can be found here: http://apt-blog.net/configuring_lapt...chpad_in_linux , in Chinese). The stuff actually worked automatically for a while, so I don't think it's about the slash. But yesterday, I didn't know how, it just can't work properly, and when I open the file, it didn't prompt me what to do. The gedit simply pop out and I thought it might be solved by using the chmod +x command. Though now it can work manually, I'm still trying to figure out how to make it automatially...

  9. #9
    Join Date
    Nov 2010
    Location
    Shanghai, China
    Beans
    19
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: autorun a shell at/before startup?

    Quote Originally Posted by efflandt View Post
    Note that if you add a bin directory to your home directory, that should "automatically" be included in your path the next time you login into X.

    echo $PATH
    /home/efflandt/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

    But the question is whether you put that script in your /home/<username>/bin/, because you said "I put this file under /home/<username>/", which is NOT in your PATH (and probably should not be).
    Well, I can't find directory "bin" under my home directory (and yes, I did press CTRL+H), but I found one under /usr/ , so I put it there, with no effect after reboot...

  10. #10
    Join Date
    May 2010
    Location
    uk
    Beans
    9,249
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: autorun a shell at/before startup?

    Hi

    What about running the script using update-rc.d with a run level

    http://embraceubuntu.com/2005/09/07/...run-at-bootup/

    Kind regards

Page 1 of 3 123 LastLast

Tags for this Thread

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
  •