HAL Devices Menu

Does anyone know if a script exists that would dynamically generate a menu of current mountable volumes detected by hal such as cds/dvds/usbdisks etc. Also maybe provide some actions depending on the volume type?

If not any suggestions on what the best way to implement this would be and what would have to be looked into :stuck_out_tongue:

If you can provide typical sample output from this command, then, yes.

– Thomas Adam

Sorry I hadn’t replied. Ya I not sure what command you could really parse output from maybe lshal. But I think it might be possible to communicate with hal directly via dbus. I believe that is how ivman and gnome-volume-manager and what not work?

Assuming you just wanted a menu of currently mounted devices, parse the output of the ‘mount’ command. Or is that not what you’re wanting?

– Thomas Adam

Not quite. Wanted each device to have some options associated with that type. Like for floppy/usbdisk i could unmount it, browse it. cds could eject and such. Would be even nicer if for instance audio cd there was option to rip cd and such.

You can still script this, using mount and some options associated with each device. Crude, perhaps, but possible.

– Thomas Adam

But its impossible with mount to determine if the cd is say an audio cd, data, or dvd movie.

Maybe give ‘ivman’ a try, it mounts the things automatically and I think it is capable of doing stuff with the mounted media.

but I guess it would be possible to generate a menu using lshall.
but I’m affraid I can’t help you much, as I’m not very familiar with ‘sed’.
I guess you’ll need ‘grep’ and ‘grep -v’ first to loose the garbage of lshal. Once you have a combination of commands that gives you the lines mentionning the devices that are detected (also unmounted stuff if I’m not mistaken), you can use ‘sed’ to remove unwanted stuff from a line of the output of the previous command.

I once looked at sed trying to understand it, as I saw it being used in many scripts to generate menus etc., but I still find it a bit difficult to use it.

well, I might give it a try later today…


Ya I think you can get ivman to execute different programs/scripts when certain media is detected. I guess I could probably right some kind of script that would write different info on what is currently mounted/pluged-in and what type of media it is into a simple easy to parse file. That way I could just have another script parse the file and generate the menu. Probably easier then trying to parse the output of lshal…

Oh and I am not sure if it can perform actions on removal of media, I hope so anyway.

you might also take a look at Brice13’s config. he made a disk-mounter script to mount/umount things. It also shows different icons in case the drive is mounted/umounted

It is an old post, but an interesting matter. I don’t know much about udev, hal and dbus. but maybe at it is possible to check something in /sys. This link can help (inclusive the links on the page): HAL and device management

A problem seam to be at udev, hal and dbus are independant from the wm. So, the mount-umount operation as well as other actions (as to start an audio player or whatever) have to be done at the system level, not at the wm level. This: HOWTO D-BUS, HAL, KDE media:/ and this: HOWTO ivman can be useful.

This cannot add or remove something from the fvwm menu, but ivman can write or remove a file, maybe directly or with a seperate script, file that can be used by the menu generation feature of fvwm.

Another way would be to not use ivman but write a program, some kind of new fvwm module for that, but it will require more programmer skils.

I hope at this reflexion can help someone.

I have recently used udev to automount devices (without ivman) giving a simple and powerful automount system you can use in fvwm that has nothing to envy to KDE. There is an example in this post. Cheers!

A little update on this.

The output of mount will give you the mounted partitions/drives and their mount points.

To determine the media type associated actions, you can check /sys/block/*/device/media.

I have a little more question: are “mount” and “/sys/block/*/device/media” portable?


– Thomas Adam

Well, I guess than, if I want to incorporate such a function into fvwm-crystal, I must separate it into 2 parts, a system specific part and a fvwm specific part.

On linux, the system specific parts can be some udev rule(s) that will interact in some way with fvwm. As example, the udev rule(s) can maintain a file with a defined syntax, file that can be used inside fvwm by the icon-launch function. That way, on other systems, folks will only have to contribute a way to create and maintain this file.

That’s hardly useful either, is it?

What is it you’re trying to do?

– Thomas Adam

I am working on the Amiga recipe (among other things) . On the real machine, it was desktop icons for every mounted drive and for the ram disk. I feel they are handy. And also I like to have some nice picture on my desk, and to click on a desk icon is a good opportunity to take a look at it.

I want some function that will launch an icon on the desktop for every mounted partition. For now, I check mtab and launch icons only for the drives/partitions (stuffs beginning with /dev/*). It is easy to associate actions to the icons like to launch a file manager with the corresponding path (thunar at that time).

I am also working on the next release, but that’s another story. Those desktop icons will be implemented only into the Amiga recipe, and they are not my top priority for this release.

B.T.W. Thomas, what is the problem with mount and portability?

Hello all,

Join our listening and speaking English For Nurses courses online, Learn basic english related to the medical and Health at PELA Online. For more info: https://www.pelaonline.com/courses/listening-speaking/