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

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

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

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

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

  1. 打开Gedit
  2. 将启动器拖动到Gedit窗口
  3. 寻找Icon定义:

    Icon=gnome-panel-launcher

然后,您可以在/usr/share/icons 某个位置找到该/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" 

将它保存在某处并运行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 

或者,您可以在/usr/share/icons直到找到您要查找的图标。


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


编辑2018年

上面脚本的更新版本:

 #!/usr/bin/env python3 import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk icon_name = input("Icon name (case sensitive): ") icon_theme = Gtk.IconTheme.get_default() icon = icon_theme.lookup_icon(icon_name, 48, 0) if icon: print(icon.get_filename()) else: print("not found") 

多一点信息。

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

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

(见http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html )

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

 Icon=usb-creator-gtk 

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

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

 $ 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 

这是基于Stefano Palazzo的答案。

 #!/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") 

将上述内容保存到文件中并使用python3 /path/to/file运行它。

Stefano Palazzo的原始剧本之间的区别在于:

  • 这可以找到图标的所有分辨率(不仅仅是48)
  • 使用gi.repository而不是Gtk
  • 使用Python 3而不是2
  • 以其他方式稍微调整一下