Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm using Xfce 4.8 installed on Ubuntu 12.04.2 LTS and I'm wondering what's the alternative for Right-click -> Order by name on XFCE. Right now, when I right click on my desktop, it looks like this:

right click menu on desktop in Xfce

As you can see, there's no option for rearranging the icons. If my assumption is correct, it can't be done directly via GUI. I saw this thread, but that doesn't really explain how to achieve the same result. Any ideas?

share|improve this question
2  
I'm not on Xubuntu but I do have Xfce as my desktop and I see Arrange Desktop Icons just above Desktop Settings when I right-click on an empty space on the desktop. (But I don't have Find in this folder.) –  user25656 Aug 10 '13 at 17:43
    
@vasa1: well, I'm on Xubuntu and there's no such option. –  Amal Murali Aug 10 '13 at 18:14
    
@AmalMurali you have installed xfce4? Can you provide a list that vasa1 can compare with your installed packages? dpkg --get-selections | grep install > packages.list –  Braiam Aug 15 '13 at 14:16
    
@vasa1 ^ same question. You may have some package that the default xubuntu installation may not have. –  Braiam Aug 15 '13 at 14:17
    
@vasa1: paste.ubuntu.com/5989198 –  Amal Murali Aug 15 '13 at 14:20

4 Answers 4

up vote 3 down vote accepted
+250

I'm using Ubuntu 13.04 with Xfce 4.10.0 and Thunar 1.6.2, and as Chipaca said in his answer I have in the right click menu on desktop the option Arrange Desktop Icons.

Anyway, if you don't have it, there is no problem, you can add your own custom option. Next I will explain how.

1. Create a perl script that automatically arrange desktop icons

You don't have to know something about perl scripting. Just follow the below steps:

  • In terminal run:

    mkdir -p bin
    

    This command will make a bin directory in your home folder if you don't already have it.

  • After run:

    gedit ~/bin/arrange_icons.pl
    

    This will create the new file arrange_icons.pl in gedit.

  • Copy and paste the following script in the new created file:

#!/usr/bin/perl

######################################################
## Script to automatically arrange desktop icons
## Modified from the original script found at
##    http://ubuntuforums.org/showthread.php?p=7755880
######################################################

use strict;

## find out the location of the config file
my $icons_file = `locate icons.screen0 | grep \$USER | grep .config | grep desktop | head -n 1`;

## open the config file to read from it
open(CONFIG, "<$icons_file") or die("Can't open $icons_file for reading!!");

my @icon_config = <CONFIG>;

close(CONFIG);

## grab all the icon names from the desktop
my @icons;
foreach my $line (@icon_config) {
    if ($line =~ /^(\[.*?\])$/) { push(@icons, $1) }
}

## sort all the icon names in alphabetical order
@icons = sort @icons;

## open the config file to write to it
open(NEWCONFIG, ">$icons_file") or die("Can't open $icons_file for writing!!");

my $row_count = 0;
my $col_count = 0;

foreach my $icon (@icons) {
## on my particular desktop (1440x900 monitor) there are 8 rows... Not sure how this plays out for other resolutions... so I incremement the row count on each loop until it reaches 8
    if ($row_count > 8) { $row_count = 0; $col_count++ }
    print NEWCONFIG "$icon\nrow=$row_count\ncol=$col_count\n\n";
    $row_count++;
}

close(NEWCONFIG);

system("xfdesktop --reload");
  • Save the file and close it.
  • Go back into terminal and run:

    chmod +x ~/bin/arrange_icons.pl
    

    to grant execute access for the script.

2. Add the script to the right click menu on desktop

Open Thunar, the default file manager for Xfce, go to Edit and select Configure custom actions.... When it opens, click on + sign from the right side of the window to add a new custom action. In Basic tab, complete all the fields as follow:

add a new custom action - basic

The most important thing is to put the right path to the script in Command field. Also you can add an icon if you wish.

In Appearance conditions tab you have only to tick the Desktop field.

add a new custom action - appearance conditions

Press Ok, then Close.

3. Arrange desktop icons by name from right click menu

To see the new option Arrange Desktop Icons by Name in the right click menu on the desktop, you don't need to reboot your system or re-login. Just run the following command in terminal:

xfdesktop --reload

After all of these, you can enjoy:

Arrange desktop icons

share|improve this answer
    
This actually answers my question. Thank you! –  Amal Murali Aug 17 '13 at 15:34

In 13.04 it's right there in the menu,

menu with "Arrange Desktop Icons" highlighted

12.04 doesn't have it; haven't tested 12.10.

share|improve this answer
1  
That seems to be it. My Lubuntu is 13.04 and the xfce desktop and thunar 1.6.2 is the latest in the software center. OP's system seems to be a mix of updated and outdated software. –  user25656 Aug 15 '13 at 16:56

I have found 2 scripts 1 from here, and 2 from here, that the are claimed to arrange the desktop icons.

Still searching for how to make a menu element for it, perhaps this could help you for the time being.

Thanks.

share|improve this answer
1  
Those links are pretty old and even though Xfce and Thunar don't evolve as rapidly as GNOME or Unity, things probably have changed since the time those threads were posted. –  user25656 Aug 15 '13 at 16:42
    
yeah you are right,but i posted them so that perhaps it would help :) –  Aaditya Bagga Aug 15 '13 at 16:57

Note: Xubuntu 13.04 its not there as well, but in Ubuntu 13.04, with the Xfce Desktop Environment, its available.

enter image description here enter image description here

XFCE4 does not have (to my knowledge) a click-able "align icons" function. Instead, it uses a grid of invisible boxes on the desktop which you can either click and drag icons 'into' or 'out of'. When you relocate a desktop icon by click and drag, you should momentarily see the outline of the grid box, which the icon will automatically center into.

If you want you're icons all in a row, or rows, you have to manually move them to where you want them. The icon "size" determines how many rows and columns of icon positions you can have on your desktop. Smaller icon sizes allow for more rows and columns, larger, less.

System > Settings > Desktop Settings > Behavior to get to the icon sizing function. The desktop icon positions are configured (stored) in ~/.config/xfce4/desktop/icons.screen0.rc.

Now I found a way that will arrange the icon automatically at login, but it only worked for me sometimes, and others it didn't. I will though list it, in case it works for you.

#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);

Paste the code into an editor and save it into your home folder as /home/user/.config/xfce4/desktop/icons.screen0.rc

Log out. Log in as that user again. The icons are arranged this time. It worked for me automatically. I am running Xfce4 over Ubuntu 12.04. As I said it didn't work all the time.

Hope this helps.

Source:This code is not mine: It's from the ubuntuforums authored by a member logged as PGScooter

share|improve this answer
    
This is completely wrong: to paste that script in /home/user/.config/xfce4/desktop/icons.screen0.rc. I can bet with you that will never work! –  Radu Rădeanu Aug 17 '13 at 14:22
    
@RaduRădeanu I don't think so, because there is a file already exist there that has to do with the desktop icons. But I like you answer. –  Mitch Aug 17 '13 at 18:24
    
Which one? icons.screen0.rc? And your answer is good until you find the script. –  Radu Rădeanu Aug 17 '13 at 18:43
    
What I mean is that the script should look like this one and should be saved under onther name, let say icons.screen0.pl. After you run it you must "refresh" your desktop by pressing F5 to see the result. And like this everything is ok. From my point of view a script should work or should not work. Doesn't exist "it only worked for me sometimes". –  Radu Rădeanu Aug 17 '13 at 19:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.