Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

i'm working on a deb package that allows the administrator to create another account and run that account automatically in kiosk mode. I created the user, specified a shortkey and put that in a hidden file, and created a .bash_profile script on the admin account that i copy to the new user's home folder.

This is the script i'm running to create the files and specify the shortkey:

#!/bin/bash
basis="Primary + Alt + "
shortkey=`zenity --entry --text "Your shortkey will be a combination of <Primary> + <Alt> + a letter\n\n Specify your letter!"`

while [[ $shortkey = *[^A-Z]* ]];
        do
                zenity --warning --text "Input incorrect\n\nTry again"
                shortkey=`zenity --entry --text "Your shortkey will be a combination of <Primary> + <Alt> + a letter\n\n Specify your letter!"`

done
        basis="$basis$shortkey"
zenity --info --text "$basis" --title="Your shortkey"

touch kiosk/kiosk-0.1/.mykey
echo "gsettings set org.gnome.desktop.wm.keybindings close [$basis]" > kiosk/kiosk-0.1/.mykey

user=$(cat kiosk/kiosk-0.1/.username)
keys=$(cat kiosk/kiosk-0.1/keys)
content=$(cat kiosk/kiosk-0.1/.mykey)

touch kiosk/kiosk-0.1/.bash_profile
echo "#!/bin/bash" >> .bash_profile
echo "" >> .bash_profile
echo $keys >> .bash_profile
echo $content >> .bash_profile
chmod +x .bash_profile
chown $user .bash_profile
mv '.bash_profile' /home/$user

That content that is copied to .bash_profile contains code to disable all the keys from the interface like:

gsettings set org.gnome.desktop.wm.keybindings begin-move []

Now I only added a line to start the chromium browser to the right website

/usr/bin/chromium-browser www.google.be --kiosk --no-default-browser-check --disable-translate

I also changed the owner of the .bash_profile script to the account user and made it executable before I copied it to the new users home folder.

Now when i login on the new user, this script does nothing. Can anyone see where i'm wrong of help me finding the solution?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

The main issue here is that .bash_profile is not read when you do a graphical login. It is a bash-specific file, it's read when you start a login shell and I very much doubt it will ever be read on graphical login.

You would have a better chance using ~/.profile instead which is i) read by most login shells, not only bash, so you're not limiting your user to a specific shell and ii) far more likely to be read by a graphical login.

I just checked this and .profile is indeed read on Ubuntu 13.04 when you log in graphically. However, you cannot assume that will always be the case. For more details see Gilles's excellent answer here.

Now, a couple of minor points. There is no need for touch, echo "foo" >> bar will create the file bar if it doesn't exist and append to it if it does. Also, there is no need for .bash_profile to be executable, the file is sourced, not run. I don't know if that would cause problems but it might.

Finally, the file's group will be root, not the user's. Again, not sure if this is a problem but you may as well add this to your script:

chown $user:$user .profile

Note that .profile is ignored by bash if a file called ~/.bash_profile exists. This should not affect graphical logins but may cause unexpected behavior when logging in from the command line.

share|improve this answer
    
i'm using the ~/.profile file now, but is it possible to call a executable script in this file? I'm trying to run my bash script with 'bash disable.sh &' but the login still happens as usual –  Gijs Mar 12 at 19:19
    
@Gijs depends on many things. If this makes your firefox load, please ask a new question about the next issue. Make sure to show what disable.sh is. Also, make sure you call the script with its full path,. for example /home/foo/scripts/disable.sh. –  terdon Mar 13 at 2:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.