blob: ccb6214d33752c4814f8daaaeb2740e556578a52 (
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
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
|
#!/usr/bin/env bash
#
# the world wide web is a mischievous rat which aims to control you
# this script serves to ration the rat
# it interfaces with my sway and waybar configurations
#
echo -e "\n\
██████╗ █████╗ ████████╗██╗ ██████╗ ███╗ ██╗\n\
██╔══██╗██╔══██╗╚══██╔══╝██║██╔═══██╗████╗ ██║\n\
██████╔╝███████║ ██║ ██║██║ ██║██╔██╗ ██║\n\
██╔══██╗██╔══██║ ██║ ██║██║ ██║██║╚██╗██║\n\
██║ ██║██║ ██║ ██║ ██║╚██████╔╝██║ ╚████║\n\
╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝\n"
SHARE=$HOME/.local/share/rat
if ! [[ -d $SHARE ]]; then
mkdir $SHARE
fi
if ! [[ -f $SHARE/status ]]; then
echo 0 > $SHARE/status
fi
yn_prompt () {
while true; do
read -p "(y/n): " choice
case $choice in
[Yy]) echo y; break ;;
[Nn]) echo n; break ;;
esac
done
}
generate_words () {
echo "$(shuf -n 10 /usr/share/dict/wordle | tr '\n' ' ' | sed -e 's/ $//')"
}
rand_prompt () {
unset response
echo "# $1"
while true; do
read -p "> " response
case $response in
$1) break ;;
*) echo ERR; rand_prompt "$1"; break ;;
esac
done
}
for_duration () {
unset choice duration
words="$(generate_words)"
echo "repeat after me:"
rand_prompt "$words"
while ! [[ "$duration" =~ ^[0-9]+$ ]]; do
echo -n "enter duration in minutes: "
read duration
done
echo "the firewall will close after $duration minutes. is this okay?"
case $(yn_prompt) in
y) nohup rat duration $duration > /dev/null & ;;
n) for_duration ;;
esac
}
for_task () {
words="$(generate_words)"
echo "repeat after me:"
rand_prompt "$words"
while [[ -z "$task" ]]; do
echo "what do you need the rat for?"
read -p "I am going to: " task
done
echo "is that so?"
case $(yn_prompt) in
y) nohup rat task "$task" > /dev/null & ;;
n) for_task ;;
esac
}
for_program () {
nohup rofi -run-command 'rat program {cmd}' -show drun > /dev/null &
}
for_work () {
unset response
echo "you're not just saying that?"
read -p "(I am not): " response
case $response in
"I am not") nohup rat work > /dev/null & ;;
"I am") exit 0 ;;
*) for_work ;;
esac
}
if [[ "$(cat $SHARE/status)" != 0 ]]; then
echo "the rat is loose. would you like to snuff it out?"
if [[ $(yn_prompt) = y ]]; then
nohup rat reset > /dev/null &
fi
exit 0
fi
echo "open the firewall for..."
PS3="selection: "
select choice in "a duration" "a task" "a program" "the work day"; do
case $choice in
"a duration") for_duration
break ;;
"a task") for_task
break ;;
"a program") for_program
break ;;
"the work day") for_work
break ;;
esac
done
|