-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththrottle
More file actions
executable file
·44 lines (38 loc) · 841 Bytes
/
throttle
File metadata and controls
executable file
·44 lines (38 loc) · 841 Bytes
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
#!/bin/bash
pid=$(xdotool search --onlyvisible --class firefox getwindowpid)
function do_throttle
{
sleep 3
echo "STOP $pid"
kill -STOP $pid
}
function do_unthrottle
{
echo "CONT $pid"
kill -CONT $pid
}
throttled=0
while true; do
activepid=$(xdotool getactivewindow getwindowpid)
if [ "$activepid" = "$pid" ]; then
if [ $throttled = 1 ]; then
do_unthrottle
throttled=0
fi
elif [ $throttled = 0 ]; then
do_throttle
throttled=1
fi
if [ $throttled = 1 ]; then
for i in $(seq 1 100); do
sleep 0.1
activepid=$(xdotool getactivewindow getwindowpid)
if [ "$activepid" = "$pid" ]; then
break;
fi
done
do_unthrottle
throttled=0
fi
sleep 1
done