Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 未检测到系统D和摆动插座_Linux_Desktop_Systemd_Systemctl_Wayland - Fatal编程技术网

Linux 未检测到系统D和摆动插座

Linux 未检测到系统D和摆动插座,linux,desktop,systemd,systemctl,wayland,Linux,Desktop,Systemd,Systemctl,Wayland,我是一个新用户,并且对创建自己的自定义项相当陌生。我以前使用Openbox、feh和systemd每30分钟创建一次带脚本的墙纸更改。下面是一个foo.service,它在Openbox中运行良好: [Unit] Description=wallpaper rotate service RefuseManualStart=no RefuseManualStop=no [Service] Type=oneshot User=trentonknight ExecStart=/bin/sh -c 'D

我是一个新用户,并且对创建自己的自定义项相当陌生。我以前使用Openbox、feh和systemd每30分钟创建一次带脚本的墙纸更改。下面是一个foo.service,它在Openbox中运行良好:

[Unit]
Description=wallpaper rotate service
RefuseManualStart=no
RefuseManualStop=no
[Service]
Type=oneshot
User=trentonknight
ExecStart=/bin/sh -c 'DISPLAY=:0.0 feh --recursive --randomize --bg-fill /home/trentonknight/Pictures/Wallpaper/*'
这是每30分钟运行一次的计时器:

[Unit]
Description=wallpaper rotate timer
RefuseManualStart=no
RefuseManualStop=no

[Timer]
Persistent=false
OnCalendar=*:0/30
Unit=wrotate.service

[Install]
WantedBy=default.target
使用合成器,非常棒。但是,feh仅适用于X。如果没有feh,我可以使用swaywm自带的简单命令轻松更改墙纸:

swaymsg output DP-3 bg foo_background.png
DP-3是在以下情况下运行此命令的结果:

swaymsg -t get_outputs
在bash脚本中使用上面的输出命令,我可以自动为目录中的墙纸随机选择图像。当从命令行运行而没有问题时,此选项有效:

#!/bin/bash
NEW=$(ls ~/Pictures/Wallpaper/ | shuf -n 1)
NEW_SWAY_BACK="~/Pictures/Wallpaper/"$NEW
swaymsg output DP-3 bg $NEW_SWAY_BACK fill
但是,如果我尝试从以下自定义服务调用此bash脚本,它将失败。以下是服务第一:

[Unit]
Description=swaymsg output rotate wallpaper service
RefuseManualStart=no
RefuseManualStop=no

[Service]
WorkingDirectory=/usr/share/backgrounds/sway/
Type=forking
User=trentonknight
ExecStart=/usr/bin/bash sway_backgroud_changer.sh
KillMode=process
这是我尝试过的许多版本之一,但它们在尝试启动后都具有相同的状态:

[trentonknight@archboX system]$ sudo systemctl status swaywallr.service
* swaywallr.service - swaymsg output rotate wallpaper service
   Loaded: loaded (/etc/systemd/system/swaywallr.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Sat 2018-05-12 18:37:17 EDT; 5s ago
  Process: 30491 ExecStart=/usr/bin/bash sway_backgroud_changer.sh (code=exited, status=1/FAILURE)

May 12 18:37:17 archboX systemd[1]: Starting swaymsg output rotate wallpaper service...
May 12 18:37:17 archboX bash[30491]: sway socket not detected.
May 12 18:37:17 archboX bash[30491]: E: 05/12/18 18:37:17 - [ipc-client.c:37] Unable to connect to
May 12 18:37:17 archboX systemd[1]: swaywallr.service: Control process exited, code=exited status=1
May 12 18:37:17 archboX systemd[1]: swaywallr.service: Failed with result 'exit-code'.
May 12 18:37:17 archboX systemd[1]: Failed to start swaymsg output rotate wallpaper service.

    [Install]
    WantedBy=multi-user.target
我看到sweesock如下所示:

[trentonknight@archboX system]$ echo $SWAYSOCK
/run/user/1000/sway-ipc.1000.527.sock
我不知道如何恰当地称呼它。或者即使这就是问题所在?此外,我正在运行以下程序:

[trentonknight@archboX system]$ uname -a
Linux archboX 4.16.8-1-ARCH #1 SMP PREEMPT Wed May 9 11:25:02 UTC 2018 x86_64 GNU/Linux
我也对其他方法持开放态度。我看到有一个sweebg,但运行时给出以下打印输出,手册页根本不包括sweebg:

[trentonknight@archboX sway]$ swaybg
05/12/18 18:43:26 - [main.c:63] Do not run this program manually. See man 5 sway and look for output options.

我的猜测是它仍在开发中。

多亏了#sway on freenode的男男女女,我能够通过简单的使用解决这个问题:

systemctl --user
我没有意识到用户级服务与系统服务是分开的。最后,我的脚本非常基本,运行于:

.config/systemd/user/
我必须附加:

systemctl --user import-environment
到我的.bashrc临时,直到我可以分析丢失的路径。无论如何,如果遇到类似情况,请查看:

如果有人对在sway中自动更换桌面墙纸感兴趣,以下方法应该可以。创建以下目录和文件,并按您认为适合服务的名称命名:

mkdir -p ~/.config/systemd/user
touch ~/.config/systemd/user/foo.service
touch ~/.config/systemd/user/foo.timer
食品服务

[Unit]
Description=swaymsg output rotate wallpaper service

[Service]
ExecStart=/usr/share/backgrounds/sway/sway_backgroud_changer.sh

[Install]
WantedBy=multi-user.target
定时器设置你想要的时间。以下是59分钟

[Unit]
Description=wallpaper rotate timer
RefuseManualStart=no
RefuseManualStop=no

[Timer]
Persistent=false
OnCalendar=*:0/59
Unit=foo.service

[Install]
WantedBy=default.target
用于旋转墙纸的Bash脚本:

[trentonknight@archboX user]$ cat /usr/share/background/sway/sway_backgroud_changer.sh

#!/bin/bash
NEW=$(ls ~/Pictures/Wallpaper/ | shuf -n 1)
NEW_SWAY_BACK="~/Pictures/Wallpaper/"$NEW
swaymsg -s $SWAYSOCK output DP-3 bg $NEW_SWAY_BACK fill
我还没有确定一种更好的方法来确保在运行此服务之前设置路径,至少今晚是这样,所以请将其附加到.bashrc中,或者使用Arch linux教程对其进行改进:

[trentonknight@archboX ~]$ cat .bashrc
systemctl --user import-environment
在下次登录之前运行以启用:

systemctl --user enable foo.timer
如果要在计时器之前进行测试:

systemctl --user start foo.service
最后一件事。请确保在~/Pictures/Wallpaper中或编辑用于加载图像的路径的任何位置都有一些高质量的图像。DP-3是我的输出,请使用:

swaymsg -t get_outputs

多亏了#sway on freenode的男男女女,我能够通过简单地使用systemctl--user来解决这个问题。我没有意识到用户级服务与系统服务是分开的。最后,我的脚本非常基本,可以从.config/systemd/user/运行。我确实需要将systemctl——用户导入环境临时附加到我的.bashrc中,直到我能够分析缺少的路径为止。无论如何,如果遇到类似情况,请查看: