xfce4桌面自动整理脚本

转自http://blog.chinaunix.net/uid-22101074-id-91073.html (有修改) xfce4桌面没有自动排列的功能,如果文件多了,超出了桌面的范围,就不好找了,在网上发现个perl脚本,比较好用,拿过来用用。

#!/usr/bin/perl



use strict;

use warnings;

my $conffile='./.config/xfce4/desktop/icons.screen0-1366x768.rc';

open(CONF,"$conffile") or die "can't find the config file";

my $all;

while (<CONF>) {

    $all=$all.$_;

}

my @oldnames=($all=~/\[(.*)\]/g);

my @allnames=sort { lc($a) cmp lc($b) } @oldnames;

print "排序前:\n";

print join("\n",@allnames);

my @rows=($all=~/row=(\d*)/g);

print join("\n",@allnames);

print "\nok now I will print the amount of rolls\n\n";

@rows=sort(@rows);

my $maxrow=$rows[-1];

print "the max rows is $maxrow\n";

my $numicons=scalar(@allnames);

print "number of icons is $numicons\n";

my @cols=($all=~/col=(\d*)/g);

@cols=sort(@cols);

my $maxcol=$cols[-1];

print "\nthe max cols is $maxcol\n";

my $i=0;



open(OUTPUT,">$conffile");

for (my $j=0;$j<=$maxcol;$j++) {    

    if ($i<=19) {

        for (my $k=0;$k<=$maxrow;$k++) {

            print OUTPUT "\[$allnames[$i]\]\nrow=$k\ncol=$j\n\n";

            $i++;

        }

    }

}



print "更新桌面完成,请刷新桌面。\n";

close(OUTPUT);
运行脚本
 
perl sort.pl
 
运行完脚本后,按一下F5,桌面就整理好了

你可能感兴趣的:(脚本)