diff options
author | Case Duckworth | 2022-07-29 15:01:01 -0500 |
---|---|---|
committer | Case Duckworth | 2022-07-29 15:01:01 -0500 |
commit | c5fc2f5876ca10250079d51a63a54112d1c661c6 (patch) | |
tree | aabfab567b84227ee5604adbeb50e008c7c07655 | |
parent | Initial commit (diff) | |
download | autoshart-c5fc2f5876ca10250079d51a63a54112d1c661c6.tar.gz autoshart-c5fc2f5876ca10250079d51a63a54112d1c661c6.zip |
Add caveat emptor
-rwxr-xr-x | autoshart.sh | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/autoshart.sh b/autoshart.sh index 4868846..9e9a1a7 100755 --- a/autoshart.sh +++ b/autoshart.sh | |||
@@ -5,6 +5,9 @@ | |||
5 | # | 5 | # |
6 | # Commentary: | 6 | # Commentary: |
7 | # | 7 | # |
8 | # An autostart script. Called "autoshart" because I literally sharted it out, | ||
9 | # and have /not/ tested it at all. So, caveat emptor, I guess. | ||
10 | # | ||
8 | # Freedesktop autostart specification: | 11 | # Freedesktop autostart specification: |
9 | # https://specifications.freedesktop.org/autostart-spec/latest/ | 12 | # https://specifications.freedesktop.org/autostart-spec/latest/ |
10 | # Freedesktop desktop entry specification: | 13 | # Freedesktop desktop entry specification: |
@@ -19,12 +22,13 @@ usage() { | |||
19 | cat <<EOF | 22 | cat <<EOF |
20 | AUTOSHART: autostart without the shit | 23 | AUTOSHART: autostart without the shit |
21 | USAGE: autoshart -h | 24 | USAGE: autoshart -h |
22 | autoshart [-k] [-n] | 25 | autoshart [-k] [-n] [-q] |
23 | 26 | ||
24 | FLAGS: | 27 | FLAGS: |
25 | -h Show this help and exit. | 28 | -h Show this help and exit. |
26 | -k Kill all processes started by autoshart and exit. | 29 | -k Kill all processes started by autoshart and exit. |
27 | -n Only print what would happen; don't execute anything. | 30 | -n Only print what would happen; don't execute anything. |
31 | -q Don't print any output. | ||
28 | EOF | 32 | EOF |
29 | } | 33 | } |
30 | 34 | ||
@@ -45,6 +49,8 @@ main() { | |||
45 | auto_search | 49 | auto_search |
46 | } | 50 | } |
47 | 51 | ||
52 | ## Library functions | ||
53 | |||
48 | auto_kill() { | 54 | auto_kill() { |
49 | cat "$PID_FILE" | xargs kill | 55 | cat "$PID_FILE" | xargs kill |
50 | } | 56 | } |
@@ -193,9 +199,13 @@ auto_search() { ## auto_search | |||
193 | while read dir; do | 199 | while read dir; do |
194 | if test -d "$dir"; then | 200 | if test -d "$dir"; then |
195 | for desktop in "$dir"/*.desktop; do | 201 | for desktop in "$dir"/*.desktop; do |
196 | if ! grep "$desktop" "$FOUND_FILE"; then | 202 | if ! grep -q "$desktop" "$FOUND_FILE"; then |
197 | auto_start "$desktop" && | 203 | auto_start "$desktop" && |
198 | print "$desktop" >>"$FOUND_FILE" | 204 | # `echo' here is |
205 | # important; it /needs/ | ||
206 | # to be output to the | ||
207 | # $FOUND_FILE | ||
208 | echo "$desktop" >>"$FOUND_FILE" | ||
199 | else | 209 | else |
200 | eprint "Already executed: $desktop" | 210 | eprint "Already executed: $desktop" |
201 | fi | 211 | fi |
@@ -204,7 +214,7 @@ auto_search() { ## auto_search | |||
204 | done | 214 | done |
205 | } | 215 | } |
206 | 216 | ||
207 | #################################### | 217 | ## Convenience functions |
208 | 218 | ||
209 | get() { # get KEY FILE | 219 | get() { # get KEY FILE |
210 | grep "^$1" "${2:-}" 2>/dev/null | cut -d= -f2- | 220 | grep "^$1" "${2:-}" 2>/dev/null | cut -d= -f2- |
@@ -226,6 +236,7 @@ die() { | |||
226 | exit $errcode | 236 | exit $errcode |
227 | } | 237 | } |
228 | 238 | ||
229 | #################################### | 239 | ## Entry point |
230 | 240 | ||
241 | test "$DEBUG" && set -x | ||
231 | main "$@" | 242 | main "$@" |