Skip to content

Commit 3f94c2f

Browse files
committed
^C to menu!
1 parent 0eb494f commit 3f94c2f

File tree

13 files changed

+205
-234
lines changed

13 files changed

+205
-234
lines changed

AGENTS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,7 @@ The Bash Screensavers project is a collection of fun screensavers written entire
5959
* Bash v3.2 or higher
6060
* All screensavers must gracefully handle ^C to clean up the terminal and exit
6161
* All shell scripts must have execute permission (chmod +x *.sh)
62+
63+
# Style
64+
65+
* Indents are 2 spaces. No Tabs.

gallery/alpha/alpha.sh

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@
55

66
SLEEPY_TIME="0.30" # Number of seconds of sleepy time between alpha-ness
77

8-
trap _stop SIGINT # Trap CONTROL-C
8+
_cleanup_and_exit() { # handler for SIGINT (Ctrl‑C)
9+
tput cnorm # show the cursor again
10+
printf '\e[0m\n' # reset colours and move to a new line
11+
exit 0
12+
}
13+
14+
trap _cleanup_and_exit SIGINT # Ctrl‑C
915

1016
_color() {
1117
printf '\e[38;5;%dm' $((RANDOM % 256))
@@ -15,15 +21,7 @@ _location() {
1521
tput cup $(($RANDOM%$(tput lines))) $(($RANDOM%$(tput cols)))
1622
}
1723

18-
_stop() {
19-
tput cnorm # yes cursor
20-
printf '\e[0m'
21-
printf '\n'
22-
exit 0
23-
}
24-
2524
clear
26-
2725
tput civis # no cursor
2826

2927
while true; do

gallery/bouncing/bouncing.sh

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,21 @@
44
# BOUNCING - A simple bouncing objects screensaver
55
#~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
66

7-
trap cleanup SIGINT # Trap CONTROL-C
8-
97
# --- Configuration ---
108
RESET=$'\e[0m'
119
COLORS=($'\e[31m' $'\e[32m' $'\e[33m' $'\e[34m' $'\e[35m' $'\e[36m')
1210
OBJECT_CHAR="O"
1311
NUM_OBJECTS=5
1412
SLEEP_TIME=0.05
1513

16-
# --- Functions ---
17-
18-
#
19-
# Cleanup function to restore the terminal
20-
#
21-
cleanup() {
22-
tput cnorm # Restore cursor
23-
printf '%s' "$RESET"
24-
printf '\n'
25-
exit 0
14+
_cleanup_and_exit() { # handler for SIGINT (Ctrl‑C)
15+
tput cnorm # show the cursor again
16+
printf '\e[0m\n' # reset colours and move to a new line
17+
exit 0
2618
}
2719

20+
trap _cleanup_and_exit SIGINT # Ctrl‑C
21+
2822
#
2923
# Main animation loop
3024
#

gallery/cutesaver/art/1.art

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
' '. ' --.'
1717
/ ' `'--' ,. |
1818
/ | .' /
19-
__________________________________________________________mx
19+
____________________________________________________________
2020

2121

2222

gallery/cutesaver/art/11.art

Lines changed: 55 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,55 @@
1-
.--.
2-
`. \
3-
\ \
4-
. \
5-
: .
6-
| .
7-
| :
8-
| |
9-
..._ ___ | |
10-
`."".`''''""--..___ | |
11-
,-\ \ ""-...__ _____________/ |
12-
/ ` " ' `"""""""" .
13-
\ L
14-
(> \
15-
/ \
16-
\_ ___..---. L
17-
`--' '. \
18-
. \_
19-
_/`. `.._
20-
.' -. `.
21-
/ __.-Y /''''''-...___,...--------.._ |
22-
/ _." | / ' . \ '---..._ |
23-
/ / / / _,. ' ,/ | |
24-
\_,' _.' / /'' _,-' _| |
25-
' / `-----'' / |
26-
`...-' dp `...-'
1+
2+
3+
do.
4+
:NOX
5+
,NOM@:
6+
:NNNN:
7+
:XXXON
8+
:XoXXX.
9+
MM;ONO:
10+
.oob.. :MMO;MOM
11+
dXOXYYNNb. ,NNMX:MXN
12+
Mo"' '':Nbb dNMMN MNN:
13+
Mo 'O;; ':Mb. ,MXMNM MNX:
14+
@O :;XXMN..'X@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utesaver/art/2.art

Lines changed: 26 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,26 @@
1-
2-
3-
do.
4-
:NOX
5-
,NOM@:
6-
:NNNN:
7-
:XXXON
8-
:XoXXX.
9-
MM;ONO:
10-
.oob.. :MMO;MOM
11-
dXOXYYNNb. ,NNMX:MXN
12-
Mo"' '':Nbb dNMMN MNN:
13-
Mo 'O;; ':Mb. ,MXMNM MNX:
14-
@O :;XXMN..'X@b. ,NXOMXM MNX:
15-
YX;;NMMMM@M;;OM@o. dXOOMMN:MNX:
16-
'MOONM@@@MMN:':NONb. ,dXONM@@MbMXX:
17-
MOON@M@@MMMM;;:OOONb ,MX'"':ONMMMMX:
18-
:NOOM@@MNNN@@X;""XNN@Mb .dP"' ,..OXM@N:
19-
MOON@@MMNXXMMO :M@@[email protected]""":OOOXNNXXOo:
20-
:NOX@@@MNXXXMNo :MMMM@K"`,:;NNM@@NXM@MNO;.'N.
21-
NO:X@@MNXXX@@O:'X@@@@MOOOXMM@M@NXXN@M@NOO ''b
22-
`MO.'NMNXXN@@N: 'XXM@NMMXXMM@M@XO"'"XM@X;. :b
23-
YNO;'"NXXXX@M;;::"XMNN:""ON@@MO: ,;;.:Y@X: :OX.
24-
Y@Mb;;XNMM@@@NO: ':O: 'OXN@@MO" ONMMX:`XO; :X@.
25-
'@XMX':OX@@MN: ;O; :OX@MO" 'OMM@N; ':OO;N@N
26-
YN;":.:OXMX"': ,:NNO;';XMMX: ,;@@MNN.'.:O;:@X:
27-
`@N;;XOOOXO;;:O;:@MOO;:O:"" ,oMP@@K"YM.;NMO;`NM
28-
`@@MN@MOX@@MNMN;@@MNXXOO: ,d@NbMMP'd@@OX@NO;.'bb.
29-
.odMX@@XOOM@M@@XO@MMMMMMNNbN"YNNNXoNMNMO"OXXNO.."";o.
30-
.ddMNOO@@XOOM@@XOONMMM@@MNXXMMo;."' .":OXO ':.'"'"' '""o.
31-
'N@@X;,M@MXOOM@OOON@MM@MXOO:":ON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OOOOOOXNMMNNNMNP ""MNNM@@@MMMM@MP
49-
@@@XOOO':::OOXXMNOO@@OOOOXNN@NNNNNNNN '`YMM@@@MMM@P'
50-
MM@@M:'''' O:":ONOO@MNOOOOXM@NM@NNN@P -hrr- "`"""MM'
51-
''MM@: "' 'OOONMOYOOOOO@MM@MNNM"
52-
YM@' :OOMN: :OOOO@MMNOXM'
53-
`:P :oP'' "'OOM@NXNM'
54-
`' ':OXNP'
55-
'"'
1+
.--.
2+
`. \
3+
\ \
4+
. \
5+
: .
6+
| .
7+
| :
8+
| |
9+
..._ ___ | |
10+
`."".`''''""--..___ | |
11+
,-\ \ ""-...__ _____________/ |
12+
/ ` " ' `"""""""" .
13+
\ L
14+
(> \
15+
/ \
16+
\_ ___..---. L
17+
`--' '. \
18+
. \_
19+
_/`. `.._
20+
.' -. `.
21+
/ __.-Y /''''''-...___,...--------.._ |
22+
/ _." | / ' . \ '---..._ |
23+
/ / / / _,. ' ,/ | |
24+
\_,' _.' / /'' _,-' _| |
25+
' / `-----'' / |
26+
`...-' `...-'

gallery/cutesaver/rollthecute.sh

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,14 @@
33
# This file reads from 12 art files and then loops.
44
# Each is displayed for 10 seconds.
55

6-
trap cleanup SIGINT # Trap CONTROL-C
7-
8-
# --- Functions ---
9-
10-
#
11-
# Cleanup function to restore the terminal
12-
#
13-
cleanup() {
14-
tput cnorm # Restore cursor
15-
printf '\e[0m'
16-
printf '\n'
17-
exit 0
6+
_cleanup_and_exit() { # handler for SIGINT (Ctrl‑C)
7+
tput cnorm # show the cursor again
8+
printf '\e[0m\n' # reset colours and move to a new line
9+
exit 1 # exit with error, so main menu knows what happened!
1810
}
1911

12+
trap _cleanup_and_exit SIGINT # Ctrl‑C
13+
2014
#
2115
# Main animation loop
2216
#

gallery/fireworks/fireworks.sh

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,20 @@
44
# FIREWORKS - A simple fireworks display
55
#~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
66

7-
trap cleanup SIGINT # Trap CONTROL-C
8-
97
# --- Configuration ---
108
RESET=$'\e[0m'
119
COLORS=($'\e[31m' $'\e[32m' $'\e[33m' $'\e[34m' $'\e[35m' $'\e[36m' $'\e[91m' $'\e[92m' $'\e[93m' $'\e[94m' $'\e[95m' $'\e[96m')
1210
ROCKET_CHARS=("." "^" "+")
1311
EXPLOSION_CHARS=("*" "+" ".")
1412

15-
# --- Functions ---
16-
17-
#
18-
# Cleanup function to restore the terminal
19-
#
20-
cleanup() {
21-
tput cnorm # Restore cursor
22-
printf '%s' "$RESET"
23-
printf '\n'
24-
exit 0
13+
_cleanup_and_exit() { # handler for SIGINT (Ctrl‑C)
14+
tput cnorm # show the cursor again
15+
printf '\e[0m\n' # reset colours and move to a new line
16+
exit 1 # exit with error, so main menu knows what happened!
2517
}
2618

19+
trap _cleanup_and_exit SIGINT # Ctrl‑C
20+
2721
#
2822
# Main animation loop
2923
#

gallery/matrix/matrix.sh

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
# MATRIX - A simple matrix-style screensaver
55
#~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
66

7-
trap cleanup SIGINT # Trap CONTROL-C
8-
97
# --- Configuration ---
108
# Set the colors
119
GREEN=$'\e[32m'
@@ -18,18 +16,14 @@ CHARS="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&*()"
1816
# The length of the character streams
1917
STREAM_LEN=15
2018

21-
# --- Functions ---
22-
23-
#
24-
# Cleanup function to restore the terminal
25-
#
26-
cleanup() {
27-
tput cnorm # Restore cursor
28-
printf '%s' "$RESET"
29-
printf '\n'
30-
exit 0
19+
_cleanup_and_exit() { # handler for SIGINT (Ctrl‑C)
20+
tput cnorm # show the cursor again
21+
printf '\e[0m\n' # reset colours and move to a new line
22+
exit 1 # exit with error, so main menu knows what happened!
3123
}
3224

25+
trap _cleanup_and_exit SIGINT # Ctrl‑C
26+
3327
#
3428
# Main animation loop
3529
#

gallery/rain/rain.sh

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
# RAIN - A simple rain-style screensaver
55
#~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
66

7-
trap cleanup SIGINT # Trap CONTROL-C
8-
97
# --- Configuration ---
108
# Set the colors
119
BLUE=$'\e[34m'
@@ -15,18 +13,14 @@ RESET=$'\e[0m'
1513
# The characters for the raindrops
1614
DROPS=("|" "." "'")
1715

18-
# --- Functions ---
19-
20-
#
21-
# Cleanup function to restore the terminal
22-
#
23-
cleanup() {
24-
tput cnorm # Restore cursor
25-
printf '%s' "$RESET"
26-
printf '\n'
27-
exit 0
16+
_cleanup_and_exit() { # handler for SIGINT (Ctrl‑C)
17+
tput cnorm # show the cursor again
18+
printf '\e[0m\n' # reset colours and move to a new line
19+
exit 0
2820
}
2921

22+
trap _cleanup_and_exit SIGINT # Ctrl‑C
23+
3024
#
3125
# Main animation loop
3226
#

0 commit comments

Comments
 (0)