AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 608837
Accepted
UTF-8
UTF-8
Asked: 2015-04-14 09:15:25 +0800 CST2015-04-14 09:15:25 +0800 CST 2015-04-14 09:15:25 +0800 CST

通过边缘绑定显示启动器

  • 772

我使用 2 个显示器(右边的一个在像素和物理指标上比左边的小)并且经常想在自动隐藏的启动器上的右显示器上打开一些东西。(显示设置中的粘性边缘关闭,因此在屏幕之间移动光标感觉更自然。)这需要我将光标缓慢移动到右显示器的左边缘,因为如果我像往常一样快速移动它,光标移动到左边的显示器。

如果我可以将光标移动到底部边缘以在启动器中淡入淡出,我会喜欢它。但是,我找不到这样做的推荐。

如果有淡入启动器的命令或以其他方式执行此操作,请告诉我。

launcher
  • 1 1 个回答
  • 73 Views

1 个回答

  • Voted
  1. Best Answer
    Jacob Vlijm
    2015-04-15T10:29:58+08:002015-04-15T10:29:58+08:00

    当鼠标进入“触发”区域时显示启动器

    当鼠标指针进入某个区域(图像中的激活区域)时,下面的脚本会激活(自动隐藏)启动器。

    由于必须向目标启动器图标画一条直线并不方便,启动器激活后,我在屏幕左侧(右)创建了一个 200px 的区域,您可以在其中自由移动无需再次隐藏发射器(移动区域)。

    在此处输入图像描述

    如何使用

    1. 该脚本用于xdotool获取鼠标位置:

      sudo apt-get install xdotool
      
    2. 将脚本复制到一个空文件中,另存为trigger_launcher.py

    3. 在脚本的头部部分,我设置了适合您的屏幕组合和顶部对齐的值。但是,如果您将脚本与其他屏幕(尺寸)一起使用,或者您想更改(触发)边距,则可以在脚本的头部进行更改:

      # 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. 使用以下命令测试脚本:

      python3 /path/to/trigger_launcher.py
      
    5. 如果一切正常,将其添加到您的启动应用程序:Dash > Startup Applications > Add。添加命令:

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

    剧本

    #!/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
    

    编辑

    下面的版本有 3 秒的时间中断,而不是“移动区域”,正如您在评论中提到的那样。

    #!/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
    
    • 1

相关问题

  • 在 10.10 上更改布局和外观

  • 某些应用程序的启动器菜单中没有“保留在启动器中”命令[重复]

  • 如何删除 Unity 启动器?

  • 使用终端应用程序的启动器,如何在程序完成后保持终端打开?

  • 如何为 .sh 文件创建应用程序启动器?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve