dinsdag 28 juli 2009

Samba shares in Thunar (file manager of Linpus Lite)

Wow, I just found this very handy forum posting explaining how to mount a Windows (or Samba) share on Linpus. I don't know if Linpus has been updated, because earlier I wasn't able to let Thunar (the default file manager) open smb shares.

I will be using the words Samba or smb because I have my shares on a Linux computer.

Part 1: create a script which will mount the samba share


First of all, create a directory in /mnt/. For example /mnt/windows, /mnt/samba or /mnt/<servername>
sudo mkdir /mnt/samba

Now, create a new file called /root/samba-share.sh with the following content
#!/bin/bash
/bin/df -k | /bin/grep /mnt/samba > /dev/null
if [ $? != 0 ]; then
sudo /sbin/mount.cifs //<server>/<share> /mnt/samba -o user=<user>%<password>
fi
/usr/bin/launch-thunar.sh /mnt/samba


You will have to insert your own servername (or ip address), share, username and password. If your server allow anonymous logins, you can replace "user=<user> password=<password>" by "guest".
Let's go through the script. The first line checks if the share is already mounted. If so, the mounting by mount.cifs is skipped.
Finally the graphical file manager Thunar is opened at your samba share.

You will have to make this file executable with the command
sudo chmod 755 /root/samba-share.sh

Part 2: create a desktop item and show it in the interface


We will create a file called /usr/share/applications/sambashare.desktop
In this directory all desktop items are placed. These items are used by the default interface.
In this file we'll put
[Desktop Entry]
Name=My Samba Share
Comment=Files shared on Samba server
Exec=/root/samba-share.sh
Icon=mydownload.png
Terminal=0


Now, just add this desktop item to the files menu. Open the file /home/user/.config/xfce4/desktop/group-app.xml and add the following line to the group with id=8 (search for <id>8</id>).
<app sequence="6">/usr/share/applications/sambashare.desktop</app>
This will have added an icon the the files menu. A reboot is needed to show it, though.

Clicking the icon will open Thunar at the samba share.

1 opmerking:

  1. this has nothing to do with thunar mounting anything. You are using a script to mount a share and open a file manager at that location. It could have been any other useless file manager as well.

    BeantwoordenVerwijderen