~mdkcore/dotbins

dotbins/power -rwxr-xr-x 653 bytes
2559c86bRodrigo Oliveira [power] Use loginctl instead of pm-* 1 year, 9 months ago
                                                                                
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
#!/bin/sh

action=${1:-hybrid}
delay=3

subcommand="hybrid-sleep"
case $action in
    hybrid)
        ;;
    suspend)
        subcommand="suspend"
        ;;
    hibernate)
        subcommand="hibernate"
        ;;
    lock-only)
        subcommand=''
        ;;
    *)
        echo "action '$action' not recognized; just locking and clearing"
        subcommand=''
        ;;
esac

for pid in $(pgrep Xorg)
do
    display=$(ps -o command= -p "$pid"| awk '{print $2}')
done
DISPLAY=$display xlock -mode blank&

# clear cached gpg password
echo RELOADAGENT | gpg-connect-agent

if [ -n "$subcommand" ]
then
    sleep $delay
    loginctl "$subcommand"
fi