从 Unity 栏中的声音菜单中删除 VLC 播放器

Nic*_*luc 11 panel unity vlc indicator-sound

我不怎么使用 VLC 把它放在那里,所以我想从右上角的声音菜单中删除它。我找到了一个小图像来显示它的样子(声音菜单已打开并显示 VLC 以及其他音乐播放器)。

在此处输入图片说明

很抱歉提供了非常低分辨率的图像。

use*_*.dz 14

要在声音菜单中禁用 VLC,请按照下列步骤操作:

  1. 移动 VLC DBus 插件

     sudo mv /usr/lib/vlc/plugins/control/libdbus_plugin.so /usr/lib/vlc/plugins/control/libdbus_plugin.so.backup
    
    Run Code Online (Sandbox Code Playgroud)
  2. 打开dconf-editorvlc.desktop从以下位置删除:

     /com/canonical/indicator/sound/interested-media-players
    
    Run Code Online (Sandbox Code Playgroud)

    或者只是通过终端重置它

     dconf reset /com/canonical/indicator/sound/interested-media-players
    
    Run Code Online (Sandbox Code Playgroud)

注意:有些人可能喜欢修改声音指示器菜单以隐藏非活动播放器的控件或在关闭后将其删除。换句话说,正在运行的玩家拥有完全的控制权,关闭的玩家要么只有启动器(没有控制按钮),要么完全从菜单中消失。

  • 此修复程序也有效! (3认同)

Jac*_*ijm 7

如何从声音菜单中删除 VLC/如何防止 VLC 重新出现在声音菜单中。

从声音菜单中删除 VLC

图形用户界面方式

  • 安装 dconf 编辑器
  • 打开 dconf-editor,然后浏览到: com/canonical/indicator/sound

在此处输入图片说明

  • 在声音菜单 ( interested-media-players) 项列表中,删除您不需要/不想出现在菜单中的应用程序。关闭 dconf 编辑器。

在此处输入图片说明

  • 完成后,VLC 从菜单中消失了。

在此处输入图片说明 在此处输入图片说明

命令行方法

防止 VLC 在声音菜单中返回 (14.04)

该解决方案从声音菜单中删除了 VLC,但是如果您启动 VLC,它会再次出现在声音菜单中。下面的脚本不会阻止这种情况,但是一旦 VLC 关闭,它就会立即自动删除它。

要使用它:

复制下面的脚本,将其粘贴到一个空的文本文件中并将其另存为vlc,使其可执行。然后将复制vlc.desktop文件从/usr/share/applications~/.local/share/applications并且与替换(第一)行开始Exec=通过Exec=/path/to/script/vlc。注销并重新登录。桌面文件将被重定向到脚本,脚本将启动 VLC 并等待它停止并立即从声音菜单中删除 VLC。

#!/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)
Run Code Online (Sandbox Code Playgroud)

其他应用

此方法/脚本也可用于声音菜单中的其他应用程序。然后根据另一个应用程序需要更改脚本最后一部分中的两行:

if item == "vlc.desktop":  (change to desktop file of the application)
Run Code Online (Sandbox Code Playgroud)

subprocess.call(["/usr/bin/vlc"]) (change the command to run the application)
Run Code Online (Sandbox Code Playgroud)