Remove VLC player from sound menu in Unity bar

  1. Move VLC DBus plugin

    sudo mv /usr/lib/vlc/plugins/control/libdbus_plugin.so /usr/lib/vlc/plugins/control/libdbus_plugin.so.backup
    
  2. Open dconf-editor, Remove vlc.desktop from:

    /com/canonical/indicator/sound/interested-media-players
    

    Or just reset it through terminal

    dconf reset /com/canonical/indicator/sound/interested-media-players
    

Note: Someones may like to Modify sound indicator menu to hide controls from inactive player or remove it after closeing. In other words, Running players have full controls, Closed ones either only launcher (no control buttons) or disappear totally from menu.


How to remove VLC from the sound menu / How to prevent VLC from reappearing in the sound menu.

Removing VLC from the sound menu

GUI method

  • Install dconf editor
  • Open dconf-editor, and browse to: com/canonical/indicator/sound

enter image description here

  • In the list of soundmenu (interested-media-players) items, remove the application(s) you do not need / want to appear in the menu. Close the dconf-editor.

enter image description here

  • Done, VLC disappeared from the menu.

enter image description here enter image description here

Command line method

  • To read the current menu items:

    gsettings get com.canonical.indicator.sound interested-media-players
    

    gives an output like:

    ['rhythmbox.desktop', 'vlc.desktop']
    
  • To remove VLC, remove vlc.desktop from the list and set the changed menu by the command:

    gsettings set com.canonical.indicator.sound interested-media-players "['rhythmbox.desktop']"
    

Preventing VLC from returning in the sound menu (14.04)

The solution removes VLC from the sound menu, but if you start VLC, it will appear again in the sound menu. The script below does not prevent that, but immediately and automatically removes it once VLC is closed.

To use it:

Copy the script below, paste it in an empty textfile and save it as vlc, make it executable. Then copy the vlc.desktop file from /usr/share/applications to ~/.local/share/applications and replace the (first) line starting with Exec= by Exec=/path/to/script/vlc. Log out and back in. The desktopfile will be redirected to the script, the script will start VLC and wait for it to stop and remove VLC from the soundmenu immediately.

#!/usr/bin/python3
import subprocess
import getpass
import time

curruser = getpass.getuser()

def read_currentmenu():
    # read the current launcher contents
    get_menuitems = subprocess.Popen([
        "gsettings", "get", "com.canonical.indicator.sound", "interested-media-players"
        ], stdout=subprocess.PIPE)
    return eval((get_menuitems.communicate()[0].decode("utf-8")))

def set_current_menu(current_list):
    # preparing subprocess command string
    current_list = str(current_list).replace(", ", ",")
    subprocess.Popen([
        "gsettings", "set", "com.canonical.indicator.sound", "interested-media-players",
        current_list,
        ])

subprocess.call(["/usr/bin/vlc"])                    
current_list = read_currentmenu()
for item in current_list:
    if item == "vlc.desktop":
        current_list.remove(item)
set_current_menu(current_list)

Other applications

This method / script can also be used for other applications in the sound menu. Two lines in the last section of the script need to be altered then, according to the other application:

if item == "vlc.desktop":  (change to desktop file of the application)

and

subprocess.call(["/usr/bin/vlc"]) (change the command to run the application)