about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2022-07-31 20:56:47 -0500
committerCase Duckworth2022-07-31 20:56:51 -0500
commit9c1c4ea34cde7ce0573769f42b7fe7f589a25540 (patch)
treec92d0b1601ca53c3aa7c3d3cf68bd1584cb58a49
parentAdd README and Makefile (diff)
downloadautoshart-9c1c4ea34cde7ce0573769f42b7fe7f589a25540.tar.gz
autoshart-9c1c4ea34cde7ce0573769f42b7fe7f589a25540.zip
Shellcheck HEAD main
-rwxr-xr-xautoshart17
1 files changed, 11 insertions, 6 deletions
diff --git a/autoshart b/autoshart index 514e264..a1d265b 100755 --- a/autoshart +++ b/autoshart
@@ -30,6 +30,7 @@ FLAGS:
30 -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. 31 -q Don't print any output.
32EOF 32EOF
33 exit "$1"
33} 34}
34 35
35main() { 36main() {
@@ -43,6 +44,10 @@ main() {
43 k) auto_kill ;; 44 k) auto_kill ;;
44 n) RUN=false ;; 45 n) RUN=false ;;
45 q) QUIET=true ;; 46 q) QUIET=true ;;
47 *)
48 echo >&2 "Unknown option: -$opt"
49 usage 1
50 ;;
46 esac 51 esac
47 done 52 done
48 shift "$((OPTIND - 1))" 53 shift "$((OPTIND - 1))"
@@ -52,7 +57,7 @@ main() {
52## Library functions 57## Library functions
53 58
54auto_kill() { 59auto_kill() {
55 cat "$PID_FILE" | xargs kill 60 xargs kill <"$PID_FILE"
56} 61}
57 62
58auto_start() { ## auto_start FILE 63auto_start() { ## auto_start FILE
@@ -129,7 +134,7 @@ auto_start() { ## auto_start FILE
129 # This is so cursed 134 # This is so cursed
130 quit="$( 135 quit="$(
131 echo "$XDG_CURRENT_DESKTOP" | tr : \\n | 136 echo "$XDG_CURRENT_DESKTOP" | tr : \\n |
132 while read desktop; do 137 while read -r desktop; do
133 case "$onlyshowin;$notshowin" in 138 case "$onlyshowin;$notshowin" in
134 *$desktop*) 139 *$desktop*)
135 if test -n "$onlyshowin"; then 140 if test -n "$onlyshowin"; then
@@ -196,7 +201,7 @@ auto_search() { ## auto_search
196 # ~/.config/autostart/ is more important than /etc/xdg/autostart/ 201 # ~/.config/autostart/ is more important than /etc/xdg/autostart/
197 echo "${XDG_CONFIG_HOME:-$HOME/.config}:${XDG_CONFIG_DIRS:-/etc/xdg}" | tr : \\n | 202 echo "${XDG_CONFIG_HOME:-$HOME/.config}:${XDG_CONFIG_DIRS:-/etc/xdg}" | tr : \\n |
198 sed 's,$,/autostart,' | 203 sed 's,$,/autostart,' |
199 while read dir; do 204 while read -r dir; do
200 if test -d "$dir"; then 205 if test -d "$dir"; then
201 for desktop in "$dir"/*.desktop; do 206 for desktop in "$dir"/*.desktop; do
202 if ! grep -q "$desktop" "$FOUND_FILE"; then 207 if ! grep -q "$desktop" "$FOUND_FILE"; then
@@ -231,9 +236,9 @@ eprint() {
231die() { 236die() {
232 errcode="$1" 237 errcode="$1"
233 shift 238 shift
234 eprint "! $@" 239 eprint "! $*"
235 echo $errcode 240 echo "$errcode"
236 exit $errcode 241 exit "$errcode"
237} 242}
238 243
239## Entry point 244## Entry point