0

on Ubuntu 14.04 the first Unity Dash search is much slower than the following searches.

With xdotool I'm trying to open and then close the Unity Dash user interface on Ubuntu start-up.

~/.config/autostart/unity_dash_update.desktop

[Desktop Entry]
Type=Application
Exec=~/.config/autostart/unity_dash_update.sh
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[it]=Unity Dash Update
Name=Unity Dash Update
Comment[it]=
Comment=

~/.config/autostart/unity_dash_update.sh

#!/bin/bash
sleep 1
xdotool key Alt+F2
sleep 3
window="$(xdotool getactivewindow)"
xdotool key --window $window "Escape"
exit 0

If I manually run the bash script, the thing works, but during the system startup the Dash appears and doesn't disappear.

I've tried with or without sleeping time between xdotool execution, with no success.

What I am doing wrong?

update

As Jacob Vlijm suggests, the Exec parameter was wrong, 'cause it must be an absolute path.

This was my fault cause I tried a quick (too quick) way to remove my name from the code I was posting.

I'm sorry.

So a corrected .desktop file would be

[Desktop Entry]
Type=Application
Exec=/home/myname/.config/autostart/unity_dash_update.sh
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[it]=Unity Dash Update
Name=Unity Dash Update
Comment[it]=
Comment=

Thanks Jacob for your help.

3
  • Try adding DISPLAY=:0 to the top of the script. That's : and zero Feb 1, 2016 at 20:31
  • no luck... doesn't help
    – nulll
    Feb 3, 2016 at 18:03
  • @nulll you are making a mistake in your setup, please se my latest edit... Feb 6, 2016 at 9:16

2 Answers 2

1

dbus actually has a method for closing the Dash menu. Using qdbus your script could be changed as follows:

#!/bin/bash
DISPLAY=:0
sleep 10
xdotool key Alt+F2
sleep 0.25 
qdbus com.canonical.Unity /com/canonical/Unity/Dash \
      com.canonical.Unity.Dash.HideDash
exit 0

Note that in addition i've increased sleep time to 10 seconds, because Unity may take time to start up. Thus if Unity haven't started yet, that will make the script run commands, but those commands would have no effect.

2
  • After doing some tests it turns out that the key thing is the first sleep time of 10 seconds. Thanks!
    – nulll
    Feb 5, 2016 at 19:29
  • I can't figure out why, if it sleep less than 10 seconds, the script is able to open Unity Dash but is not able to close it...
    – nulll
    Feb 6, 2016 at 8:28
1

You have a few issues in your setup: one will definitely make it not work, the other most likely:

1. The most important one:

In the .desktop file, you use:

Exec=~/.config/autostart/unity_dash_update.sh

but ~ does not work ina a .desktop file, you need to use absolute path, unless your script is in $PATH (and executable), then simply run it by its name.

2. Most likely, you need to set a break before the command runs

Now it simply runs too early and will either break, or miss target. This is often the case with:

  • touchpad, mouse and keyboard (settings) related commands.
  • xrandr commands, especially when a second monitor is attached
  • Indicators

and a few more... Unity related commands are in the list by definition, since it is desktop related by nature.

Concluding: change your Exec= line into:

Exec=/bin/bash -c "sleep 15 && /absolute/path/to/unity_dash_update.sh

EDIT

Important Notes

  1. In your question, you mention "Unity Dash search is much slower". However, your xdotool command does not call Unity Search, but the command entry. To call Unity Search simply (virtually) press Super is sufficient. Then make the script:

    xdotool key Super && sleep 3 && xdotool key Super
    

    Or better, don't use a script at all, and add this to startup applications, including the break you need before it to run:

    /bin/bash -c "sleep 15 && xdotool key Super && sleep 3 && xdotool key Super"
    

    Of course you can experiment with the sleep 15 time.

  2. Your .desktop file is quite extended, while for a basic job like running a script on startup:

    [Desktop Entry]
    Name=name
    Exec=command
    Type=Application
    

    is sufficient.
    If you use less, less can go wrong :)

    See also here.

  3. If you insist on using a separate script, don't store it in ~/.config/autostart. That directory is specifically meant for startup (log in) launchers.

4
  • Thanks Jabob for your answer. The problem of the absolute path was just a problem of me quickly (too quickly) triyng to hide my name contained in the code I was posting... sorry.
    – nulll
    Feb 5, 2016 at 19:20
  • 2
    @nulll Sorry, but that is really asking questions in a bad way, -1 It is the main issue in the question, you turned out not to ask. By editing it out, you make me look silly. Feb 5, 2016 at 19:21
  • Thanks Jabob for your help, I've edited my answer highlighting my error. I hope now that the "incident" is recovered... thanks again
    – nulll
    Feb 5, 2016 at 19:39
  • 1
    @nulll Thanks for editing. I wouldn't store the script in a specific directory like ~/.config/autostart btw. It isn't meant for that. Feb 5, 2016 at 19:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .