Main index > About existing desklets > mounter

By darkliquid (Desklet Author), on Thu Apr 7 09:19:25 2005: mounter.

I have written a new desklet for creating icons on the desktop with which you can (un)mount devices. Hopefully some people will find it useful!

The code is on my wiki as usual: mounter desklet

Screenshot:
http://www.darkliquid.co.uk/media/projects/aDesklets/mounter-aDesklet-1.jpg

By darkliquid (Desklet Author), on Thu Apr 7 11:23:37 2005.

I have just updated it to version 0.2.0, now custom captios are possible and a bug is fixed in the free disk space indicator drawing section.

By geoSlack (User), on Thu Apr 7 12:40:56 2005.

Very nice....
Would it be too difficult to add the possibility of launching a file manager when the drive is mounted? Like if I click on the cd-rom icon in fluxbox, the drive would be mounted and rox would open up the /mnt/cdrom directory. Would that be hard to implement?
-geoSlack

By darkliquid (Desklet Author), on Thu Apr 7 12:50:59 2005.

I shouldn't be too hard, but at the moment clicking is used for toggling the mount status of the drive, so I'd have to investigate other options.

One idea I just had is to optionally move the toggle mount command into the right-click menu and have clicking launch a filemanager instead.

ie: add a 'filemanage_on_click' bool to set what mode you are in and shuffle things accordingly and look at a 'filemanagemer' variable for running the filemanager.

I'll probably get round to it when I fix the flickering problem. Be done soon hopefully :D

By ZeroDivide (Desklet Author), on Thu Apr 7 22:32:55 2005.

Nice desklet darkliquid, I find it very handy :)

I did notice one little glitch though..
If you start the desklet with show_free_space=False and the drive is already mounted, the desklet crashes.

Its an easy fix " as im sure you know :) ", heres how I fixed it.

Code:

class MounterDesklet(object):
    def __init__(self, config, basedir):
        self._show_free_space = self.config['show_free_space']



ZeroDivide

By darkliquid (Desklet Author), on Fri Apr 8 08:08:15 2005.

Right, I've fixed all the bugs (famous last words). I've got rid of the flickering finally and implemented the requested features which all seem to work so far under basic testing.

Look out for the new release soon.

By cRoMo (User), on Mon Apr 11 10:53:10 2005.

I've notced that there is no possibility to have no icon caption at all. It'd nice to have it :)

Isn't it possible to have a few mount-points set for one mounter's session? I personally think it's stupid to pay 9MBs (python + adesklets, according to 'ps aux') for every another mounting point :)

By darkliquid (Desklet Author), on Mon Apr 11 11:47:39 2005.

Having no icon caption at all will be easy enough to implement, I'll have a go at that soonish.

As for have a single mounter session contain multiple mount-points, etc, that should be possible too, though it will be a while before anything like that happens as it will require a fair amount of work. Also, initially it will support displaying them vertically stacked, much like the screenshot of the four mounters running at once.

I'm not sure how reliable the ps aux is in this case, each mounter adesklets session reports 0.3% of my memory and each mounter python session reports the same. All of that from my 1GB memory = 24.5MB for running 4 mounters, though if I take all my other memory usage statistics, it doesn't add up to the amount of memory being used, so I am reluctant to use ps aux output as a definitive guide to memory usage, at least on my system :P

Regardless, I will have a look at working on all of the previously mentioned features and try and implement them in due course.

By syfou (Core Developer & Desklet Author), on Mon Apr 11 12:45:01 2005.

In both linux 2.4 and 2.6, the virtual memory pages allocated by a shared library by anything that is not simple malloc (Imlib2 is in this case) is counted multiple time (once per process), and initial memory taken by Imlib2 is 2 to 3 MB on my system. A rough estimate through valgrin shows that an new empty desklet of 100X100 pixels use about 1MB of new allocated memory with pseudo-transparency on.

By cRoMo (User), on Mon Apr 11 16:05:29 2005.

syfou wrote:

an new empty desklet of 100X100 pixels use about 1MB of new allocated memory with pseudo-transparency on.

But what about python? It also takes a cuple of megs each desklet. Anyway, to be honest, I supposed adesklet to be really reasource-saving, but it seems that it's just not :(

By Ryanx0r (User), on Mon Apr 11 16:28:20 2005.

It is, compared to other's like gDesklets and Karamba.
(snapshot form ps)

