我想用 来控制显示器亮度ddcutil
,需要i2c-dev
加载模块。
它不会自动加载,所以我正在关注ArchWiki 上的方向尝试使用 systemd 自动加载它。systemd-modules-load.service
没有错误,但是模块未在启动时加载。
# Not loaded
[rcorre@midova ~]$ sudo ddcutil setvcp 10 10
Display not found
# But I've got a file in modules-load.d
[rcorre@midova ~]$ cat /etc/modules-load.d/i2c-dev
i2c-dev
# The logs have always been rotated on boot ...
[rcorre@midova ~]$ sudo systemctl status systemd-modules-load
● systemd-modules-load.service - Load Kernel Modules
Loaded: loaded (/usr/lib/systemd/system/systemd-modules-load.service; static; vendor preset: disabled)
Active: active (exited) since Thu 2019-09-05 06:51:35 EDT; 14min ago
Docs: man:systemd-modules-load.service(8)
man:modules-load.d(5)
Main PID: 449 (code=exited, status=0/SUCCESS)
Tasks: 0 (limit: 4915)
Memory: 0B
CGroup: /system.slice/systemd-modules-load.service
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
# ... so I try restarting the service
[rcorre@midova ~]$ sudo systemctl restart systemd-modules-load
[rcorre@midova ~]$ sudo systemctl status systemd-modules-load
● systemd-modules-load.service - Load Kernel Modules
Loaded: loaded (/usr/lib/systemd/system/systemd-modules-load.service; static; vendor preset: disabled)
Active: active (exited) since Thu 2019-09-05 07:10:19 EDT; 14s ago
Docs: man:systemd-modules-load.service(8)
man:modules-load.d(5)
Process: 8189 ExecStart=/usr/lib/systemd/systemd-modules-load (code=exited, status=0/SUCCESS)
Main PID: 8189 (code=exited, status=0/SUCCESS)
Sep 05 07:10:19 midova systemd[1]: Stopping Load Kernel Modules...
Sep 05 07:10:19 midova systemd[1]: Starting Load Kernel Modules...
Sep 05 07:10:19 midova systemd[1]: Started Load Kernel Modules.
# Still no luck
[rcorre@midova ~]$ sudo ddcutil setvcp 10 10
Display not found
# But I can load it manually
[rcorre@midova ~]$ sudo modprobe i2c-dev
[rcorre@midova ~]$ sudo ddcutil setvcp 10 10
答案1
每个配置文件都以 的格式命名
/etc/modules-load.d/<program>.conf
。
后缀.conf
是必需的对于 modules-load.d – 忽略其他文件。(这是程序区分实际配置和剩余备份的方式,例如各种发行版的 .pacnew/.rpmnew 文件。)
答案2
有几种方法可以modprobe
在启动期间运行。如果您使用 LXDE 作为桌面,则可以在新行中modprobe i2c-dev
输入。我还没有尝试过其他启动方法,但您可能能够将其添加到X 启动桌面时执行的程序中。您也可以将其放入,但这需要打开终端窗口才能执行它。此外,在 Arch Linux 菜单中,您可以配置然后单击自动启动按钮以添加手动启动的应用程序(这与编辑文件相同)。~/.config/lxsession/LXDE/autostart
@sudo modprobe i2c-dev
.xinitrc
.bashrc
Preferences
Default applications for LXSession
../LXDE/autostart