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-473048

Alexander Praehauser's questions

Martin Hope
Alexander Praehauser
Asked: 2024-08-14 16:17:26 +0800 CST

找出 X11 的键盘标识符

  • 5

我为我的默认笔记本电脑键盘和添加的其他键盘提供了一个自定义键盘布局,设置/etc/X11/xorg.conf.d/00-keyboard.conf如下:

Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "dxkb"
        Option "XkbVariant" "main"
EndSection

但最近我制作了一个 Lily58 键盘,我想制作一个键盘映射的变体,使其自动应用于 Lily58,但不适用于其他键盘,如下所示:

Section "InputClass"
        Identifier "Lily58"
        MatchIsKeyboard "on"
        Option "XkbLayout" "dxkb"
        Option "XkbVariant" "lily58"
EndSection

问题在于如何找出 Lily58 的标识符。我找到的所有资源都只提到了标识符system-keyboard,但没有提到特定键盘的标识符,并且使用Lily58上述方法似乎无法识别键盘。我如何找出键盘的正确标识符?

x11
  • 1 个回答
  • 9 Views
Martin Hope
Alexander Praehauser
Asked: 2024-08-11 02:53:26 +0800 CST

命令拉入 CD 驱动器

  • 5

我想将我的 CD 收藏数字化。最快的方法是创建一个命令,该命令拉入 CD 驱动器,调用 abcde 来翻录并自动弹出驱动器,并将该命令绑定到一个键。编写该命令所需的唯一部分是我不知道可以使用什么命令自动拉入我的 CD 驱动器,基本上是 的逆eject。有人知道这样的命令吗?

data-cd
  • 1 个回答
  • 30 Views
Martin Hope
Alexander Praehauser
Asked: 2024-08-04 17:24:25 +0800 CST

如何通过 ssh 播放音频,而无需先通过物理登录使用声卡?

  • 5

我有一台装有 Gentoo 的 Raspberry Pi,我用它来播放音频。我的想法是通过 ssh 登录,然后从命令行播放音频。但是当我在没有先进行物理登录的情况下通过 ssh 进入它并使用声卡时,alsamixer我得到:

ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.2.11/work/alsa-lib-1.2.11/src/confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.2.11/work/alsa-lib-1.2.11/src/conf.c:5204:(_snd_config_evaluate) function snd_func_card_inum returned error: File or directory not found
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.2.11/work/alsa-lib-1.2.11/src/confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.2.11/work/alsa-lib-1.2.11/src/conf.c:5204:(_snd_config_evaluate) function snd_func_concat returned error: File or directory not found
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.2.11/work/alsa-lib-1.2.11/src/confmisc.c:1342:(snd_func_refer) error evaluating name
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.2.11/work/alsa-lib-1.2.11/src/conf.c:5204:(_snd_config_evaluate) function snd_func_refer returned error: File or directory not found
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.2.11/work/alsa-lib-1.2.11/src/conf.c:5727:(snd_config_expand) Evaluate error: File or directory not foundccc
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.2.11/work/alsa-lib-1.2.11/src/control/control.c:1570:(snd_ctl_open_noupdate) Invalid CTL default
Error when opening mixer: File or directory not found

更一般地说,我现在无法播放音频。如果我先以物理方式登录并调用alsamixer,然后alsamixer通过 ssh 使用,那么它就可以正常工作,我也可以播放音频。所以我想我可以通过物理登录来激活声卡,而不能通过 ssh 来使用它,而且一旦激活,我也可以通过 ssh 使用它。我怎样才能在不进行物理登录的情况下激活我的声卡?

编辑:看来 ssh 没有为我的会话分配席位。

ssh
  • 1 个回答
  • 41 Views
Martin Hope
Alexander Praehauser
Asked: 2024-07-18 04:30:50 +0800 CST

Systemd-user-service 启用键盘没有错误,但不起作用

  • 5

我的笔记本电脑键盘很差,但 Lily58 好得多,所以我写了一个 bash 脚本来禁用我的笔记本电脑键盘,这样我就可以将 Lily58 放在上面,然后再重新启用它。但是当我禁用笔记本电脑键盘时,如果我将笔记本电脑挂起,它就会保持禁用状态,而我希望它在恢复时自动重新启用。所以我写了一个简短的 bash 脚本