acid 2102 0.0 0.6 8016 5304 ? S 12:53 0:00 python /home/acid
acid 2103 0.0 0.6 8016 5308 ? S 12:53 0:00 python /home/acid
acid 2104 0.6 0.5 6344 4300 ? S 12:53 3:55 python /home/acid
acid 2105 0.0 0.7 8760 6016 ? S 12:53 0:01 python /home/acid
acid 2129 0.0 0.5 8036 4600 ? S 12:53 0:03 adesklets /home/a
acid 2130 0.0 0.5 7720 4276 ? S 12:53 0:04 adesklets /home/a
acid 2131 0.0 0.5 7820 4416 ? S 12:53 0:04 adesklets /home/a
acid 2132 0.4 0.6 8508 5024 ? S 12:53 2:21 adesklets /home/a

Notice that the mem% isn't too high. I've got 4 desklets running.
and lets be honest here. You can't have something this sexy for free aye :) (free as in, hardly any RAM usage).

By syfou (Core Developer & Desklet Author), on Mon Apr 11 17:08:06 2005.

Well, depending of what Python you use, you often have the same kind of ill-reported memory info. Also through valgrind, launch cost of python with the adesklets package is in from 2 to 5 MB of virtual memory. Supplementary cost for each new desklet is around 200 KB on my system. So I found my measurements in the documentation to be accurate.

I should also point-out that this is virtual memory, not real memory use. Both Python and Imlib2 set up in-memory caches, initially empty, but allocated anyway. So, if you are short of memory, unused page will just go to the swap. I have a 486 DX 66 with linux 2.2 and 64 MB of RAM. If am running about 5 desklets on it, without even hitting the swap, even if I have a huge (34 MB of virtual memory right now) email server process running on it..

By cRoMo (User), on Thu Apr 14 04:04:02 2005.

One more thing I wish mounter had: possibility to mount two devices at once. What is this needed for? For exapmle, there are some mp3 players that have internal and external (flash card) memory. Each time you connect them, most likely kernel will find two devices. So it would be nice to be able to mount both of them atonce with only one mounter desklet :)

By darkliquid (Desklet Author), on Fri Apr 15 05:30:19 2005.

cRoMo wrote:

One more thing I wish mounter had: possibility to mount two devices at once. What is this needed for? For exapmle, there are some mp3 players that have internal and external (flash card) memory. Each time you connect them, most likely kernel will find two devices. So it would be nice to be able to mount both of them atonce with only one mounter desklet :)


Well, this is somewhat more complex t implement because I'll have to change a fair few things.

It's a pity you cant have some kind of 'virtual mount point' that would mount all the devices underneath it.

Th easiest way I guess would be to provide a list of mount points, and for it to iterate through the list, mounting, unmounting etc.

Well, I'm not sure if this will happen anytime soon, but I'll look into it. I'm quite busy at the moment, uni is coming to the runch point at the moment *sweat*

By syfou (Core Developer & Desklet Author), on Fri Apr 15 13:49:56 2005.

A possibility would be to let people specify via the configuration file what commands (or scripts) to use for mounting and unmounting the drive(s), while giving default. This way, any sequence of operation could be performed, and this would also work on platform that implements mounting in different ways.

Of course, you would also need to decide how to pass the possible parameters (as a command line argument seems enough), and how to interpret return code, in case the operation fails, but this is anything but complicated..

By cRoMo (User), on Fri Apr 15 15:28:51 2005.

syfou wrote:

Of course, you would also need to decide how to pass the possible parameters (as a command line argument seems enough), and how to interpret return code, in case the operation fails, but this is anything but complicated..


Besides at the moment there is no return code interpreting in mounter, so nothing changes actually as this is the stuff in todo list.

Methinks this is a good idea :)

By allucid (User), on Sun Apr 17 18:11:25 2005.

is there somewhere I can get more icons that match the included ones for the CDROM? I use mounter for USB pen drives and one of my hard drives and right now I am using the CDROM png's for everything. It works, just looks a bit odd. ;)

By CitizenX (Themer / Graphic Artist), on Sun Apr 17 23:20:36 2005.

I've got this...

http://home.comcast.net/~iibagod/usbicon.png

By allucid (User), on Mon Apr 18 19:15:58 2005.

found the icon theme here.

By ohm314 (User), on Tue Apr 19 11:13:22 2005: sudo option.

Hi darkliquid

I have another little suggestion to make...

Some linux distributions (gentoo is one of them) only allow (u)mount (and similar commands) for root per default. To be able to use mount/umount as a normal user, one would usually install sudo, set an apropriate rule and use mount through sudo.

So i would suggest adding an option into mounter to allow the use of sudo.

I have already tried to add this feature into my mounter desklet..
Here is what i have done:

The main change is in the toggleMount function were we would have to add a test if the sudo option is True. This changes the function to:

