0

I use 2 monitors (the right one of which is smaller than the left one in pixels and physical metrics) and often want to open something on the right monitor on the launcher which is on autohide. (Sticky edges are off in the display settings so moving the cursor between the screens feels more natural.) This requires me to move the cursor slowly to the left edge of the right monitor because if I move it as fast as usual, the cursor moves to the left monitor.

I'd like it if I could move my cursor to the bottom edge to fade in the launcher. However, I couldn't find a commend to do so.

If there is a command to fade the launcher in or some other way to do this, let me know, please.

8
  • For my understanding, is your launcher set to autohide? Also: do you need to have windows spread over two monitors? If not a simple way would be to drag the right monitor upwards in monitor settings, so there is only a small area to jump from one to the other. I am pretty sure a nice solution is possible one way or the other. Let me know. Apr 13, 2015 at 18:47
  • @JacobVlijm Thank you. Yes, my launcher is set to autohide. I forgot to mention it because I'm so used to it. I didn't know it's possible to drag the displays around freely because the settings are made in a way that they snap in on the edges when dragged around quickly and without precision. So this would be a good solution if there weren't a few bugs, especially that the launcher didn't come out anymore after I restarted the computer. Furthermore, this wouldn't be a good permanent solution since my right monitor is smaller than the left one (in pixels and physical metrics).
    – UTF-8
    Apr 13, 2015 at 20:23
  • Ah I see. We can create something that makes the mouse pointer only cross a certain point (the left side of the right screen) when it is at least x time "on the edge" (2-3 seconds?) would that be an idea? If you like it, it would be fun to do. If so I´ ll look into it tomorrow :). Let me know. Apr 13, 2015 at 20:28
  • I don't think that that's a good idea because it would make it hard to drag windows between the screens and would feel unnatural even without a window on the cursor.
    – UTF-8
    Apr 13, 2015 at 20:32
  • Wait, but your suggestion is probably very well possible in an elegant form. will look into it (again) tomorrow... Apr 13, 2015 at 20:45

1 Answer 1

1

Show the launcher when the mouse enters a "trigger" area

The script below activates the (auto-hidden) launcher when the mouse pointer enters a certain area (activation area in the image).

Since it would not be convenient to have to draw an exactly straight line towards the targeted launcher icon, after the launcher is activated, I created an area of 200px from the left side of the (right) screen, in which you can freely move around without hiding the launcher again (the move area).

enter image description here

How to use

  1. The script uses xdotool to get the mouse position:

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

  3. In the head section of the script, I set the values as they should be appropriate to your screen combination and top-alligned. If you however would use the script with other screen (sizes) or you would like to alter the (trigger-) marges, you can change it in the head of the script:

    # the script assumes the two screens are top-alligned (!)
    
    #-- set the area to trigger the launcher (from left bottom of second screen) below:
    vert_marge = 50
    hor_marge = 200
    #-- set the width of the left screen below:
    width_screen1 = 1680
    #-- set the height of the right screen below:
    height_screen2 = 900
    #---
    
  4. Test-drive the script with the command:

    python3 /path/to/trigger_launcher.py
    
  5. If all works fine, add it to your Startup Applications: Dash > Startup Applications > Add. Add the command:

    /bin/bash -c "sleep 15&&python3 /path/to/trigger_launcher.py"
    

The script

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

# the script assumes the two screens are top-alligned (!)

#-- set the area to trigger the launcher (from left bottom of second screen) below:
vert_marge = 50
hor_marge = 200
#-- set the with of the left screen below:
width_screen1 = 1680
#-- set the height of the right screen below:
height_screen2 = 900
#--


vert_line = height_screen2-vert_marge
hor_line2 = width_screen1+hor_marge
k = [" org.compiz.unityshell:/org/compiz/profiles/unity/plugins/unityshell/ ",
    "gsettings set ", "launcher-hide-mode 1", "launcher-hide-mode 0"]