#!/bin/bash

fconfig="/home/alex/.keyboard" 
id=$(xinput | grep AT | sed -n '2,2p' | awk '{print $7}' | sed 's/[^0-9]*//g')

if [ -f $fconfig ]; then
  read -r var< $fconfig
  if [ "$var" = "disabled" ]; then
      xinput enable $id
      echo "enabled" > $fconfig
  fi
fi

/home/alex/.keyboard这将检查跟踪键盘是否启用的文件中是否存在“disabled” ,如果是,则xinput使用通过筛选输出获得的 id 运行以重新启用,xinput 方式与 的定义相同id,然后设置/home/alex/.keyboard为enabled。当我从终端触发 bash 脚本时,此操作可以正常工作,但是当我启动 systemd 服务时

[Unit]
Description=This service enables your keyboard after suspension
PartOf=graphical-session.target

[Service]
Type=oneshot
ExecStart=/home/alex/bash/enable-keyboard

[Install]
WantedBy=multi-user.target

我想在暂停后运行,它设置/home/alex/.keyboard为enabled但实际上并没有重新启用我的键盘。此外,journalctl -xeu enable-keyboard.service没有指示任何错误:

Jul 17 22:16:25 gentoolaptop systemd[795]: Starting This service enables your keyboard after suspension.
░░ Subject: A start job for unit UNIT has begun execution
░░ Defined-By: systemd
░░ Support: https://gentoo.org/support/
░░ 
░░ A start job for unit UNIT has begun execution.
░░ 
░░ The job identifier is 8969.
Jul 17 22:16:25 gentoolaptop systemd[795]: Finished This service enables your keyboard after suspension.
░░ Subject: A start job for unit UNIT has finished successfully
░░ Defined-By: systemd
░░ Support: https://gentoo.org/support/
░░ 
░░ A start job for unit UNIT has finished successfully.
░░ 
░░ The job identifier is 8969.

出了什么问题?

编辑:如果我将一个子句放入脚本中以将输出打印xinput到文件中,则输出将由一个空行组成。

编辑:的输出systemctl --user status dbus.socket dbus.service是

● dbus.socket - D-Bus User Message Bus Socket
Loaded: loaded (/usr/lib/systemd/user/dbus.socket; static)
                Active: active (running) since Thu 2024-07-18 17:22:54 CEST; 5 days ago
                Triggers: ● dbus.service
                Listen: /run/user/1000/bus (Stream)
                Tasks: 0 (limit: 47295)
                Memory: 4.0K (peak: 1.5M)
                CPU: 8ms
                CGroup: /user.slice/user-1000.slice/[email protected]/app.slice/dbus.socket

                Jul 18 17:22:54 gentoolaptop systemd[830]: Starting D-Bus User Message Bus Socket...
                Jul 18 17:22:54 gentoolaptop systemd[830]: Listening on D-Bus User Message Bus Socket.

                ● dbus.service - D-Bus User Message Bus
                Loaded: loaded (/usr/lib/systemd/user/dbus.service; static)
                                Active: active (running) since Thu 2024-07-18 17:22:54 CEST; 5 days ago
                                TriggeredBy: ● dbus.socket
                                Docs: man:dbus-daemon(1)
                                Main PID: 897 (dbus-daemon)
                                Tasks: 1 (limit: 47295)
                                Memory: 1.0M (peak: 1.7M)
                                CPU: 252ms
                                CGroup: /user.slice/user-1000.slice/[email protected]/session.slice/dbus.service
                                └─897 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only

                                Jul 23 16:55:45 gentoolaptop dbus-daemon[897]: [session uid=1000 pid=897 pidfd=5] Activating via systemd: service name='org.freedesktop.Notifications' unit='dunst.service' requested by ':1.149' (uid=1000 pid=105378 comm="/bin/dunstify Battery <80 Battery under 80%.")
                                Jul 23 17:11:00 gentoolaptop dbus-daemon[897]: [session uid=1000 pid=897 pidfd=5] Failed to activate service 'org.freedesktop.Notifications': timed out (service_start_timeout=120000ms)
                                Jul 23 17:19:31 gentoolaptop dbus-daemon[897]: [session uid=1000 pid=897 pidfd=5] Activating via systemd: service name='org.freedesktop.Notifications' unit='dunst.service' requested by ':1.152' (uid=1000 pid=106706 comm="/bin/dunstify Battery <80 Battery under 80%.")
                                Jul 23 17:21:31 gentoolaptop dbus-daemon[897]: [session uid=1000 pid=897 pidfd=5] Failed to activate service 'org.freedesktop.Notifications': timed out (service_start_timeout=120000ms)
                                Jul 23 17:30:31 gentoolaptop dbus-daemon[897]: [session uid=1000 pid=897 pidfd=5] Activating via systemd: service name='org.freedesktop.Notifications' unit='dunst.service' requested by ':1.153' (uid=1000 pid=108520 comm="/bin/dunstify Battery <80 Battery under 80%.")
                                Jul 23 17:32:31 gentoolaptop dbus-daemon[897]: [session uid=1000 pid=897 pidfd=5] Failed to activate service 'org.freedesktop.Notifications': timed out (service_start_timeout=120000ms)
                                Jul 24 14:15:05 gentoolaptop dbus-daemon[897]: [session uid=1000 pid=897 pidfd=5] Activating via systemd: service name='org.freedesktop.Notifications' unit='dunst.service' requested by ':1.164' (uid=1000 pid=126615 comm="/bin/dunstify Battery <80 Battery under 80%.")
                                Jul 24 14:17:05 gentoolaptop dbus-daemon[897]: [session uid=1000 pid=897 pidfd=5] Failed to activate service 'org.freedesktop.Notifications': timed out (service_start_timeout=120000ms)
                                Jul 24 14:26:05 gentoolaptop dbus-daemon[897]: [session uid=1000 pid=897 pidfd=5] Activating via systemd: service name='org.freedesktop.Notifications' unit='dunst.service' requested by ':1.165' (uid=1000 pid=127823 comm="/bin/dunstify Battery <80 Battery under 80%.")
                                Jul 24 14:28:05 gentoolaptop dbus-daemon[897]: [session uid=1000 pid=897 pidfd=5] Failed to activate service 'org.freedesktop.Notifications': timed out (service_start_timeout=120000ms)