Code:


        def toggleMount(self):
                f = open("/etc/mtab")
                mtab = f.read()
                f.close()

                if self.config['use_sudo']:
                        sudo_prefix = "sudo "
                else:
                        sudo_prefix = " "

                if find(mtab, self.config['mount_point'])!=-1:
                        popen(sudo_prefix+"umount "+self.config['mount_point'])
                else:
                        popen(sudo_prefix+"mount "+self.config['mount_point'])
                self.display()



To support this change, we need now a new line in the configfile

Code:


...
 'use_sudo': True}



and of course a line in the cfg_default list:

Code:


cfg_default = { 'mounted_icon': 'cdrom_mount.png',
                       ...
                      'filemanager': 'rox',
                      'use_sudo': False }



(i am not really familiar with python, so sorry for the bad style - for me it seems to be working just fine this way)

just for completeness:
the line in the sudoers file I use is:

Code:


username    LOCALHOST=              NOPASSWD: /bin/mount /mnt/cdrom ,/bin/umount /mnt/cdrom



I hope this feature will make it into a future version.

ohm314

By allucid (User), on Tue Apr 19 11:27:03 2005.

sudo is unnecessary. Edit fstab and for devices you want to be able to mount add 'user' to the fourth column:

Code:

/dev/usbkey             /mnt/usbkey     auto            noauto,user             0 0

By ohm314 (User), on Tue Apr 19 11:38:17 2005.

oops, ok you are absolutely right...
i havent really looked at all options in fstab..

hm.. this makes my post kind of stupid/useless..

thanks anyway

ohm314

By syfou (Core Developer & Desklet Author), on Tue Apr 19 13:15:07 2005.

If I may: all those special cases, if they are needed, would be more easily implemented using my previous suggestion (see the bottom of last page): implementing a call to mount script mechanism... But I believe darkliquid is just a bit taken elsewhere right now.

By bhalash (User), on Wed May 11 23:32:42 2005.

Hello!

I'm a newish user of adesklets and I've run into a problem configuring mounter. I change the config.txt to add my flash drive as below:

Code:

id3 = {'caption_font': 'VeraBd',
 'caption_font_color': '666666',
 'caption_font_size': 12,
 'custom_caption': 'CDROM',
 'delay': 60,
 'filemanager': 'rox',
 'filemanager_on_click': False,
 'free_space_color': 'AAFFAA',
 'free_space_width': 8,
 'icon_height': 64,
 'icon_width': 64,
 'mount_point': '/mnt/cdrom',
 'mounted_icon': 'cdrom_mount.png',
 'padding': 4,
 'show_free_space': True,
 'unmounted_icon': 'cdrom_unmount.png',
 'use_custom_caption': False

 'caption_font': 'VeraBd',
 'caption_font_color': '666666',
 'caption_font_size': 12,
 'custom_caption': 'Flash Drive',
 'delay': 60,
 'filemanager': 'rox',
 'filemanager_on_click': False,
 'free_space_color': 'AAFFAA',
 'free_space_width': 8,
 'icon_height': 64,
 'icon_width': 64,
 'mount_point': '/mnt/flash',
 'mounted_icon': 'usbdisk_mount.png',
 'padding': 4,
 'show_free_space': True,
 'unmounted_icon': 'usbdisk_unmount.png',
 'use_custom_caption': False}


However, it returns a syntax error as below:

Code:

Traceback (most recent call last):
  File ".desklets/mounter-0.3.0/mounter.py", line 227, in ?
    Events(dirname(__file__)).pause()
  File ".desklets/mounter-0.3.0/mounter.py", line 181, in __init__
    adesklets.Events_handler.__init__(self)
  File "/usr/lib/python2.3/site-packages/adesklets/events_handler.py", line 157, in __init__
    self.ready()
  File ".desklets/mounter-0.3.0/mounter.py", line 190, in ready
    join(self.basedir,'config.txt'))
  File ".desklets/mounter-0.3.0/mounter.py", line 44, in __init__
    adesklets.ConfigFile.__init__(self,id,filename)
  File "/usr/lib/python2.3/site-packages/adesklets/configfile.py", line 159, in __init__
    self._load_and_save()
  File "/usr/lib/python2.3/site-packages/adesklets/configfile.py", line 202, in _load_and_save
    all= ConfigImport.load(buf[:])
  File "/usr/lib/python2.3/site-packages/adesklets/configfile.py", line 41, in __call__
    return dict(self._group(
  File "/usr/lib/python2.3/compiler/transformer.py", line 50, in parse
    return Transformer().parsesuite(buf)
  File "/usr/lib/python2.3/compiler/transformer.py", line 120, in parsesuite
    return self.transform(parser.suite(text))
  File "<string>", line 25
    'caption_font': 'VeraBd',
                 ^
SyntaxError: invalid syntax


I'm oviously missing something on this and no amount of searching and experimenting has provided any clues.

Would anyone be able to shed light on this?

By syfou (Core Developer & Desklet Author), on Wed May 11 23:50:03 2005.

A comma is missing at the end of the

Code:


 'use_custom_caption': False 


line. Yours,

By darkliquid (Desklet Author), on Wed Jun 8 07:59:04 2005.

syfou wrote:

If I may: all those special cases, if they are needed, would be more easily implemented using my previous suggestion (see the bottom of last page): implementing a call to mount script mechanism... But I believe darkliquid is just a bit taken elsewhere right now.


Now my course is over I will be attempting to implement this shortly.

By xps (User), on Mon Aug 1 10:17:38 2005: ejectable option.

Hi!, here is a patch to add the "ejectable" and "eject_command" to the config file, the purpose of the options is obvious ;-)

Code:


--- mounter-orig.py     2005-08-01 16:05:29.903782616 +0200
+++ mounter.py  2005-08-01 16:04:33.580345080 +0200
@@ -40,7 +40,9 @@
                                        'filemanager_on_click': False,
                                        'filemanager': 'rox',
                                        'mount_command': 'mount',
-                                       'unmount_command': 'umount' }
+                                       'unmount_command': 'umount', 
+                                       'ejectable': True,
+                                       'eject_command': 'eject'}
 
        def __init__(self,id,filename):
                adesklets.ConfigFile.__init__(self,id,filename)
