如何找到正在使用的启动器图标的位置?

Tim*_*ann 23 icons launcher find

我的桌面上有一个启动器,想手动添加另一个具有相同图标的启动器。

当我转到现有启动器的首选项并单击该图标时,它不会将我带到存储该图标的文件夹,而只会将我带到我的主文件夹。

如何找出启动器使用的图标在我的系统中的位置?

Ste*_*zzo 21

大多数情况下,图标将从您当前的图标主题中选择,而不是被称为绝对路径。

  1. 打开 Gedit

  2. 将启动器拖入 Gedit 窗口

  3. 查找Icon定义:

    Icon=gnome-panel-launcher

然后,您可以找到图标地方/usr/share/icons,这取决于您的主题。

这是一个快速的python脚本,可以为您找到正确的图标路径:

import gtk

print "enter the icon name (case sensitive):"
icon_name = raw_input(">>> ")
icon_theme = gtk.icon_theme_get_default()
icon = icon_theme.lookup_icon(icon_name, 48, 0)
if icon:
    print icon.get_filename()
else:
    print "not found"
Run Code Online (Sandbox Code Playgroud)

将其保存在某处并运行python /path/to/script.py

它看起来像这样:

stefano@lenovo:~$ python test.py 
enter the icon name (case sensitive):
>>> gtk-execute
/usr/share/icons/Humanity/actions/48/gtk-execute.svg
Run Code Online (Sandbox Code Playgroud)

或者,您可以四处翻找,/usr/share/icons直到找到您正在寻找的图标。


更容易:您只需复制并粘贴启动器并更改名称和命令


编辑 2018

上面脚本的更新版本:

stefano@lenovo:~$ python test.py 
enter the icon name (case sensitive):
>>> gtk-execute
/usr/share/icons/Humanity/actions/48/gtk-execute.svg
Run Code Online (Sandbox Code Playgroud)

  • 另一个常见的检查路径是`/usr/share/pixmaps`。 (6认同)

kyl*_*leN 5

多一点信息。

普通启动器实际上是 /usr/share/applications/ 中的 .desktop 文件。

例如:/usr/share/applications/usb-creator-gtk.desktop

(参见https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html

每个桌面文件都有一行指定图标,例如:

Icon=usb-creator-gtk
Run Code Online (Sandbox Code Playgroud)

当没有路径(和文件扩展名)(如本例中)时,这意味着在 /usr/share/icons/ 中(某处)找到图标,运行时使用的图标取决于当前主题和某些案例显示上下文(大小)。

从桌面文件中知道图标名称(不带扩展名),可以按如下方式找到它/它们:

$ find . -name "usb-creator-gtk*"
./hicolor/scalable/apps/usb-creator-gtk.svg
./Humanity/apps/32/usb-creator-gtk.svg
./Humanity/apps/16/usb-creator-gtk.svg
./Humanity/apps/22/usb-creator-gtk.svg
./Humanity/apps/24/usb-creator-gtk.svg
./Humanity/apps/64/usb-creator-gtk.svg
./Humanity/apps/48/usb-creator-gtk.svg
Run Code Online (Sandbox Code Playgroud)


kir*_*iri 5

这是基于斯特凡诺宫的答案在这里

#!/usr/bin/env python3

from gi.repository import Gtk

icon_name = input("Icon name (case sensitive): ")
if icon_name:
    theme = Gtk.IconTheme.get_default()
    found_icons = set()
    for res in range(0, 512, 2):
        icon = theme.lookup_icon(icon_name, res, 0)
        if icon:
            found_icons.add(icon.get_filename())

    if found_icons:
        print("\n".join(found_icons))
    else:
        print(icon_name, "was not found")
Run Code Online (Sandbox Code Playgroud)

将上述内容保存到文件中并使用python3 /path/to/file.

Stefano Palazzo的原始脚本之间的差异在于:

  • 这会找到图标的所有分辨率(不仅仅是 48)
  • 使用gi.repository代替Gtk
  • 使用 Python 3 而不是 2
  • 在其他方面稍微调整