转自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 "排序前: "; print join(" ",@allnames); my @rows=($all=~/row=(d*)/g); print join(" ",@allnames); print " ok now I will print the amount of rolls "; @rows=sort(@rows); my $maxrow=$rows[-1]; print "the max rows is $maxrow "; my $numicons=scalar(@allnames); print "number of icons is $numicons "; my @cols=($all=~/col=(d*)/g); @cols=sort(@cols); my $maxcol=$cols[-1]; print " the max cols is $maxcol "; 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]] row=$k col=$j "; $i++; } } } print "更新桌面完成,请刷新桌面。 "; close(OUTPUT);
运行脚本
perl sort.pl
运行完脚本后,按一下F5,桌面就整理好了