@@ -80,6 +82,10 @@
                        adesklets.menu_add_item('Toggle_Mount')
                else:
                        adesklets.menu_add_item('Filemanager')
+
+               if self.config['ejectable']:
+                       adesklets.menu_add_item('Eject')
+
                adesklets.window_show()
 
        def display(self):
@@ -168,6 +174,10 @@
                        popen(self.config['mount_command']+" "+self.config['mount_point'])
                self.display()
 
+       def eject(self):
+               popen(self.config['eject_command'] +" "+ self.config['mount_point'])
+
+
 #-----------------------------------------------------------------------------
 
 class Events(adesklets.Events_handler):
@@ -214,6 +224,9 @@
                        self._execute(self.config['filemanager'] + " " + self.config['mount_point'])
                if item=='Toggle_Mount':
                        self.mounter_desklet.toggleMount()
+                if item=='Eject':
+                        self.mounter_desklet.eject()
+
 
        def button_press(self, delayed, x, y, button):
                if self.config['filemanager_on_click']:

By sash (User), on Sat Nov 19 21:06:41 2005.

my copy of mounter crashes:

Code:

close failed: [Errno 10] No child processes
Traceback (most recent call last):
  File "./mounter.py", line 235, in ?
    Events(dirname(__file__)).pause()
  File "/usr/lib/python2.4/site-packages/adesklets/events_handler.py", line 228, in pause
    posix_signal.pause()
  File "/usr/lib/python2.4/site-packages/adesklets/events_handler.py", line 214, in _fire_event
    [x for x in
  File "./mounter.py", line 228, in button_press
    self.mounter_desklet.toggleMount()
  File "./mounter.py", line 175, in toggleMount
    self.display()
  File "./mounter.py", line 141, in display
    free_space_height = int((window_height-2) * self.__getFreeSpacePercentage())
  File "./mounter.py", line 161, in __getFreeSpacePercentage
    df_output = popen("df -h "+self.config['mount_point']).readlines()
IOError: [Errno 4] Interrupted system call


My mount point is /mnt/cdrecorder with the following fstab entry:


Code:

/dev/scd0       /mnt/cdrecorder iso9660   ro,user,noauto,unhide   0      0

By sash (User), on Sun Nov 20 01:43:09 2005.

sash wrote:

my copy of mounter crashes...


It seems to work well now--there was a runaway java_vm process on my machine that was hogging the CPU.

By Xophmeister (User), on Mon May 1 17:28:14 2006: How To Mount Multiple Drives.

Hi,

I'm probably being really stupid here, but how on Earth do you configure mounter for more than one mount point? At the moment, the only way I can think of is making as many seperate copies of mounter in one's .desklet directory (or symlinking them) and altering the relevant config.txt... That seems like a major hassle - so probably wrong!

Thanks :)

By syfou (Core Developer & Desklet Author), on Mon May 1 17:45:27 2006: Re: How To Mount Multiple Drives.

Xophmeister wrote:

how on Earth do you configure mounter for more than one mount point?

One instance of mounter will always handle a single mount point. Hence, just register as many instances as you need, as explained in the documentation (see chapter 4). Need to handle three mount points? Register three instances, then re-launch all your desklets (by using the adesklets command) and finally look into the desklet configuration file to customize each instance the way you want. Yours,


adesklets is proud to be hosted on:

SourceForge.net Logo

Back to adesklets.sf.net.