我写了一个脚本来自动更改我的电脑主题。该脚本在终端中运行没有任何问题,但当我将其放入 cron 中时,我收到此错误
dconf-WARNING **: 02:52:01.932: failed to commit changes to dconf: Conncetion closed
我该如何解决这个问题?我花了几个小时在谷歌上搜索,但没有结果。
这是我的脚本:
AutoThemeSwithcer.sh
#!/bin/bash
CurrenTime="$(date +%H)"
NIGHT_TIME=7
DAY_TIME=8
DAY_THEME="Sierra-light"
NIGHT_THEME="Sierra-dark"
USER=robin994
NIGHT_IMAGE_PATH="/home/$USER/Immagini/mojave-night.jpg"
DAY_IMAGE_PATH="/home/$USER/Immagini/mojave-day.jpg"
CT=$(( 10#$CurrenTime-12 ))
if [ $CT -ge 0 ]
then
if [ $CT -ge $NIGHT_TIME ]
then
gsettings set org.gnome.desktop.interface gtk-theme "$NIGHT_THEME"
gsettings set org.gnome.desktop.interface gtk-theme "$NIGHT_THEME"
gsettings set org.gnome.shell.extensions.user-theme name "$NIGHT_THEME"
gsettings set org.gnome.desktop.background picture-uri "file://$NIGHT_IMAGE_PATH"
else
gsettings set org.gnome.desktop.interface gtk-theme "$DAY_THEME"
gsettings set org.gnome.desktop.interface gtk-theme "$DAY_THEME"
gsettings set org.gnome.shell.extensions.user-theme name "$DAY_THEME"
gsettings set org.gnome.desktop.background picture-uri "file://$DAY_IMAGE_PATH"
fi
elif [ $(( $CT + 12 )) -ge $DAY_TIME ]
then
gsettings set org.gnome.desktop.interface gtk-theme "$DAY_THEME"
gsettings set org.gnome.desktop.interface gtk-theme "$DAY_THEME"
gsettings set org.gnome.shell.extensions.user-theme name "$DAY_THEME"
gsettings set org.gnome.desktop.background picture-uri "file://$DAY_IMAGE_PATH"
else
gsettings set org.gnome.desktop.interface gtk-theme "$NIGHT_THEME"
gsettings set org.gnome.desktop.interface gtk-theme "$NIGHT_THEME"
gsettings set org.gnome.shell.extensions.user-theme name "$NIGHT_THEME"
gsettings set org.gnome.desktop.background picture-uri "file://$NIGHT_IMAGE_PATH"
fi
这是我的 cron 文件:
克罗恩
#Borrowed from anacron
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/home/robin99$
#End borrowed from anacron
DISPLAY=:0
XAUTHORITY=/home/robin994/.Xauthority
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-qQv0mtFe42,guid=f0a53dfd4343da$
DBUS_SESSION_BUS_PID=14893
* * * * * bash -x AutoThemeSwitcher.sh > /home/robin994/bin/auto3.log 2$
日志档案
++ date +%H
+ CurrenTime=02
+ NIGHT_TIME=7
+ DAY_TIME=8
+ DAY_THEME=Sierra-light
+ NIGHT_THEME=Sierra-dark
+ NIGHT_IMAGE_PATH=/home//Immagini/mojave-night.jpg
+ DAY_IMAGE_PATH=/home//Immagini/mojave-day.jpg
+ CT=-10
+ '[' -10 -ge 0 ']'
+ '[' 2 -ge 8 ']'
+ gsettings set org.gnome.desktop.interface gtk-theme Sierra-dark
(process:19539): dconf-WARNING **: 02:52:01.918: failed to commit changes to dconf: La connessione è chiusa
+ gsettings set org.gnome.desktop.interface gtk-theme Sierra-dark
(process:19543): dconf-WARNING **: 02:52:01.923: failed to commit changes to dconf: La connessione è chiusa
+ gsettings set org.gnome.shell.extensions.user-theme name Sierra-dark
(process:19547): dconf-WARNING **: 02:52:01.927: failed to commit changes to dconf: La connessione è chiusa
+ gsettings set org.gnome.desktop.background picture-uri file:///home//Immagini/mojave-night.jpg
(process:19551): dconf-WARNING **: 02:52:01.932: failed to commit changes to dconf: La connessione è chiusa