How to put unity launcher on in different positions on different monitors

I have two monitors: One is a large 2560x1600 monitor, which I use as my main monitor and do most work on, and the other is a 1360x768 monitor set up vertically for use as an 'off' monitor - for things like my calendar and email, notification popups, or for a web browser while playing games, etc.

I currently have it configured so that the unity launcher is located only on the left edge of the main monitor.

I would like to be able to have a separate unity launcher for each monitor. The advantage of doing this is that the applications on each monitor are then associated with only the launcher on that monitor, which helps with keeping the desktop organized.

Unfortunately, horizontal space is at a premium on the off monitor - I don't want to have to use an extra 48 pixels of horizontal space just for this.

A solution to this would be to change the launcher position setting (e.g. via the Unity Tweak Tool or similar) to the bottom. However, this setting would affect the position of the launcher on both screens, and I want to keep the launcher on the left edge of my main monitor.

How can I configure unity to use different launcher positions on different monitors?

An alternate solution would be to have the unity launcher on the off monitor auto-hide, but I want to keep the launcher bar static on my main monitor. If there is a way to configure the auto-hide behavior on a per-monitor basis this would also be an acceptable solution.

I would prefer to stick to the default unity desktop environment, but if there is another DE that handles multiple monitors really well I might be interested.


Solution 1:

Automatically move the launcher, depending on the active screen

A possible solution is to automatically change the position of the launcher, depending on the current mouse-position:

  • if it is on the left screen, move the launcher to left
  • if it is on the right screen, move it to the bottom

In the test I ran, it worked surprisingly smooth, and windows adapt well to the change.

The script

#!/usr/bin/env python3
import subprocess
import time

scr_data = subprocess.check_output(["xrandr"]).decode("utf-8")
border = int([s.split("x")[0] for s in scr_data.split() if "+0+0" in s][0])
left_scr = [l.split()[0] for l in scr_data.splitlines() if "+0+0" in l][0]

key = "com.canonical.Unity.Launcher"
item = "launcher-position"

def catch_mouse():
    return int(subprocess.check_output([
        "xdotool", "getmouselocation"
        ]).decode("utf-8").split()[0].split(":")[1])

test1 = ""

while True:
    time.sleep(1)
    test2 = catch_mouse() <= border
    if test2 != test1:
        if test2 == True:
            cmd = ["gsettings", "set", key, item, "Left"]
        else:
            cmd = ["gsettings", "set", key, item, "Bottom"]
        subprocess.Popen(cmd)
    test1 = test2

How to use

  1. The script needs xdotool:

    sudo apt-get install xdotool
    
  2. Copy the script into an empty file, save it as move_launcher.py

  3. Test- run it by the command (from a terminal)

    python3 /path/to/move_launcher.py
    
  4. If all works fine, add to Startup Applications: Dash > Startup Applications > Add. Add tghe command:

    /binh/bash -c "sleep 15 && python3 && /path/to/move_launcher.py
    

EDIT

...Or more advanced, only a launcher on the active screen on an arbitrary position.

...a script that will set only one launcher (on the left screen, on the left side):

![enter image description here

...while you are working on the left screen. This will give you full size view on the right screen...

...and one launcher at the bottom of the second screen:

enter image description here

...If you move to the right screen, giving you the launcher you need on the desired position on the right screen.

As mentioned, in the test(s), the windows adapted smoothly without an error.

The script

#!/usr/bin/env python3
import subprocess
import time

scr_data = subprocess.check_output(["xrandr"]).decode("utf-8")
border = int([s.split("x")[0] for s in scr_data.split() if "+0+0" in s][0])
left_scr = [l.split()[0] for l in scr_data.splitlines() if "+0+0" in l][0]
right_scr = [l.split()[0] for l in scr_data.splitlines() if all([
    not "+0+0" in l, l.count("+") == 2])][0]

key = "com.canonical.Unity.Launcher"
item = "launcher-position"

subprocess.call(["dconf", "write",
        "/org/compiz/profiles/unity/plugins/unityshell/num-launchers", "1"])

def catch_mouse():
    return int(subprocess.check_output([
        "xdotool", "getmouselocation"
        ]).decode("utf-8").split()[0].split(":")[1])

test1 = ""

while True:
    time.sleep(1)
    test2 = catch_mouse() <= border
    if test2 != test1:
        if test2 == True:
            cmd1 = ["xrandr", "--output", left_scr, "--primary"]
            cmd2 = ["gsettings", "set", key, item, "Left"]
        else:
            cmd1 = ["xrandr", "--output", right_scr, "--primary"]
            cmd2 = ["gsettings", "set", key, item, "Bottom"]
        subprocess.Popen(cmd1)
        subprocess.call(cmd2)
    test1 = test2

To use

  • This version runs exactly like the first one.

Note

These are just two examples. Many things are possible.

Two launchers, at the same time on a different position per screen, is currently impossible however, untill someone creates the option...

Solution 2:

I cannot see a mechanism to choose a different location for a single launcher (e.g Unity) on different monitors.

Given the problem of real-estate (limited horizontal), I can see that placing a launcher at the bottom of the screen and auto-hiding it would be a solution.

In Ubuntu 16.04 LTS, you can move the Launcher to the bottom, but I realise this results in the absence of the Launcher on the left-hand-side of your main monitor (your other issue).

So - what about if you had two (hidden) Launchers on both screens? One on the left-hand side, and one at the bottom of the screen?

See this article for a mechanism of using an alternate Launcher (Cairo Dock): http://www.howtogeek.com/202708/how-to-convert-the-unity-launcher-into-a-dock-style-launcher/

I have tested this (14.04 LTS) and can confirm installing Unity Tweak Tool and Cairo Dock would provide you with two (hidden, if you so choose) Launchers on both screens - one (Unity Launcher) on the left-hand side, and another (Cairo Dock) at the bottom of the screen.

From my assessment of your needs, this would meet both but would mean having running two Launchers on both screens so you can choose which to use when it suits you.

Cairo-Dock allows you, if you have multiple monitors, to manage the location of the Dock/Launcher so that it appears in a specific location on only one monitors by leveraging features in Xinerama.

I do not think this would provide significant benefits if the Dock/Launcher is always auto-hidden, however it might provide you some flexibility and potentially a solution that I can't think of... :)

See here for option: https://glx-dock.org/bg_topic.php?t=5632