我一直在关注教程如何在 Ubuntu 20.04 Focal Fossa 服务器/桌面上启动时运行脚本尝试在启动时运行某些操作:
我完全按照他们的要求做了所有事情,但脚本仍然无法运行。我添加了一个声音以确保它不会在我看不到的时候运行,但它就是无法运行。我不知道发生了什么。以下是服务的代码及其运行的脚本:
openup.sh
#!/bin/bash
play /home/synthetichuman/Downloads/br2rotr/2a1d14277eb3aacfcda04a0b57d78cc4.wav
gsettings set org.gnome.desktop.background picture-uri "file:///home/synthetichuman/Pictures/1.jpg" & sleep 0.5
gsettings set org.gnome.desktop.background picture-uri "file:///home/synthetichuman/Pictures/2.jpg" & sleep 0.5
gsettings set org.gnome.desktop.background picture-uri "file:///home/synthetichuman/Pictures/3.jpg" & sleep 0.5
gsettings set org.gnome.desktop.background picture-uri "file:///home/synthetichuman/Pictures/4.jpg" & sleep 0.5
gsettings set org.gnome.desktop.background picture-uri "file:///home/synthetichuman/Pictures/5.jpg" & sleep 0.5
gsettings set org.gnome.desktop.background picture-uri "file:///home/synthetichuman/Pictures/6.jpg" & sleep 0.5
gsettings set org.gnome.desktop.background picture-uri "file:///home/synthetichuman/Pictures/7.jpg" & sleep 0.5
openup.service
[Unit]
After=network.service
[Service]
ExecStart=/usr/local/bin/openup.sh
[Install]
WantedBy=default.target
编辑:事实证明,我一直做错了。不过,我已经弄清楚了。
答案1
事实证明,我一直都做错了。为了在 Gnome shell 启动时运行脚本,请使用命令gnome-session-properties
并向其中添加 .sh 脚本。