blob: 0be387c66f0966b56458b1adc7611635436c5aa8 (
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
# with openrc use loginctl
[ "$(cat /proc/1/comm)" = "systemd" ] && logind=systemctl || logind=loginctl
command="$1"
system_control() {
if [ "$(loginctl show-session --property=NCurrentSessions --value)" -gt 2 ]; then
notify-send --replace-id=4252 \
"i3exit" "Multiple users are logged in\nCant't $command"
exit
fi
eval "$@"
}
lockWall="$HOME/.local/share/lockWall"
lock_desktop() {
[ -f "$lockWall" ] &&
i3lock --tiling --image="$lockWall" ||
i3lock --color=001177
pkill ssh-agent
}
case "$command" in
lock)
lock_desktop
xset dpms force off
;;
logout)
switch-session
i3-msg exit
;;
switch_user)
dm-tool switch-to-greeter
;;
suspend)
lock_desktop; $logind suspend
;;
hibernate)
system_control lock_desktop && $logind hibernate
;;
reboot)
system_control $logind reboot
;;
shutdown)
system_control $logind poweroff
;;
*)
echo "== ! i3exit: missing or invalid argument ! =="
echo "Try again with: lock | logout | switch_user | suspend | hibernate | reboot | shutdown"
exit 2
esac
exit 0
|