-
Notifications
You must be signed in to change notification settings - Fork 0
/
monitor-lock.sh
executable file
·39 lines (33 loc) · 1022 Bytes
/
monitor-lock.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
#!/bin/bash
# @installable
# screen lock/unlock monitor based on gnome screen saver
MYSELF="$(readlink -f "$0")"
MYDIR="${MYSELF%/*}"
ME=$(basename $MYSELF)
source $MYDIR/env
[[ -f $LOCAL_ENV ]] && source $LOCAL_ENV
source $MYDIR/log.sh
function install() {
log "installing lock screen monitor..."
}
function monitor() {
debug "monitoring lock screen..."
dbus-monitor --session "type='signal',interface='org.gnome.ScreenSaver'" | \
( while true
do read X
debug "received screen saver signal: $X"
if echo $X | grep "boolean true" &> /dev/null; then
debug "screen locked"
$MYDIR/rr-pause.sh || $MYDIR/play.sh --pause
elif echo $X | grep "boolean false" &> /dev/null; then
debug "unlocked screen..."
#$MYDIR/rr-play.sh || $MYDIR/play.sh || true
$MYDIR/notify.sh "task was automatically paused on screen lock!"
fi
done )
}
function disabled() {
debug "script disabled"
}
trap 'disabled' EXIT
monitor