Create Mozilla Shortcuts on all Users' Desktops
Sometimes it can be useful to have an icon on the desktop. If you have 1,000 users, it is even handier if you can add this icon for all users in a single sweep.
All shortcuts are really just files. These files are found in the folder 'Desktop' in the users' home directories. As an example, the file that represents the shortcut to the web browser Mozilla is called Mozilla_Navigator.desktop. The content starts like this:
[Desktop Entry] Type=Application Exec=mozilla Name=Mozilla Navigator Comment=Mozilla Navigator Icon=/usr/share/pixmaps/mozilla.xpm
Here is the information about where the program is installed, what kind of icon will be used, and other information.
If, for instance, you want everybody to have access to an icon for OpenOffice.org on the desktop as a shortcut (the file in this case is called textdoc.desktop), then do the following as the root user:
One file spread to all users in a single sweep.
- First you have to create the shortcut manually for a single user, for instance the user "test", this will end up as /skole/tjener/home0/test/Desktop/textdoc.desktop.
- The next step is to make a script that does the following:
- Copies this 'textdoc.desktop' to all users' Desktop folder.
- Sets the correct permissions and ownership of the file, i.e. the file is owned by the user himself, and not by root..
#!/bin/sh #Saved as for instance spread-desktop #use as follows ./spread-desktop path-to-created-shortcut-file.desktop #remember to make this script runnable with chmod 755 spread-desktop #If your users home directories are not located under home0, you have to #change the variable HOMEDIRS underneath to reflect this. #If the home areas are in different directories under #/skole/tjener/home0, for instance /skole/tjener/home0/2004-A, #add several paths in HOMEDIRS and separate them with a space character. #For instance HOMEDIRS="/skole/tjener/home0/2004-B /skole/tjener/home0/2004-A" # HOMEDIRS="/skole/tjener/home0" # # If there is a "Desktop directory, we copy it in. copykde () { if [ -d $U/Desktop ] then cp -a "$FILE" $U/Desktop DEST="`basename \"$FILE\"`" chown --reference=$U/ $U/Desktop/"$DEST" fi } while [ $# -gt 0 ] do FILE="$1" if [ -f "$FILE" ] then #Find all directories under /home for H in $HOMEDIRS do USERLIST="`ls -ad $H/*`" if [ "$USERLIST" ] then # for each user for U in $USERLIST do copykde done fi done fi shift done
This script could for instance be saved in the home directory of root. In this example with the file textdoc.desktop having been created under the test user, the command that spreads this file to all users will be:
./spread-desktop /skole/tjener/home0/test/Desktop/textdoc.desktop