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
    • 最新
    • 标签
主页 / user-245933

PatrickSteiner's questions

Martin Hope
PatrickSteiner
Asked: 2019-06-24 10:18:45 +0800 CST

如何使用 `wmctrl` 通过 PID 调整窗口大小和移动窗口?

  • 2

我正在使用 21:9 显示器并编写了一个脚本,使用键盘快捷键将我的窗口平铺/对齐到显示器的左侧、中心和右侧:

┌─────────┬─────────┬─────────┐
│ window1 │ window2 │ window3 │
│ left    │ centre  │ right   │
│ aligned │ aligned │ aligned │
└─────────┴─────────┴─────────┘

该脚本通过获取当前聚焦窗口的名称来工作:
WINDOW_NAME=$(xdotool getwindowfocus getwindowname)
并使用其窗口名称对齐窗口:
wmctrl -ir "$WINDOW_NAME" -e 1,$X_OFFSET,$Y_OFFSET,$X_WIDTH,$Y_HEIGHT

问题是,当打开多个具有相同窗口名称的窗口(例如 2 个 Firefox 浏览器或 3 个终端等)时,它不会移动当前焦点窗口,而是从所有具有相同名称的窗口中移动,即第一个打开的窗口.

即假设我打开了 3 个终端,并且我想要对齐终端 T2,脚本将对齐 T1 而不是 T2,因为首先打开了 T1。

所以我的想法是使用进程ID(PID)而不是使用窗口名称,因为与窗口名称不同,PID是唯一的。问题是:是否可以wmctrl使用 PID?

在我的手册页中,wmctrl我找到了-i将变量解释<WIN>为数字而不是字符串名称的选项。

$ man wmctrl 
[...]
    -e <MVARG>
      Resize  and  move  a  window  that  has been specified with a -r
      action according to the <MVARG> argument.
[...]
    -r <WIN>
      Specify a target window for an action.
[...]
    -i     
      Interpret window arguments (<WIN>) as  a  numeric  value  rather
      than  a  string name for the window. If the numeric value starts
      with the prefix '0x' it is assumed to be a hexadecimal number.
[...]

我真的不明白这个-i选项的含义,并认为这可能意味着可以使用 PID 而不是窗口名称:

WINDOW_ID=$(xdotool getactivewindow getwindowpid)
WINDOW_ID=$(printf 0x%x $WINDOW_ID)
wmctrl -ir "$WINDOW_ID" -e 1,$X_OFFSET,$Y_OFFSET,$X_WIDTH,$Y_HEIGHT

不幸的是,这不起作用(无论是十进制数,还是十六进制数)。

Q1:是否可以使用wmctrlPID 而不是窗口名称?
Q2:这个-i选项实际上是什么意思?

wmctrl
  • 1 个回答
  • 3018 Views
Martin Hope
PatrickSteiner
Asked: 2019-04-18 08:38:16 +0800 CST

如何在 linux mint 上禁用网络连接检查?

  • 1

(虚拟机操作系统:Linux Mint 19.1 Tessa)

我正在尝试禁用 Linux Mint 上的网络连接检查。 该网站展示了如何在 Ubuntu 17.10 的 GUI 中禁用它。不幸的是,在 Mint 中,路径 Settings > Privacy > Turn off "network connectivity checking" 不存在。根据这篇文章,GUI只是将文件中的一行条目更改/var/lib/NetworkManager/NetworkManager-intern.conf为false:

[connectivity] 
.set.enabled=false

通过使用cat我看到这两行甚至不存在,因此我插入它们并再次尝试以下过程:

1. network-tray-icon > Wired_connection_1 > Disconnect
2. wireshark start packet capturing for interface "enp0s3"
3. network-tray-icon > Wired_connection_1 > Connect
4. wireshark stop packet capturing

通过应用 display-filter (dns.qry.name == "connectivity-check.ubuntu.com"),在 wireshark 中,正好有 100 个 DNS 查询及其相应的响应。所以这两条线的插入不起作用。

我也确实覆盖了以下文件,如此处所述:

sudo touch /etc/NetworkManager/conf.d/20-connectivity-ubuntu.conf

仍然是 100 条 DNS 消息。

如何使用终端禁用 Linux Mint 上的网络连接检查?

linux-mint dns
  • 1 个回答
  • 2887 Views
Martin Hope
PatrickSteiner
Asked: 2019-04-15 23:50:21 +0800 CST

无法禁用网络时间控制 (NTP)

  • 0

我想使用wireshark分析virtualbox(操作系统:Linux Mint 19.1 Tessa)内的一些协议(ARP、NDP等),并试图禁用“网络时间控制”-同步。

yuza@VirtualBox:~$ sudo timedatectl set-ntp off && timedatectl status 
                      Local time: Fri 2019-04-12 09:59:28 CEST
                  Universal time: Fri 2019-04-12 07:59:28 UTC
                        RTC time: Fri 2019-04-12 07:59:29
                       Time zone: Europe/Vienna (CEST, +0200)
       System clock synchronized: yes
systemd-timesyncd.service active: no
                 RTC in local TZ: no

尽管如此,wireshark 仍然经常捕获 NTP 流量。
我知道wiresharks capture filter和display filter。
不过,我很感兴趣,为什么我不能使用 NTP 来禁用 NTP sudo timedatectl set-ntp off?


编辑:
我没有安装chrony:

yuza@VirtualBox:~$ apt policy chrony | grep Installed
  Installed: (none)

Wireshark 抓包截图: NTP_Wireshark_Capture

UDP 123端口进程打开的文件列表:

