[Share Experiences] 登录锁屏古诗词,每次开机触发刷新
Tofloor
poster avatar
yicold
deepin product team
2023-10-20 22:37
Author

截图_dde-desktop_20231018094343.png

效果如上,只需两步:1、配置脚本;2、开机触发;

脚本内容如下,我这边放在路径:/home/cold/Documents/,注意与开机触发的desktop文件配置一致。

#!/bin/bash  
 
showTopTip=$(dde-dconfig --get -a org.deepin.dde.lock -r org.deepin.dde.lock -k showTopTip)
echo $showTopTip

if [ "$showTopTip" = 'false' ]; then
    dde-dconfig --set -a org.deepin.dde.lock -r org.deepin.dde.lock -k showTopTip -v true
    dde-dconfig --set -a org.deepin.dde.lightdm-deepin-greeter -r org.deepin.dde.lightdm-deepin-greeter -k showTopTip -v true
fi

topTipTextFont=$(dde-dconfig --get -a org.deepin.dde.lock -r org.deepin.dde.lock -k topTipTextFont)
echo $topTipTextFont

if [ $topTipTextFont -ne 10 ]; then
    dde-dconfig --set -a org.deepin.dde.lock -r org.deepin.dde.lock -k topTipTextFont -v 10
    dde-dconfig --set -a org.deepin.dde.lightdm-deepin-greeter -r org.deepin.dde.lightdm-deepin-greeter -k topTipTextFont -v 10
fi

tokenfile=~/.config/tokenfile/config
if [ -e "$tokenfile" ]; then
    echo "文件存在"
else
    mkdir ~/.config/tokenfile/
    touch $tokenfile
fi

token=$(cat $tokenfile)
echo $token

if [ -z "$token" ]; then
    echo "token为空"
    curl -X GET -H 'Accept: application/json' https://v2.jinrishici.com/token | jq -r '.data' > "$tokenfile"
    token=$(cat $tokenfile)
    echo $token
else
    echo "token存在"
fi

#token=$(cat $tokenfile)
shici=$(curl -X GET -H 'Accept: application/json' -H "X-User-Token: $token" https://v2.jinrishici.com/sentence | jq -r '.data.content')
dde-dconfig --set -a org.deepin.dde.lock -r org.deepin.dde.lock -k topTipText -v $shici
dde-dconfig --set -a org.deepin.dde.lightdm-deepin-greeter -r org.deepin.dde.lightdm-deepin-greeter -k topTipText -v $shici

开机触发的desktop文件如下,需要放入用户自启目录中:~/.config/autostart

[Desktop Entry]
Encoding=UTF-8
Type=Application
#应用名称
Name=SHICHI
#图标路径
Icon=deepin-image-viewer
#启动是否开启终端
Terminal=false
#文件路径
Exec=/home/cold/Documents/jinrishici.sh %U
StartupNotify=true
X-Deepin-CreatedBy=com.deepin.SessionManager
X-Deepin-AppID=SHICI
Hidden=false
Reply Favorite View the author
All Replies
2 / 2
To page
晚秋(lateautumn)
Moderator
2023-10-30 22:56
#21

学习了,1级坛神applaud

Reply View the author
2 / 2
To page