-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwakefull_active.sh
77 lines (44 loc) · 1.44 KB
/
wakefull_active.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
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
#!/usr/bin/env bash
# wakefull_active.sh
# Copyright (C) 2015, John Walsh, all rights reserved.
# called periodically while wakefull.py is turned ON (active)
# it works by:
# simulate a key press
# OR
# find any screen/power saver processes and block/reset them
# ----
# decide on method to use
if [[ $(type -p xdotool) ]]; then
use_xdotool=1
else
use_xdotool=0
fi
# override method
#use_xdotool=0
# ----
if (( $use_xdotool )); then
######################################################################
# simulate a key press
######################################################################
# in general, this should work for all cases
xdotool key F20
# if it doesn't, or causes any problems, then try this:
#xdotool search --name Desktop key F20
# otherwise, don't use xdotool
else
######################################################################
# find any screen/power saver processes and block/reset them
######################################################################
# gnome-screensaver
pgrep -f gnome-screensaver && gnome-screensaver-command --deactivate
# ----
# xscreensaver
pgrep -f xscreensaver && xscreensaver-command -deactivate
# ----
# gnome-power-manager
pgrep -f gnome-power-manager && pkill -f gnome-power-manager; gnome-power-manager &
# ----
# xfce4-power-manager
pgrep -f xfce4-power-manager && xfce4-power-manager --restart
fi
######################################################################