yuza@VirtualBox:~$ sudo lsof -iUDP:123
COMMAND PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
ntpd    716  ntp   16u  IPv6  19895      0t0  UDP *:ntp 
ntpd    716  ntp   17u  IPv4  19900      0t0  UDP *:ntp 
ntpd    716  ntp   18u  IPv4  19904      0t0  UDP localhost:ntp 
ntpd    716  ntp   19u  IPv6  19906      0t0  UDP ip6-localhost:ntp 
ntpd    716  ntp   23u  IPv4  22229      0t0  UDP VirtualBox:ntp 
ntpd    716  ntp   24u  IPv6  22232      0t0  UDP VirtualBox:ntp 
ntp ntpd
  • 1 个回答
  • 1881 Views
Martin Hope
PatrickSteiner
Asked: 2018-09-16 11:42:49 +0800 CST

Linux Mint xfce 键盘快捷键保存在哪里?

  • 3

我目前正在使用桌面环境“ xfce4 ”运行“Linux Mint 18.3 Sylvia ”。
因为我必须设置多台 PC,所以我想编写一个 bash 脚本来配置系统的键盘快捷键。

我做了一些研究,但这些文章都不是我要搜索的。例如,这里作者使用Cinnamon作为 DE,因此/org/cinnamon/desktop/keybindings/我的系统上不存在给定的文件路径 ()。在这篇文章中,作者正在使用该程序dconf-cli。但我不想使用外部应用程序。我真的很想知道,在我的系统上,这些快捷方式将被保存在哪里。

keyboard-shortcuts keyboard
  • 1 个回答
  • 1096 Views
Martin Hope
PatrickSteiner
Asked: 2018-06-05 12:39:32 +0800 CST

如何在 xfce 中为“运行程序...”创建快捷方式

  • 2

操作系统:Linux Mint 18.2 索尼娅
DE:XFCE

通过单击面板中的菜单按钮,存在选项Run Program ...。我想创建一个快捷方式Menu/Settings/Settings-Manager/Keyboard/Application-Shortcuts来从菜单访问这个应用程序启动器。是否存在可用于分配快捷键组合以调用此应用程序启动器的终端命令?

在此处输入图像描述

xfce desktop-environment
  • 1 个回答
  • 11845 Views
Martin Hope
PatrickSteiner
Asked: 2018-04-06 00:47:34 +0800 CST

如何在游侠预览中启用语法突出显示?

  • 13

我看过一些截图,其中游侠在其预览窗口中使用语法高亮。所以我想知道如何启用此功能,发现我需要scope.sh目录中的文件, 该文件/home/user/.config/ranger/scop.sh将使用命令生成 $ ranger --copy-config=scope。然而,在生成它之后,预览窗口完全消失了,尽管我插入set use_preview_script true了rc.config.

问:有人知道如何在 Ranger 预览窗口中启用语法高亮(尤其是 C/C++)吗?

ranger syntax-highlighting
  • 2 个回答
  • 8057 Views
Martin Hope
PatrickSteiner
Asked: 2018-03-15 07:13:36 +0800 CST

通过连接到 Logitech MX Master S2 鼠标蓝牙连接失败

  • 0

我正在使用 Linux Mint 18.2 Sonja 并想在不使用蓝牙加密狗的情况下连接我的新罗技 MX Master S2 鼠标,而是直接使用笔记本电脑的内置蓝牙模块。运行命令后,这适用于我的电脑:

~$ sudo hciconfig hci0 sspmode 1
~$ sudo hciconfig hci0 down
~$ sudo hciconfig hci0 up

但是,通过输入sudo hciconfig hci0 sspmode 1,我在笔记本上收到以下错误消息:

Can't set Simple Pairing mode on hci0: Input/output error (5)

在阅读了不同社区的几篇文章后,他们建议执行以下操作:

alpha@Pavilion ~ $ bluetoothctl 
[NEW] Controller B0:35:9F:0E:4F:3D Pavilion [default]
[NEW] Device C5:E2:3F:77:5C:3D MX Master 2S
[NEW] Device DD:6A:F3:5A:A2:A2 MI Band 2
[NEW] Device C5:E2:3F:77:5C:3B MX Master 2S
[NEW] Device 00:02:3C:51:C6:12 Creative T50 Wireless
[bluetooth]# power on
Changing power on succeeded
[bluetooth]# agent on
Agent registered
[bluetooth]# default-agent 
Default agent request successful
[bluetooth]# scan on
Discovery started
[CHG] Device C5:E2:3F:77:5C:3D RSSI: -15
[bluetooth]# scan off
Discovery stopped
[CHG] Device C5:E2:3F:77:5C:3D RSSI: -4
[bluetooth]# trust C5:E2:3F:77:5C:3D
Changing C5:E2:3F:77:5C:3D trust succeeded
[bluetooth]# pair C5:E2:3F:77:5C:3D
Attempting to pair with C5:E2:3F:77:5C:3D
[CHG] Device C5:E2:3F:77:5C:3D Connected: yes
Failed to pair: org.bluez.Error.AuthenticationTimeout
[CHG] Device C5:E2:3F:77:5C:3D Connected: no
[bluetooth]# connect C5:E2:3F:77:5C:3D
Attempting to connect to C5:E2:3F:77:5C:3D
Failed to connect: org.bluez.Error.Failed
[bluetooth]# version
Version 5.37
[bluetooth]# exit
Agent unregistered
[DEL] Controller B0:35:9F:0E:4F:3D Pavilion [default]
alpha@Pavilion ~ $ 

如您所见,通过尝试配对鼠标,它很快连接并出现错误:Failed to pair: org.bluez.Error.AuthenticationTimeout
有人有想法吗?

提前致谢!

mouse bluetooth
  • 3 个回答
  • 9940 Views

Sidebar

Stats

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

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

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

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve