Is It Possible to Have a Shortcut Button Assigned to Eject USB HDD?

Hi eager

Sorry for late reply just tested mapping a button to script and works well unmounting drive. Works with longpress too. An an extra step i also mapped a button to remount an ejected drive again.

Ok here are steps:

  1. Download the winscp program and install it on your pc WinSCP :: Official Site :: Download

  2. Open winscp. Select new site. Fill in the details as follows
    File Protocol: SCP
    Host Name: Enter ip address of your vero
    Port Number: 22
    Username & Password: If you haven’t changed the username or password before then it osmc for both

    Click on advanced. Select scp/shell on left hand side column. In shell dropdown menu change from default to sudo su -.
    Warning: I recommend you change this back to default after you have finished this tutorial as you are able to delete system files with this enabled.

    Click ok and select save. Tick the remember passoword box. Click login.

  3. Next download putty program here and install Download PuTTY: latest release (0.79)

Open putty. Put in vero ip address in host name and click open. Enter vero username and password when prompted.

  1. Run command blkid. You should see line like /dev/sda1 or sdb1. If you have 1 hard drive attached this is your hard drive.

  2. Next open notepad and paste the following into it. Change the sda1 if yours is different.

#!/bin/sh

sudo umount /dev/sda1
exit

  1. Save the file as Unmount.sh to desktop.
    Make sure you dont save as a text file. Select all files from the drop down menu when saving

  2. Go back to winscp. On left hand column navigate to your desktop. On the right navigate to your osmc folder /home/osmc/

  3. Drag and drop the Unmount.sh file over from desktop to osmc

  4. Right click on Unmount.sh select properties. And tick all the R,W,X boxes. Click ok.

  5. Next navigate to folder /home/osmc/.kodi/userdata/keymaps

  6. Next double click on the keyboard.xml or gen.xml file.

  7. Add your key you want to map the key too like the following. I used f1 key but you can choose any key instead just replace f1.

        <keymap>
         <global>
          <keyboard>
              <f1 mod="longpress">System.Exec(/home/osmc/UnmountDrive.sh)</f1>
           </keyboard>
          </global>
          </keymap>
    

Note: If you are using a remote instead of a keyboard you may need to install the keymap editor addon in the kodi repo and run it and map something to the button you want to use to get the right key id. When keymap editor is saved. Open the xml file in /home/osmc/.kodi/userdata/keymaps. There should be a line similar to < key id=“61531”> where the id is your button id. So replace the f1 line above to something like

< key id=“61531” mod=“longpress”>System.Exec(/home/osmc/MountDrive.sh)< /key>

  1. Save xml and go back to putty and run the command

Sudo systemctl restart mediacenter

Hopefully now when you hold down your button the hard drive removal message should pop up.

Hope this helps :slight_smile:

4 Likes