hide = k[1]+k[0]+k[2]; show = k[1]+k[0]+k[3]

def set_launcher(command):
    subprocess.Popen(["/bin/bash", "-c", command])

def get_mousepos():
    curr = subprocess.check_output(["xdotool", "getmouselocation"]).decode("utf-8")
    return [int(it.split(":")[1]) for it in curr.split()[:2]]

current1 = get_mousepos()
while True:
    time.sleep(0.3)
    current2 = get_mousepos()
    if not current1 == current2:
        test1 = [int(current1[1]) > vert_line, width_screen1 < int(current1[0]) < hor_line2]
        test2 = [int(current2[1]) > vert_line, width_screen1 < int(current2[0]) < hor_line2]
        test3 = any([int(current2[0]) > hor_line2, int(current2[0]) < width_screen1])
        if (all(test1), all(test2)) == (False, True):
            set_launcher(show)
        elif test3 == True:
            set_launcher(hide)
    current1 = current2

Edit

Below a version with a time break of 3 seconds, instead of a "move area", as you mentioned in a comment.

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

# the script assumes the two screens are top-alligned (!)

#-- set the area to trigger the launcher (from left bottom of second screen) below:
vert_marge = 50
hor_marge = 200
#-- set the with of the left screen below:
width_screen1 = 1680
#-- set the height of the right screen below:
height_screen2 = 900
#--

vert_line = height_screen2-vert_marge
hor_line2 = width_screen1+hor_marge
k = [" org.compiz.unityshell:/org/compiz/profiles/unity/plugins/unityshell/ ",
    "gsettings set ", "launcher-hide-mode 1", "launcher-hide-mode 0"]

hide = k[1]+k[0]+k[2]; show = k[1]+k[0]+k[3]

def set_launcher(command):
    subprocess.Popen(["/bin/bash", "-c", command])

def get_mousepos():
    curr = subprocess.check_output(["xdotool", "getmouselocation"]).decode("utf-8")
    return [int(it.split(":")[1]) for it in curr.split()[:2]]

current1 = get_mousepos()
while True:
    time.sleep(0.3)
    current2 = get_mousepos()
    if not current1 == current2:
        test1 = [int(current1[1]) > vert_line, width_screen1 < int(current1[0]) < hor_line2]
        test2 = [int(current2[1]) > vert_line, width_screen1 < int(current2[0]) < hor_line2]
        if (all(test1), all(test2)) == (False, True):
            set_launcher(show)
            time.sleep(3)
            set_launcher(hide)
    current1 = current2
8
  • Thank you! It is, however, inconvenient for me to regard the left-right position first, before moving the mouse down, so a small trigger area isn't good, and I don't want to move the cursor all the way to the right. That's why I changed the script so the launcher is hidden again, 3 seconds after it's shown. Before submitting this comment I took a look at your script (I don't know anything about Python, so it wasn't obvious what it does immediately) and thought that ...
    – UTF-8
    Apr 14, 2015 at 19:00
  • gsettings set org.compiz.unityshell:/org/compiz/profiles/unity/plugins/unityshell/ launcher-hide-mode 0 && sleep 3 && gsettings set org.compiz.unityshell:/org/compiz/profiles/unity/plugins/unityshell/ launcher-hide-mode 1 set as edge biding in CompizConfig (under Commands) should do the same thing. I tried it but it only works when done on the left monitor. Do you know how to change it to the right monitor?
    – UTF-8
    Apr 14, 2015 at 19:03
  • @UTF-8 added the time-break version. I'd prefer to add the time break inside python, apart from the issue you're having adding it to the shell command. Apr 14, 2015 at 19:13
  • @UTF-8 please let me know if this is what you were aiming at. Apr 14, 2015 at 19:18
  • @UTF-8 BTW did you try the (first) script? I am not quite getting what you are describing. Apr 14, 2015 at 19:19

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.