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 / 问题 / 994100
Accepted
thebunnyrules
thebunnyrules
Asked: 2018-01-10 19:01:18 +0800 CST2018-01-10 19:01:18 +0800 CST 2018-01-10 19:01:18 +0800 CST

是否可以在 Wayland 下启用焦点窃取?(侏儒外壳 3.26,Ubuntu 17.10)

  • 772

我刚刚在 Ubuntu 17.10 下从 XOrg 切换到 Wayland。

假设我在 Nautilus 中,然后单击一个文本文件。过去对我来说,我会自动切换到 gedit(每次我点击一个文件,即使 gedit 已经打开)。

在 Wayland 上,这发生在我第一次单击文件时(第一次打开 gedit 时),但之后不再切换。gedit 只是在后台打开文本文件,甚至没有弹出通知说“blablabla.txt 已在 gedit 中准备好”。

在 XOrg gnome-shell 下,我曾经能够安装一个名为Steal My Focus的扩展(也可以在 此处找到 3.26 的更新版本)。这些扩展似乎都不再起作用了。

还有一个 gsetting 与这些扩展做同样的事情:

gsettings set org.gnome.desktop.wm.preferences focus-new-windows 'strict'

这似乎也不再起作用了。

由于这发生在我切换到 Wayland 之后,我猜这与 Wayland 有关。

任何人都成功地在 Wayland 下禁用了焦点窃取保护。如果没有,有人有什么想法吗?建议?

nautilus
  • 1 1 个回答
  • 1089 Views

1 个回答

  • Voted
  1. Best Answer
    thebunnyrules
    2018-02-21T20:30:19+08:002018-02-21T20:30:19+08:00

    好吧,不确定这个错误是否只发生在我的机器上,或者它是否更普遍。我可能是错的,但我猜这可能是由于一些 Wayland 安全限制阻止应用程序聚焦已经打开的窗口(据我所知,窗口管理器现在应该处理这些事情,而不是 X 中的显示服务器)。我假设这是一个过渡性问题,gnome 最终将使 gedit 能够专注于新选项卡。

    在等待此修复程序时,我想出了一个部分修复程序,当在 gedit 中打开新选项卡时会发送通知。这并不能解决自动对焦问题,但至少它会给你一些提示,这样你就不会坐在那里 2 或 3 秒想知道为什么你的窗口还没有打开。

    在非 root 终端中,输入:

    gedit admin:///usr/bin/gedit-notify
    

    在gedit-notify中,粘贴以下脚本:

    #!/bin/bash
    # purpose of this script: gedit under gnome Wayland has pretty messed up focusing and activation problems. First document/tab opened will focus normally but all the following ones open in the background without the traditional notification: "Your window is now read, click to focus". Its very distracting behavior because for the first 2 seconds you're wondering if your click was registered or not, if the app opened or not, etc. This script sends a notification every time you open a text file in the background. 
    
    skip_list=true # you get notified but your notification list doesn't get spammed.
    
        gedit_inst=$(ps ax|grep " gedit "|wc -l)      #total number gedit windows + 1
        gedit_inst=$(expr $gedit_inst - 1)          #remove one from the count to account for the grep " gedit " process
        gedit_s=$(ps ax|grep " gedit -s"|wc -l)         # -s switch represents signle / independent instance for gedit. 
                                                    # gedit_s represents the number of gedit windows running as 
                                                    # independent instances + 1
        gedit_s=$(expr $gedit_s - 1)                # same logic as before
        gedit_inst=$(expr $gedit_inst - $gedit_s)   #substracts the # of windows running in independent instances 
                                    #from total cound - because they don't affect the focus behavior. 
        if [ "$skip_list" = true ]; then
            n_arg0="--hint";n_arg1="int:transient:1"
        else
            n_arg0="-u";n_arg1="low"
        fi
    
        if [ "$gedit_inst" = 0 ]; then notify=false;fi 
    
    n=0
    while true; do
        n=$(expr $n + 1)
        file=$(eval echo \$$n)
        if ! [ -z "$file" ]; then 
            gedit "$file" &
            if [ -z "$err" -o "$err" = 0 ]; then 
                    err="$?"
            fi
        else
            count=$(expr $n - 1) 
            if [ $count = 0 ]; then 
                if [ "$notify" != false ]; then notify-send $n_arg0 $n_arg1 "TEXT EDITOR is ready. Activate it manually.";fi
                gedit
            fi
            break; 
        fi          
    done
    
    if [ "$err" = 0 -a "$notify" != false ]; then 
        if [ $count -gt 1 ]; then
            notify-send $n_arg0 $n_arg1 "TEXT EDITOR is ready. Activate it manually." "$count files were opened."
        elif [ $count = 1 ]; then
            notify-send $n_arg0 $n_arg1 "TEXT EDITOR is ready. Activate it manually." "file: \"$1\""
        fi
    elif [ "$err" != 0 ]; then
        notify-send -i error "TEXT EDITOR: I ran into some error(s) while opening your file(s)."
    fi
    

    保存gedit-notify,然后输入:

    cd /usr/bin
    sudo chmod +x gedit-notify; sudo touch gedit-notify
    gedit admin:///usr/share/applications/gedit-notify.desktop
    

    在gedit-notify.desktop中,粘贴以下代码:

    [Desktop Entry]
    Name=Text Editor (Notify)
    Comment=Edit text files
    Exec=gedit-notify %U
    Terminal=false
    Type=Application
    StartupNotify=true
    Icon=gedit
    Categories=GNOME;GTK;Utility;TextEditor;
    X-GNOME-DocPath=gedit/gedit.xml
    X-GNOME-FullName=Text Editor
    X-GNOME-Bugzilla-Bugzilla=GNOME
    X-GNOME-Bugzilla-Product=gedit
    X-GNOME-Bugzilla-Component=general
    X-GNOME-Bugzilla-Version=3.22.1
    X-GNOME-Bugzilla-ExtraInfoScript=/usr/share/gedit/gedit-bugreport.sh
    Actions=new-window;new-document;
    Keywords=Text;Editor;Plaintext;Write;
    X-Ubuntu-Gettext-Domain=gedit
    
    X-AppStream-Ignore=true
    
    [Desktop Action new-window]
    Name=New Window
    Exec=gedit --new-window
    
    [Desktop Action new-document]
    Name=New Document
    Exec=gedit --new-document
    

    这将创建一个桌面快捷方式,该快捷方式将在仪表板和打开方式菜单中显示为文本编辑器(通知)。在nautilus中,四处浏览,找到一个文本文件,右键单击它,选择属性,单击打开方式选项卡,选择“文本编辑器(通知)”,设置为默认值。将有 4 或 5 种不同类型的文本文件需要重复此过程。冲洗并重复。

    • 1

相关问题

  • Nautilus 自动以 root 身份浏览

  • 在 nautilus 中刷新缩略图

  • 如何在 Nautilus 中管理保存的完整网页及其目录(例如 n.html 和 n_files)

  • 如何让 Nautilus windows 坚持拖放?[关闭]

  • Nautilus 中的 FTP 连接问题 - 一段时间后似乎超时

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