5

After I update my ubutu to 16.04, I got a problem with Unity launcher. Whenever I open an application which is not listed in launcher, it will take the third position instead of last position. Has anyone the same problem?

enter image description here

1
  • 4
    Just a hunch, but could you post the output of gsettings get com.canonical.Unity.Launcher favorites? Not sure if it leads to something. Dec 13 '16 at 17:05
8
+50

There is a special invisible launcher item called "Running Apps" which is always present in your launcher favorites and determines at which position the icons of unpinned running apps appear. In your case, it obviously somehow got to a weird position, but it's easily fixable.

There are two ways, an easy way and of course also the nerdy command-line way ;-)


I want it easy to do and to remember!

The most simple way is to just drag and drop your launcher icons in the right order.

Therefore open one application that is not pinned to the launcher, like the Appearance Settings in your screenshot. It must not be pinned, otherwise this won't work.

Then you do not drag the unpinned icon, because that will not affect the position of the special "Running Apps" item but just pin the dragged icon to the new location.
Instead, drag all icons from below/the right (works for both launcher orientations) of the unpinned one to directly above/the left of it. That way you move the unpinned icon to the bottom/right without touching it.

When it reached the position where you want all unpinned application icons to appear, you're done. You can now close that window and open it again or new ones to test that it worked.


I'm feeling nerdy today, let's hack it through the terminal!

Your pinned launcher items are called "favorites" and are stored as dconf settings in your user profile. You can see your list of favorites by opening a terminal and running

gsettings get com.canonical.Unity.Launcher favorites

This could look like the example below (output formatting added by me):

$ gsettings get com.canonical.Unity.Launcher favorites
['application://gnome-terminal.desktop', 
 'application://org.gnome.Nautilus.desktop', 
 'application://firefox.desktop', 
 'unity://running-apps', 
 'unity://desktop-icon',
 'unity://devices']

This output represents a minimalistic launcher with only a terminal, Nautilus and Firefox icon pinned. The next item is 'unity://running-apps' which is the important special item that serves as placeholder for the icons of all unpinned running applications. After that there are more special items following, namely the "Show Desktop" icon and another placeholder item that defines where icons of plugged in removable devices will appear.

The only item that is interesting for us is the "Running Apps" item. To fix your issue, you must move it to the desired position in the list of items.

You do this by typing the command

gsettings set com.canonical.Unity.Launcher favorites []

but instead of an empty list [], you need to pass your modified list as last argument, of course.

For example, given the launcher described above, to make the running apps icons appear below "Show Desktop" but still above the device icons, run this:

$ gsettings set com.canonical.Unity.Launcher favorites "['application://gnome-terminal.desktop', 'application://org.gnome.Nautilus.desktop', 'application://firefox.desktop', 'unity://desktop-icon', 'unity://running-apps', 'unity://devices']"

The changes will take effect immediately, so launch some unpinned applications to verify you've put the item at the right position and enjoy.

2
  • 1
    If wanting truly at the end I'd suggest just removing the 'unity://running-apps', entry. It will be auto re-inserted at the end & running apps will get an icon at the very bottom or at far right when using bottom launcher option.
    – doug
    Dec 14 '16 at 0:10
  • Good answer Byte, and spot on ! Hence upgoated , +1. Dec 14 '16 at 1:42
2

As ByteCommander properly explained, the unity://running-apps position in the list of com.canonical.Unity.Launcher gsettings schema does affect where running apps appear, hence his answer is spot on. To demonstrate and test this, I've written a small script, results of which you can see in screenshots below.

Notice how the script called with index 1 and index 2, shows two terminal apps moving together to the respective position in the launcher ( i.e., running apps that are not in current list are grouped together ). Notice that the list begins with index 0, which is appropriately taken by the chromium icon.

enter image description here enter image description here

Note: if you want running apps to be last, it is sufficient to use -1 as argument.

Script

from gi.repository import Gio
import sys

def gsettings_get(schema, path, key):
    """Get value of gsettings schema"""
    if path is None:
        gsettings = Gio.Settings.new(schema)
    else:
        gsettings = Gio.Settings.new_with_path(schema, path)
    return gsettings.get_value(key)

def gsettings_set(schema, path, key, value):
    """Set value of gsettings schema"""
    if path is None:
        gsettings = Gio.Settings.new(schema)
    else:
        gsettings = Gio.Settings.new_with_path(schema, path)
    if isinstance(value, list):
        return gsettings.set_strv(key, value)
    if isinstance(value, int):
        return gsettings.set_int(key, value)

def main():
    schema='com.canonical.Unity.Launcher' 
    key='favorites'
    current_list = list(gsettings_get(schema,None,key))
    running_index = current_list.index('unity://running-apps')

    position = int(sys.argv[1])

    temp = current_list[position]
    current_list[position] = current_list[running_index]
    current_list[running_index] = temp
    gsettings_set(schema,None,key,current_list)
if __name__ == '__main__': main()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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