Command to reorganize desktop by name etc

Please post suggestions for improvement of Cinnamon here
Post Reply
Level 1
Level 1
Posts: 8
Joined: Wed Dec 18, 2013 4:51 pm

Command to reorganize desktop by name etc

Post by caitifty » Mon Jan 15, 2018 2:59 pm

The current cinnamon desktop lets you right click and select Desktop -> By Name / Size / Type /Modification date, which I like much better than auto-arrange.

What I'd like to do is create custom keyboard shortcuts for some of these. Does anyone know the command you need to trigger any of the above? I know how to create a keyboard shortcut once I have the necessary command, but I haven't been able to find the command via google..

Many thanks in advance

User avatar
Level 24
Level 24
Posts: 23474
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: Command to reorganize desktop by name etc

Post by xenopeek » Mon Jan 15, 2018 3:58 pm

It's not very nice but you can do it. The process that manages the desktop is called nemo-desktop and your preferences for the desktop from the context menu are stored in the text file ~/.config/nemo/desktop-metadata. To bind a command to a keyboard shortcut you need a command that can change a value in this file and a command that will restart nemo-desktop. Hence I say it's not very nice, as your desktop will disappear for and reappear shortly after (probably less than a second, but still). This because nemo-desktop doesn't watch for changes to its preferences file so you need to restart the process to make it use your changes.

There is a setting nemo-icon-view-sort-by in that file that can have value of: name, size, detailed_type or modification date. Other interesting settings are nemo-icon-view-auto-layout and nemo-icon-view-keep-aligned (both can either be true or false). I couldn't immediately see where it remembers whether to arrange vertically or horizontally. I may have overlooked it.

So anyway, back to a command you can bind to a keyboard shortcut. Something like this would work to set it to sort by name:

Code: Select all

bash -c "sed -i -r 's/^(nemo-icon-view-sort-by=).*$/\1name/' ~/.config/nemo/desktop-metadata; nemo-desktop --quit; nohup nemo-desktop &>/dev/null &"
That one line (may be displayed as more lines here, but it is a single line) is the command to use for your custom keyboard shortcut. To add a keyboard shortcut open Keyboard from your menu (type in your menu to find it), go to the Shortcuts tab, click on Add custom shortcut button and give it a name and put this command in. After adding it click on one of the "unassigned" under keyboard bindings for your entry and click it again to set a keyboard shortcut. It should work immediately.

If you want sort by something else replace name with size or detailed_type or modification date.

If you want to change one of the other settings replace nemo-icon-view-sort-by in the command with that setting's name and replace name with true or false.

Post Reply

Return to “Cinnamon”