about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2022-07-29 15:01:01 -0500
committerCase Duckworth2022-07-29 15:01:01 -0500
commitc5fc2f5876ca10250079d51a63a54112d1c661c6 (patch)
treeaabfab567b84227ee5604adbeb50e008c7c07655
parentInitial commit (diff)
downloadautoshart-c5fc2f5876ca10250079d51a63a54112d1c661c6.tar.gz
autoshart-c5fc2f5876ca10250079d51a63a54112d1c661c6.zip
Add caveat emptor
-rwxr-xr-xautoshart.sh21
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
20AUTOSHART: autostart without the shit 23AUTOSHART: autostart without the shit
21USAGE: autoshart -h 24USAGE: autoshart -h
22 autoshart [-k] [-n] 25 autoshart [-k] [-n] [-q]
23 26
24FLAGS: 27FLAGS:
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.
28EOF 32EOF
29} 33}
30 34
@@ -45,6 +49,8 @@ main() {
45 auto_search 49 auto_search
46} 50}
47 51
52## Library functions
53
48auto_kill() { 54auto_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
209get() { # get KEY FILE 219get() { # 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
241test "$DEBUG" && set -x
231main "$@" 242main "$@"