How to order desktop icons by name in XFCE?

5,300

Solution 1

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

Solution 2

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:
5,300

Related videos on Youtube

Amal Murali
Author by

Amal Murali

Updated on September 18, 2022

Comments

  • Amal Murali
    Amal Murali over 1 year

    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?

    • Admin
      Admin over 10 years
      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.)
    • Amal Murali
      Amal Murali over 10 years
      @vasa1: well, I'm on Xubuntu and there's no such option.
    • Braiam
      Braiam over 10 years
      @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
      Braiam over 10 years
      @vasa1 ^ same question. You may have some package that the default xubuntu installation may not have.
    • Amal Murali
      Amal Murali over 10 years
    • Amal Murali
      Amal Murali over 10 years
      @vasa1: Xfce version is 4.8 and lsb_release -a outputs 'Description : Ubuntu 12.04.2 LTS`.
  • Admin
    Admin over 10 years
    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.
  • Admin
    Admin over 10 years
    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.
  • Radu Rădeanu
    Radu Rădeanu over 10 years
    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!
  • Amal Murali
    Amal Murali over 10 years
    This actually answers my question. Thank you!
  • Mitch
    Mitch over 10 years
    @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.
  • Radu Rădeanu
    Radu Rădeanu over 10 years
    Which one? icons.screen0.rc? And your answer is good until you find the script.
  • Radu Rădeanu
    Radu Rădeanu over 10 years
    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".