Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
Hi, So I'm running Fluxbox as my window manager in Xubuntu. I use ivman to automatically mount any usb devices. Now I was wondering if it's possible to have conky ...
  1. #1
    Just Joined!
    Join Date
    Mar 2006
    Posts
    26

    Conky Display all Mounted Drives

    Hi,

    So I'm running Fluxbox as my window manager in Xubuntu. I use ivman to automatically mount any usb devices.

    Now I was wondering if it's possible to have conky display all mounted drives and some information about them.

    I saw you can do {$ifmounted /media/blah} but this would assume I have a set number of devices preconfigured in fstab. It doesn't account for some random guy's flash drive, or a buddy's smartphone.

    I know mount | grep sd outputs a list of mounted drives. So then could I somehow format that output and pass it to conky? Or do you guys have any more clever ideas on how I could accomplish this?

  2. #2
    Trusted Penguin Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,393
    You could look at the output of 'df', which gives a list of the sizes of the available drives. Sometimes I find this output to be easier to read than 'mount'.

    You could also try grepping around in the /proc directory - start by looking at 'partitions' or 'diskstats'.
    Linux user #126863 - see http://linuxcounter.net/

  3. #3
    Just Joined!
    Join Date
    Mar 2006
    Posts
    26
    Thanks for the advice.

    I came up with the following command:

    df | sed '/none/d' | sed 1d | cut -d% -f2

    This displays all current mount points, line by line, e.g.:

    /
    /media/usb

    I can pass this info to conky, which is sort of okay, but how could I manipulate the output in order to get information such as fs_free_perc or fs_bar?

  4. #4
    Linux Engineer Segfault's Avatar
    Join Date
    Jun 2008
    Location
    Acadiana
    Posts
    855
    You could use /etc/mtab

  5. #5
    Just Joined!
    Join Date
    Dec 2007
    Posts
    16
    So, did you find a clean way of doing it?
    for now I have all my drives listed in my conkyrc file, which is kinda messy since I can have at most 3 drives installed at a time.

  6. #6
    Just Joined!
    Join Date
    Mar 2006
    Posts
    26
    I kinda gave up on it to be honest. When you have a bunch of flash drives, external hard drives, etc., fstab just doesn't cut it. So I'm using some application to automatically mount the drives for me.

    So if I wanted to get a beautiful, automatically updating conkyrc displaying all the mounted drives, I'm not sure how I would do it. You might have to configure whatever application is mounting the drives to also update a text file or run a script which would get the right info displayed in conky.

    Let me know if you figure something out.

  7. #7
    Just Joined!
    Join Date
    Dec 2007
    Posts
    16
    Well, I just threw this together after your post. I guess this is what I'm using now.
    It'd be nice to hook the percentage up to a "bar" so that it would have visual representation of the percentage.

    Code:
    ${exec df -h | grep "/dev/sd" | awk '{ printf "%s of %s \t : %s\n", $5, $2, $6 }' }

  8. #8
    Just Joined!
    Join Date
    Mar 2006
    Posts
    26
    That's amazing. I didn't know awk could split an output like that, just with the number of which entry you're looking for.

    As for the bar, can't you just do:

    execbar$(df -h | grep "/dev/sd" | awk '{ printf "%s", $5 }'

    then that would just leave the matter of re-executing that command every time a drive is added or removed.

  9. #9
    Just Joined!
    Join Date
    Dec 2007
    Posts
    16
    Quote Originally Posted by arrow.69 View Post
    That's amazing. I didn't know awk could split an output like that, just with the number of which entry you're looking for.

    As for the bar, can't you just do:

    execbar$(df -h | grep "/dev/sd" | awk '{ printf "%s", $5 }'

    then that would just leave the matter of re-executing that command every time a drive is added or removed.
    That only creates one.
    I was hoping that I could have one for each file system.
    Anyway, having percentages is better than nothing.

  10. #10
    Just Joined!
    Join Date
    Dec 2007
    Posts
    16
    update!
    I wanted to add the "free space" of drives, so I edited the code:
    Code:
    df -h | grep "/dev/sd" | awk 'BEGIN { print "free\ttotal\tfull" } { printf "%s\t%s\t%s\t%s\n", $4, $2, $5, $6 }'
    Let me know if you have any ideas.

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...