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.

When dragging a file, all the entries on the launcher that are able to open that file stay lightened while the others fade. As far as I know, this is based on the Mime Types specified on the .desktop file of each application.

I would like my application to be able to accept folders as arguments through the unity launcher. I have added

MimeType=inode/directory;

to my .desktop file but to no avail.

Any ideas?

Edit:

This is my full .desktop file:

[Desktop Entry]
Version=4
Name=Wallch
Comment=Change desktop wallpapers automatically
Exec=/usr/bin/wallch %U
Icon=wallch
Terminal=false
Type=Application
Categories=Utility;Application;
MimeType=inode/directory;

Actions=Start;Change_Wallpaper;

[Desktop Action Start]
Name=Start
Exec=/usr/bin/wallch --start
TargetEnvironment=Unity

[Desktop Action Change_Wallpaper]
Name=Change Wallpaper
Exec=/usr/bin/wallch --change
TargetEnvironmet=Unity
share|improve this question
    
Have you checked the nautilus launcher? The "Exec" line is Exec=nautilus --new-window %U (that %U is important). –  Bruno Nova Sep 5 '13 at 9:13
    
The %U is for generally passing arguments through the Unity Launcher as far as I know. And yes, I have it in my Exec field, after the command, as well. I just added the full .desktop file –  hakermania Sep 5 '13 at 9:28
    
I have done a quick test. The launcher doesn't light up but if I drag a file/folder to the launcher, the application opens (the test was just a script that prints the arguments). Now, how to make the launcher light up... –  Bruno Nova Sep 5 '13 at 9:53
    
Yes, you are right. How do I make the launcher light up? –  hakermania Sep 5 '13 at 10:42
    
@BrunoNova - drop an answer with what you have been looking at - you can always tailor the answer with further findings. Please cleanup by removing comments. cheers. –  fossfreedom Sep 5 '13 at 12:47

1 Answer 1

up vote 5 down vote accepted
+500

After some research I discovered that if you want an application from the launcher to be active and to stay lightened when you drag a folder, you need to name its .desktop file as follows:

app_name-nautilus.desktop

or:

app_name-nautilus-folder-handler.desktop

So, in your case it will be:

wallch-nautilus.desktop

I'm not sure if this restriction is a normal behavior (as it should be) or if it is a bug. If you consider that this is a bug, you can report it as a bug.

This being said, I created the following script which will make this job automatically for you (I named it wallch_on_launcher):

#!/bin/bash

#wallch_on_launcher - script to create a .desktop file for wallch application and set its icon on the launcher
#the icon from the launcher will stay lightened when a folder is dragged

#Licensed under the standard MIT license:
#Copyright 2013 Radu Rădeanu (http://askubuntu.com/users/147044/).
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE

desktop_file="wallch-nautilus.desktop"
desktop_file_path="$HOME/.local/share/applications/$desktop_file"

launcher_icons=$(gsettings get com.canonical.Unity.Launcher favorites)
new_launcher_icons=$(echo $launcher_icons | sed "s/]/, 'application:\/\/$desktop_file']/g")

touch $desktop_file_path

cat << EOF > $desktop_file_path 
[Desktop Entry]
Version=4
Name=Wallch
Comment=Change desktop wallpapers automatically
Exec=/usr/bin/wallch %U
Icon=wallch
Terminal=false
Type=Application
Categories=Utility;Application;
MimeType=inode/directory;

Actions=Start;Change_Wallpaper;

[Desktop Action Start]
Name=Start
Exec=/usr/bin/wallch --start
TargetEnvironment=Unity

[Desktop Action Change_Wallpaper]
Name=Change Wallpaper
Exec=/usr/bin/wallch --change
TargetEnvironmet=Unity
EOF

gsettings set com.canonical.Unity.Launcher favorites "$new_launcher_icons"

Don't forget to make the script executable:

chmod +x wallch_on_launcher

The result can be seen in the below screen cast:

wallch desktop file


Note that the current version of Wallch (3.01-0ubuntu2) doesn't know how to handle a folder which is given as argument:

$ wallch ~/Pictures
Invalid option: '/home/radu/Pictures'
Type wallch -h or --help for all available options

So, because of this nothing will happen when you drag and drop a folder on the Wallch icon on the Unity Launcher.

share|improve this answer
    
Thanks, that seems to work just fine. I will totally fill a bug report! But, how did you get it to work with the gnome-terminal previously ? And why would I need a script for a simple renaming? –  hakermania Sep 6 '13 at 11:59
    
@hakermania You said that you are co-creator of Wallch, so you can use this script to run when Wallch is installed and when Wallch will know how to handle a folder. ...In the previous answer, the .desktop file for that script was named... copy-of-nautilus.desktop :) –  Radu Rădeanu Sep 6 '13 at 12:10
    
Applications come with .desktop files pre-created. The .desktop files then are simply moved to /usr/share/applications. Nothing is created on the fly, only the configuration files. So, the only thing that I have to do is rename my .desktop file to wallch-nautilus.desktop, which is ridiculous :P Bug reported: bugs.launchpad.net/ubuntu/+source/unity/+bug/1221701 –  hakermania Sep 6 '13 at 12:12

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.