我试着制作一个脚本,用当前屏幕的屏幕截图,模糊它,并将它设置为i3锁screen.In加法的背景。我想激活10秒的超时时间来关闭锁定的屏幕。我将这个脚本与i3锁的键绑定链接起来,但是10秒超时功能也在没有i3锁的情况下运行,我的屏幕功能在每10秒不活动之后就会下降。
这是我的剧本:
#!/bin/bash
img='ss.png'
scrot "$img"
convert $img -blur 2,5 $img
i3lock -i $img
rm $img
xset dpms 0 0 10 ```发布于 2021-12-13 10:17:51
也许您可以写一些类似的东西,而不是xset行
#!/usr/bin/env bash
img='ss.png'
scrot "$img"
convert "$img" -blur 2,5 "$img"
i3lock -i "$img"
rm -f -- "$img"
has_set_dpms=false
while :; do
if pgrep i3lock >/dev/null; then
if [ "$has_set_dpms" != true ]; then
xset dpms 0 0 10
fi
has_set_dpms=true
else
# Once the process i3lock cannot be found, we turn off DPMS, or
# you can reset it to what it was before
xset -dpms
exit
fi
sleep 5
done本质上,它只是循环,检查i3lock是否开着。如果是(我们刚刚启动它),则执行xset (并使用has_set_dpms变量确保只在while循环中调用xset一次)。
一旦i3lock进程不存在,我们就用xset重置dpms并退出。
我还以为i3lock -i "$img"需要在行的末尾有一个&,但我想不是……
https://stackoverflow.com/questions/70323790
复制相似问题