WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: extension for usb storage automount, with eject button  (Read 1521 times)

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1511
extension for usb storage automount, with eject button
« on: November 24, 2020, 12:01:30 AM »
I created a custom extension for my own use but thought I'd share it in case it is useful to others.

The extension is called  usb-automount.tcz  and is pretty minimalistic--just a udev rule, two shell scripts, and an icon. While the extension is loaded, plugging in usb storage devices cause the devices to be immediately mounted and opened for browsing in user's GUI file manager. Each mounted device has an associated "eject" button on user's wbar or on user's desktop panel*.

The extension works with any window manager/desktop environment and any GUI file manager. All you need to tweak are the four preference settings in ~/.config/usb-automount.conf

I'll submit the extension for TCL x86_64 but it should work in other architectures as well.

* For a panel icon, you need a panel of some kind (obviously) and the  yad.tcz  extension.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11629
Re: extension for usb storage automount, with eject button
« Reply #1 on: November 24, 2020, 12:51:21 AM »
Hi GNUser
I've been running something similar since last year:
http://forum.tinycorelinux.net/index.php/topic,23337.msg146183.html#msg146183
It works with USB, card readers, and CD drives. I didn't bother auto-launching a file manager. I use the mount tool to
unmount partitions when I'm done with them. If the mount tool is left open, my script updates the number of buttons
as devices are added and removed.

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1511
Re: extension for usb storage automount, with eject button
« Reply #2 on: November 24, 2020, 08:48:04 AM »
I wish I had seen that. Oh, well. It was fun rolling my own, anyway.

Two things I like about mine (not bragging, just saying):
1. The eject icon stays "in my face" until the device is ejected. This helps me not yank out drives that are still mounted.
2. Each eject icon is labeled with the device's volume label. I like TCL's mount tool and I do use it for system partitions, but for usb drives I prefer my solution because when multiple usb drives are connected, buttons called "Eject Patriot" and "Eject Kingston" are easier for a human to grasp than toggle buttons for "sdc1" and "sdd1".

My extension is attached in case anyone wants to try it. For those who care about this sort of thing (as I do), the scripts are free software (GPLv3). All you need to do to use the extension is this:
1. Load the extension
2. Create  ~/.config/usb-automount.conf  to specify your four preferences. Mine looks like this:
Code: [Select]
mount_dir=/mnt
file_manager=xfe # change to your GUI file manager
icon=/usr/local/share/icons/eject.png # this icon is included with the extension but you can use any icon you want
icon_method=yad # must be either yad or wbar
That's it! Now just plug in a usb drive and enjoy.
« Last Edit: November 24, 2020, 08:54:09 AM by GNUser »