现在的位置: 首页linux软件>正文
Linux图标快快找,不错的Nautilus脚本
发表于528 天前 linux软件 评论数 3 ⁄ 被围观 680 阅读+

小凡在使用Windows系统的时候总是喜欢把好看的图标收藏起来,转用Ubuntu后,不得不放弃这个习惯了.不过,现在又可以继续这个癖好了.下面是小凡查找到的一个Nautilus脚本:where-is-this-icon.用于快速查找系统中图标的位置.下载下面的脚本,放置到Gnome的脚本文件夹当中就能使用了.具体操作如下:

图标快快找-凡尘飞扬-kofj.net

图标快快找-凡尘飞扬-kofj.net

1.下载文末的脚本保存到你home目录的 .gnome2/nautilus-scripts 文件夹下(按CTRL+H显示隐藏文件)

2.右键应用程序图标运行 ‘where is this icon’

#!/usr/bin/perl -w
#Title=where-is-this-icon
#Title[fr]=ou-est-cet-icone

#==============================================================================
#                            where-is-this-icon
#
#  author  : SLK
#  version : v2010120101
#  license : Distributed under the terms of GNU GPL version 2 or later
#
#==============================================================================
#
#  description :
#    nautilus-script :
#    displays the full path of the icon choosen for a folder, a file or a
#    launcher (.desktop).
#
#  informations :
#    - a script for use (only) with Nautilus.
#    - to use, copy to your ${HOME}/.gnome2/nautilus-scripts/ directory.
#
#  WARNINGS :
#    - this script must be executable.
#    - package "zenity" must be installed
#
#==============================================================================

use utf8 ;
use strict ;

#==============================================================================
#                                                                     CONSTANTS

# choose (or add !) your language :
my $lang = 'en' ;
#my $lang = 'fr' ;

my %LOC = () ;
my $l = '' ;
$l = 'en' ;
    $LOC{$l}{'title'} = 'where is this icon ?' ;
    $LOC{$l}{'default_icon'} = 'no specific icon for this file' ;
    $LOC{$l}{'desktop_icon'} = 'full path of this icon (this file is a launcher):' ;
    $LOC{$l}{'path_icon'} = 'full path of this icon:' ;
$l = 'fr' ;
    $LOC{$l}{'title'} = 'ou est cette icone ?' ;
    $LOC{$l}{'default_icon'} = 'aucune icone specifique pour ce fichier' ;
    $LOC{$l}{'desktop_icon'} = 'chemin complet de cette icone (ce fichier est un lanceur):' ;
    $LOC{$l}{'path_icon'} = 'chemin complet de cette icone :' ;

my $obj = '' ;
my @encoded_tree = () ;
my $encoded_filename_obj = '' ;
my $encoded_dirpath_obj = '' ;
my $double_encoded_dirpath_obj = '' ;
my $filepath_xml =  '' ;
my $filepath_icon = 'NONE' ;
my $encoded_filepath_icon = 'NONE' ;
my $text = '' ;

#==============================================================================
#                                                                INIT VARIABLES

my $HOME_PATH = $ENV{'HOME'} ;
my $ZENITY='/usr/bin/zenity' ;

#==============================================================================
#                                                                     FUNCTIONS

sub to_url
{
    my @out = @_ ;
    s/([^A-Za-z0-9._-])/sprintf("%%%02X", ord($1))/seg for(@out) ;
    return @out ;
}
sub from_url
{
    my @out = @_ ;
    s/\%([A-Fa-f0-9._-]{2})/pack('C', hex($1))/seg for(@out) ;
    return @out ;
}

#==============================================================================
#                                                                          MAIN

# retrieve first clicked object
($obj) = split("\n", $ENV{'NAUTILUS_SCRIPT_SELECTED_FILE_PATHS'}) ;

if((-f $obj) && ($obj =~ /\.desktop$/))
{
    # if file is a launcher (*.desktop)
    # retrieve in the file the value of the iconpath
    open(my $DESKTOP, '<', $obj) || die ;
    my @CONTENT = <$DESKTOP> ; close $DESKTOP ;
    ($filepath_icon) = grep(s/^Icon=(.+)$/$1/, @CONTENT) ;
    $text = $LOC{$lang}{'desktop_icon'} .'\n'. $filepath_icon ;
}
else
{
    # extract files of the full path and encode to url
    @encoded_tree = to_url(split('/', $obj)) ;
    $encoded_filename_obj = pop(@encoded_tree) ;
    ($encoded_dirpath_obj) = join('/',@encoded_tree) ;

    # try to retrieve the metafile (if exist) which contains iconpath
    ($double_encoded_dirpath_obj) = to_url($encoded_dirpath_obj) ;
    $filepath_xml = $HOME_PATH .'/.nautilus/metafiles/file:%2F%2F'. $double_encoded_dirpath_obj .'.xml' ;
    if(-f $filepath_xml)
    {
        # try to get the full path name of the icon
        open(my $XML, '<', $filepath_xml) || die ;
        while(<$XML>)
        {
            if(($encoded_filepath_icon) = (/file name="$encoded_filename_obj"[^>]+?custom_icon="(.+?)"/))
            {
                # from uri : get local path
                ($encoded_filepath_icon =~ s|^file://||) ;

                # if relative path, let's create absolute path
                ($encoded_filepath_icon =~ m|^[^/]|)
                  && ($encoded_filepath_icon = join('/',($encoded_dirpath_obj, $encoded_filename_obj, $encoded_filepath_icon))) ;

                ($filepath_icon) = from_url($encoded_filepath_icon) ;
                $text = $LOC{$lang}{'path_icon'} .'\n'. $filepath_icon ;
                last ;
            }
        }
        close $XML ;
    }
}
$text = ($filepath_icon eq 'NONE')
  ? $LOC{$lang}{'default_icon'}
  : $text ;

system $ZENITY .' --info --title="'. $LOC{$lang}{'title'} .'" --text="'. $text .'"' ;

exit 0 ;

# EOF
文件名   where-is-this-icon图标快快找-凡尘飞扬-kofj.net.无 文件大小:4.62 kB
更新时间:2010-12-08 累计下载:131次
关于作者
凡尘飞扬, 天津冶金职业技术学院
系统安装与维护,Lamp运维,企业主页解决方案,系统优化

Linux图标快快找,不错的Nautilus脚本:目前有3 条留言

  1. zigbee : 2010年12月08日6:06 下午 回复

    知道一些.跟桌面有关的吧

  2. 奚少 : 2010年12月08日5:13 下午 回复

    额,没有用过哦,呵呵~

给我留言


/ 快捷键:Ctrl+Enter

无觅相关文章插件,快速提升流量

不想听你唠叨×