-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpower-mgm
executable file
·131 lines (121 loc) · 2.3 KB
/
power-mgm
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
set -x
modes="suspend\nhibernate\nreboot\nshutdown"
action=
dir=$(pwd)
user=$USER
show_menu=
get_var=
color=
image=
for param in $@; do
case $get_var in
action)
case $param in
menu)
show_menu=1
;;
*)
action=$param
;;
esac
;;
user)
user=$param
;;
dir)
dir=$param
;;
color)
color="--color $param"
;;
image)
image="--image $param"
;;
*)
;;
esac
get_var=
case $param in
-a)
get_var=action
;;
--action)
get_var=action
;;
-u)
get_var=user
;;
--user)
get_var=user
;;
-d)
get_var=dir
;;
--dir)
get_var=dir
;;
-c)
get_var=color
;;
--color)
get_var=color
;;
-i)
get_var=image
;;
--image)
get_var=image
;;
*)
esac
done
case $action in
hibernate)
sudo -u $user i3lock -t $color $image &
sleep 1
sudo swapon /swapfile-hibernate
sudo s2disk > /dev/zero
sudo swapoff /swapfile-hibernate &
;;
suspend)
sudo -u $user i3lock -t $color $image &
sleep 1
sudo s2ram > /dev/zero
;;
reboot)
sudo shutdown -r now
;;
shutdown)
sudo shutdown now
;;
*)
;;
esac
case $BLOCK_BUTTON in
1)
show_menu=1
;;
2)
;;
3)
;;
4)
;;
5)
;;
6)
;;
7)
;;
*)
;;
esac
if [[ -n $show_menu ]]; then
selected=$(echo -e $modes | dmenu -i)
if [[ -n $selected ]]; then
#sudo ~/.config/i3/i3tools/power-mgm --dir ~/.config/i3/i3tools --user $user --action $selected
sudo ~/.config/i3/i3tools/power-mgm --user $user --action $selected $color $image
fi
fi
#echo "{\"dir\":\"$dir\",\"user\":\"$user\",\"action\":\"$action\",\"selected\":\"$selected\"}" > ~/power.log