8

I don’t use VLC that much to have it there, so I would like to remove it from the sound menu in the top right. I found a small image to show what it looks like (the sound menu is open and shows VLC along with other music players).

enter image description here

Sorry for giving a very low resolution image.

  • I asked this question before, so this is sort of a duplicate. Although this asks just about removing VLC from the sound menu, versus stopping it from continually appearing. Not sure if both answers should stay open. askubuntu.com/questions/455940/… – Aibara May 23 '14 at 16:54
  • Nick, I edited my answer to prevent it from (permanently) reurning to the soundmenu. – Jacob Vlijm May 23 '14 at 18:48
  • yep, it keeps appearing whenever i use vlc. im looking through internet tutorials of how to disable it in preferences and cant find it cuz my version is too new. its called "D-Bus" – Nick Bailuc May 24 '14 at 19:17
  • Possible duplicate: askubuntu.com/questions/177652/disable-vlcs-mpris-plugian – Exeleration-G Dec 8 '15 at 2:24
13
  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.

  • 2
    This fix works as well! – Aibara May 24 '14 at 18:35
6

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)
  • I did the terminal method because I didnt want to install unneeded applications. thank you, it worked instantly – Nick Bailuc May 19 '14 at 16:02
  • 1
    I agree! if not necessary, I'd prefer not to install addition software. Glad it worked out. – Jacob Vlijm May 19 '14 at 16:05
  • But it will be readded as soon as you open VLC again... – Aibara May 23 '14 at 16:36
  • Correction: as soon as you start playing a video in VLC again. – Aibara May 23 '14 at 16:50
  • 1
    @NickBailuc I tried, and you are right, I will get back to you on this! – Jacob Vlijm Jun 14 '14 at 18:33
1

Show user defined applications in the soundmenu only if they run

The solution below is flexibly usable for mutiple applications at once with a position in the sound menu. User can define (and change) which applications have a permanent position in the menu, and which ones should be removed from the sound menu after they are closed.

enter image description here enter image description here

What it is and what it does

The solution exists of a script that runs from startup (login). It allows user defined applications to appear in the sound menu, but removes those applications from the soundmenu after they close.

The script has no effect on the functionality of the desktop files. I could not notice any effect on the processor load, memory usage is negligible.

how to use

  • Copy the script below into an empty file, save it as cleanup_soundmenu.py

  • In the line starting with no_show =, applications are set which should be cleaned up from the menu after they are closed. Two examples are set: ['rhythmbox', 'vlc']. The names are derrived from their desktop files, stripped from .desktop.

  • In the line, starting with cleanup_interval, user can define the interval between the clean up checks. By default it is 10 seconds.

  • Add the following line to Startup Applications (Dash > Startup Applications > Add):

    python3 /path/to/cleanup_soundmenu.py
    

On next login, defined application will be cleaned from sound menu if they are not running.

The script

#!/usr/bin/env python3

import subprocess
import time
import getpass

no_show = ['rhythmbox', 'vlc'] # add names here, to set apps not to show
cleanup_interval = 10 # cleanup interval (in seconds)

curruser = getpass.getuser()

def createlist_runningprocs():
    processesb = subprocess.Popen(
        ["ps", "-u", curruser],
        stdout=subprocess.PIPE)
    process_listb = (processesb.communicate()[0].decode("utf-8")).split("\n")
    return process_listb

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

def set_soundmenu(new_list):
    # set the launcher contents
    subprocess.Popen([
        "gsettings", "set",
        "com.canonical.indicator.sound",
        "interested-media-players",
        str(new_list)])

def check_ifactionneeded():
    snd_items = read_soundmenu()
    procs = createlist_runningprocs()
    remove = [item+".desktop" for item in no_show if not item in str(procs)]
    if len(remove) != 0:
        for item in remove:
            try:
                snd_items.remove(item)
            except ValueError:
                pass
        return snd_items
    else:
        pass

while 1 != 0:
    new_list = check_ifactionneeded()
    if new_list != None:
        set_soundmenu(new_list)
    time.sleep(cleanup_interval)
  • Yes it works, but running a check every 10 secondes for an event that may happen once or twice per session seems extremely inefficient. – Lilley Mar 11 '15 at 0:24
  • @Lilley getting values from gsettings is extremely light, and be aware of the fact that the system runs all kinds of loops constantly. – Jacob Vlijm Mar 11 '15 at 5:23
1

Ubuntu 14.04 simple solution (only one command, no sudo, no script).

Open Terminal application, then copy, paste and execute one of the following command. After that the sound indicator will be automatically cleaned out after VLC exits.

  1. don't leave any entry within the sound indicator:

    (mkdir -p ~/.local/share/applications);(cp /usr/share/applications/vlc.desktop ~/.local/share/applications);(sed -i 's/Exec=\/usr\/bin\/vlc --started-from-file %U/Exec=sh -c "\/usr\/bin\/vlc --started-from-file %U; gsettings reset com.canonical.indicator.sound interested-media-players"/' ~/.local/share/applications/vlc.desktop)
    
  2. leave Rhythmbox entry within the sound indicator:

    (mkdir -p ~/.local/share/applications);(cp /usr/share/applications/vlc.desktop ~/.local/share/applications);(sed -i 's/Exec=\/usr\/bin\/vlc --started-from-file %U/Exec=sh -c "\/usr\/bin\/vlc --started-from-file %U; gsettings set com.canonical.indicator.sound interested-media-players \\\"['\'rhythmbox.desktop\'']\\\""/' ~/.local/share/applications/vlc.desktop)
    
  3. undo changes:

    rm ~/.local/share/applications/vlc.desktop
    
0

This an article about how to add this feature do the opposite scenario:

Tools -> Preferences -> all -> Interface -> Control Interface -> D-Bus Control interface

  • 3
    This option is no longer present in VLC. – Aibara May 25 '14 at 17:02
  • D'oh it exists for me, perhaps i've an old version .. – Hedwig May 25 '14 at 17:30

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.