的输出ls -l /run/user/*/bus是

srw-rw-rw-   1 alex           alex            0 2024-07-18 17:22 /run/user/1000/bus
```.
systemd
  • 2 个回答
  • 83 Views
Martin Hope
Alexander Praehauser
Asked: 2024-07-10 22:55:46 +0800 CST

电池通知脚本可以独立运行,但由 systemd 服务触发时不起作用

  • 5

在我的 Gentoo Linux 上,使用 dunstify 作为通知守护进程,使用 StumpWM 作为窗口管理器,我编写了以下 bash 脚本,用于告知我电池状态:

#!/bin/bash
#This script notifies you if your battery is under 80% and puts the laptop to sleep in 5min if it is under 50% and isn't plugged in within that time.

if ! [ -z "$(acpi -b | cut -c 25)" ] && [[ $(acpi -b | cut -c 25) -lt 8 ]] && ! [[ "$(  acpi -b | cut -c 28)" == "%" ]]
then if ! [ -z "$(acpi -b | cut -c 25)" ] && [[ $(acpi -b | cut -c 25) -lt 5 ]] && ! [[ "$(acpi -b | cut -c 28)" == "%" ]]
     then dunstify "Battery <50" "Battery under 50%, will sleep in 5min."
          sleep 5m
          if ! [ -z "$(acpi -b | cut -c 25)" ] && [[ $(acpi -b | cut -c 25) -lt 5 ]] && ! [[ "$(acpi -b | cut -c 28)" == "%" ]]
          then sudo systemctl suspend
          fi
     else dunstify "Battery <80" "Battery under 80%."
     fi
fi

当我手动触发它时,它可以正常工作。但是,它应该每 10 分钟左右由 systemd 定期触发一次,并在电池电量不足时通知我。因此,我编写了以下 systemd-service:

[Unit]
Description=Checks your battery.
RefuseManualStart=no
RefuseManualStop=yes
 
[Service]
Type=oneshot
ExecStart=/bin/battery

如果电池电量高于 80%,服务将顺利完成,这是理所当然的。但是,如果电池电量低于 80%,服务将因错误而退出。查看日志,我发现以下内容:

░░ A start job for unit battery.service has begun execution.
░░ 
░░ The job identifier is 79311.
Jul 10 16:02:54 gentoolaptop battery[537360]: Connecting to D-Bus failed: Unable to autolaunc>Jul 10 16:02:54 gentoolaptop systemd[1]: battery.service: Main process exited, code=exited, s>░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: https://gentoo.org/support/
░░ 
░░ An ExecStart= process belonging to unit battery.service has exited.

我一直尝试将其作为用户服务运行,并收到此消息;作为系统服务运行,并被告知未设置 XDISPLAY 和 XAUTHORITY。为什么在作为服务触发时无法发送消息?

systemd
  • 2 个回答
  • 30 Views
Martin Hope
Alexander Praehauser
Asked: 2024-07-10 20:15:42 +0800 CST

永久设置 X11 中所有键盘的布局

  • 8

在我的笔记本电脑上,我使用 Gentoo Linux 并以 StumpWM 作为窗口管理器,我有一个自定义键盘布局,称为 daselt,我一直在使用它。到目前为止,我都是通过setxkbmap daselt daselt在启动时自动运行来设置它,但问题是,这只为始终连接的键盘设置它(例如我的笔记本电脑键盘),而不是为挂起后必须重新添加的外部键盘设置它。我想要做的是将键盘布局设置为默认设置,所有键盘在连接时都会设置为默认设置。所以我运行了

sudo localectl set-x11-keymap daselt "" daselt

并生成文件00-keyboard.conf,其内容为

# Written by systemd-localed(8), read by systemd-localed and Xorg. It's
# probably wise not to edit this file manually. Use localectl(1) to
# update this file.
Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "daselt"
        Option "XkbVariant" "daselt"
EndSection

但是,当我暂停笔记本电脑,然后再次唤醒它时,我的外接键盘会添加正常的 en-us 布局。我怎样才能使 daselt 布局自动应用于所有添加的键盘?

x11
  • 1 个回答
  • 52 Views
Martin Hope
Alexander Praehauser
Asked: 2024-02-29 01:20:02 +0800 CST

WLAN 唤醒应该可以工作,但不行

  • 7

按照这些说明,我发现phy0我的桌面上应该支持 wlan 唤醒并将其打开。

[root@Arch alex]# iw phy0 wowlan show
WoWLAN is enabled:
 * wake up on magic packet

但是,当我暂停系统并尝试从远处唤醒它时,它不起作用:

[alex@Archlaptop tmp]$ wol 44:E5:17:ED:9E:D2r
Waking up 44:E5:17:ED:9E:D2r...

但什么也没发生。此外,如果我关注Arch wiki,我不会收到 wlan 唤醒:

[root@Arch alex]# ethtool wlo1
Settings for wlo1:
        Link detected: yes

到底是怎么回事?

networking
  • 1 个回答
  • 25 Views
Martin Hope
Alexander Praehauser
Asked: 2023-10-28 22:51:11 +0800 CST

读取 bash 脚本中命令的数字 if 条件

  • 5

我正在尝试编写一个命令来查看我的电池状态,并在电池电量不足时暂停笔记本电脑。我尝试使用这样的东西:

#!/bin/bash
if [ $(acpi -b | cut -c 25) < 11 ]
then notify-send "Hello"
fi

这可行,但由于某种原因,如果我用一位数(如 5)替换 11,则会收到错误

battery-notify-standby: line 2: 5: No such file or directory

我还尝试用两个圆括号替换方括号,以将其指定为算术表达式。然后我得到

battery-notify-standby: line 2: ((: < 11 : syntax error: operand expected (error token is "< 11 ")

我不确定到底出了什么问题。有人可以帮我吗?

bash
  • 2 个回答
  • 47 Views
Martin Hope
Alexander Praehauser
Asked: 2023-05-05 15:56:46 +0800 CST

Xkb 亮度、音量控制和待机功能的名称

  • 5

我已经在其中编写了一个自定义键盘布局,xkb我想将音量和亮度控制以及待机和关机功能合并到其中,这样当我想更改它们时就不必触及最高行的键. 但是我不知道xkb这些函数的名称。有人知道它们以便我可以将它们放入我的xkb布局中吗?

keyboard
  • 1 个回答
  • 15 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