Ubuntisten,
Ik zoek een manier om mijn iconen op het buroblad te sorteren op type ipv op naam.
Klikt men recht op het buroblad dan verschijnt in het geopende meny "opschonen op naam"
Zou het niet prachtig zijn om hier meerder mogelijkheden te hebben zoals:
Op Type of Automatisch rangschikken.
dit is wat ik op een Engelstalig Ubuntuforum vond:
Re: How can I change location of desktop icons ?
Hey guys, I keep seeing this thread pop up occasionally, and one user wrote a perl script for it, but it was more of his/her own quick-n-dirty, so I thought I'd bust one out with some in-depth comments in case you want to use it. This script will just automatically arrange the icons starting in the upper left, in no particular order, except that 'Home', 'File System', and 'Trash' will be the first 3 icons down the left-hand side.
If you'd like some changes, such as order by type, alphabetically, etc, just let me know, and I'll be happy to make the changes (or you can play with it and pick up a very important tool - Perl... ;o)
Anyway, here it is:
Code:
#!/usr/bin/perl
######################################################
## Script to automatically arrange desktop icons, starting in the upper left. This can be run hourly from crontab like so:
## 0 * * * * <username> /usr/local/bin/icon_arrange.pl
## And/Or it can be placed in rc.local to run on every reboot. I don't reboot my machine very often, to I use the crontab option.
######################################################
use strict;
use File::Copy;
## might be multiple users, find out who's using the current x-session-manager
my @user = `ps aux|egrep 'x-session-manager'|grep -v egrep`;
chomp(@user[0]);
@user[0] =~ s/^(\w+)\s.*?$/$1/g;
my $user = @user[0];
## find out the location of the file (helps across distributions/updated kernels, etc...)
my $icons_file = `locate icons|grep desktop|grep screen0`;
chomp($icons_file);
## just in case there are multiple users, set the /home/<user>/ to the $user variable:
$icons_file =~ s/^\/home\/\w+\//\/home\/$user\//g;
## finally, we now have the right file, make a backup & proceed with parsing it:
copy("$icons_file", "$icons_file.bak");
open(CONFIG, "<$icons_file") or die("Can't open $icons_file for reading!!");
my @icon_config = <CONFIG>;
close(CONFIG);
## grab all the icon names on the desktop. Don't care about their positions, since I'm giving them new ones:
my @icons;
foreach my $line (@icon_config) {
if ($line =~ /^(\[.*?\])$/) { push(@icons, $1) }
}
## open the new config file to write to it:
open(NEWCONFIG, ">$icons_file") or die("Can't open $icons_file for writing!!");
## I personally prefer 'Home' at the top left, then 'File System' underneath it, then 'Trash', then so on...
print NEWCONFIG "[Home]\nrow=0\ncol=0\n
[File System]\nrow=1\ncol=0\n
[Trash]\nrow=2\ncol=0\n\n";
my $row_count = 3;
my $col_count = 0;
foreach my $icon (@icons) {
## on my particular desktop (1280x2048 dual monitor) there are 9 rows... Not sure how this plays out for lower resolutions...
## so here I incremement the row count on each loop until it reaches 9, then reset it to 0 and increment the col count up 1:
if ($row_count > 9) { $row_count = 0; $col_count++ }
if ($icon !~ /^(\[Home\]|\[File System\]|\[Trash\])$/) { print NEWCONFIG "$icon\nrow=$row_count\ncol=$col_count\n\n"; }
$row_count++;
}
Dit is dus chinees!
of nog een andere oplossing
#make sure you change 'user' on line 4 to the username of the desktop you want to organize
use strict;
use warnings;
my $conffile='/home/user/.config/xfce4/desktop/icons.screen0.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 "testing sort:";
print join("\n",@allnames);
my @rows=($all=~/row=(\d*)/g);
print join("\n",@allnames);
print "ok now I will print the amount of rolls\n\n\n";
@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,'>icons.screen0.rc');
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++;
}
}
}
close(OUTPUT);
Dit is dus Japanees!
Iemand die dit aan een beginner kan verduidelijken?
Met Dank,
80b.