Application always show in the third position in Ubuntu 16.04
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?
Solution 1:
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.
Solution 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.
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()