2

I tried to unlock partitions from the launcher, but they keeps reappearing after every reboot. Is there any good way to permanently remove partitions from the launcher?

This is happening only on Ubuntu 16.04

enter image description here

3
  • How about automatically mounting them on startup? Link. After mounting they dont show up anymore.
    – Videonauth
    Apr 24, 2016 at 11:04
  • When you unlock them from the launcher, are they actually blacklisted? See the answer here for instructions on how to check: askubuntu.com/questions/195988/…
    – Tobias
    Apr 24, 2016 at 11:14
  • Hi @Severus Tux. Not sure the issue is 16.04 specific. It occurs to me I've heard of it before. Anyway, posted a workaround. Please mention if you manage. Apr 24, 2016 at 11:56

1 Answer 1

5

Although the solution below is not a fix to what seems to be a minor bug, you can use it as a workaround to automatically blacklist devices on startup (log in).

The solution

...is a small script that remembers your blacklisted items on log in. It runs with two arguments: get and set. The first is to read the current blacklisted items, the second will (re-) set the list to the last read version.

In practice

  • Remove the devices from the Unity Launcher like you are used to.
  • Run the command /path/to/remember_blacklist.sh get This will make a snapshot of the currently blacklisted devices.

Now the next time you log in or restart, the blacklisted devices are automatically removed. Of course you can add the command to a shortcut.

How to use / set up

  • Copy the script below into an empty file, save it as remember_blacklist.sh

    #!/bin/bash
    
    arg=$1
    blacklist=~/.currblacklist
    key="com.canonical.Unity.Devices blacklist"
    
    if [ "$arg" == "get" ]
    then
     printf "$(gsettings get $key)" > $blacklist
    elif [ "$arg" == "set" ]
    then
      if [ "$(cat $blacklist)" == "@as" ]
      then 
        gsettings set $key []
      else
        gsettings set $key "$(cat $blacklist)"
      fi
    fi
    
  • make it executable (!)

  • Add the following to Startup Applications Dash > Startup Applications > Add. Add the command

    /bin/bash -c "sleep 10 && /path/to/remember_blacklist.sh set"
    
  • Remove the devices from the launcher as usual
  • To remember, run: /path/to/remember_blacklist.sh get

Explanation

If you remove a device from the launcher, it is blacklisted. You can read the current list of blacklisted devices with the command:

gsettings get com.canonical.Unity.Devices blacklist

This will output something like

['0A444ED409660B91-intern_1', '2899FAA548C61099-intern_2']

What the script does is:

  • when run with the argument get: it reads the current blacklist and saves the output in a hidden file: ~/.currblacklist
  • when run with the argument set: it reads the content of the file ~/.currblacklist and sets the blaclist with the command:

    gsettings set com.canonical.Unity.Devices blacklist <content_of_the_file>
    
4
  • Brilliant!!, do you mind telling me what is @as (12th line in your script). Thanks :-) Apr 24, 2016 at 12:15
  • @SeverusTux That's a secret code :), no seriously, if there are no items blacklisted, the command returns @as. This cannot be used to set an empty list however, then we need to use []. Apr 24, 2016 at 12:17
  • @SeverusTux you know that always makes me happy :) Apr 24, 2016 at 12:40
  • This scripts on a first attempt, but after restarting my session a second time all drives are back. Could there something wrong with my script? Or is this method no longer viable on newer Ubuntu versions? Oct 29, 2017 at 8:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.