-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathswayidle.sh
executable file
·66 lines (59 loc) · 1.37 KB
/
swayidle.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env bash
# c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t
# vi: set shiftwidth=4 tabstop=4 noexpandtab:
# :indentSize=4:tabSize=4:noTabs=false:
#
set -o nounset
set -o errexit
set -o pipefail
# shellcheck disable=SC1090
source "$HOME/bin/common.bash"
set -x
###############################################################################
echo "swayidle called as $0 $*"
function _lock() {
#dunstctl set-paused true
makoctl mode -a do-not-disturb
swaylock.sh
}
function _resume() {
swaymsg reload
sleep 1
for display in $(wlr-randr --json | jq -r .[].name)
do
swaymsg "output ${display} dpms on"
if [ $(wlr-randr --json | jq -r ".[] | select(.name == \"${display}\") | .enabled") = false ]
then
sleep 1
wlr-randr --output ${display} --on
fi
done
sleep 1
swaymsg reload
setsbg next
makoctl mode -r do-not-disturb
}
command=${1:-default}
if [ "${command}" = "default" ]
then
/usr/bin/swayidle -d -w -C "$HOME/.config/swayidle/config" 2>&1 | tee --append $HOME/logs/swayidle-$HOSTNAME-$(timestamp).log
elif [ "${command}" = "timeout" ]
then
swaymsg 'output * dpms off'
elif [ "${command}" = "resume" ]
then
_resume
elif [ "${command}" = "lock" ]
then
_lock
elif [ "${command}" = "unlock" ]
then
#dunstctl set-paused false
makoctl mode -r do-not-disturb
elif [ "${command}" = "sleep" ]
then
_lock
elif [ "${command}" = "sleepresume" ]
then
_resume
fi