aboutsummaryrefslogtreecommitdiff
path: root/wmutils/bin/deletelock.sh
blob: ed9e5530a16f5e3f8281ac8715d1106f2c7f24d9 (plain)
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
#!/bin/sh
#
# wildefyr - 2015 (c) wtfpl
# toggle delete lock for current window

usage() {
    echo "usage: $(basename $0) <lock|unlock|toggle|status> <wid>"
    exit 1
}

wid=$(pfw)

case $2 in
    0x*)
        wid=$2
        ;;
    *)
        usage
        ;;
esac

case $1 in
    lock)
        xprop -id $wid -f _WMUTILS_DELETELOCK 8i -set _WMUTILS_DELETELOCK '1'
        ;;
    unlock)
        xprop -id $wid -remove _WMUTILS_DELETELOCK
        ;;
    toggle)
        lockStatus=$(xprop -id $wid _WMUTILS_DELETELOCK | cut -d\  -f 3)
        case $lockStatus in
            1)
                $(basename $0) unlock $wid 
                ;;
            *)
                $(basename $0) lock $wid 
                ;;
        esac
        ;;
    status)
        lockStatus=$(xprop -id $wid _WMUTILS_DELETELOCK | cut -d\  -f 3)
        case $lockStatus in
            1)
                echo "1"
                ;;
            *)
                echo "0"
                ;;
        esac
        ;;
    *)
        usage
        ;;
esac