diff options
author | Case Duckworth | 2022-07-31 20:56:47 -0500 |
---|---|---|
committer | Case Duckworth | 2022-07-31 20:56:51 -0500 |
commit | 9c1c4ea34cde7ce0573769f42b7fe7f589a25540 (patch) | |
tree | c92d0b1601ca53c3aa7c3d3cf68bd1584cb58a49 | |
parent | Add README and Makefile (diff) | |
download | autoshart-main.tar.gz autoshart-main.zip |
-rwxr-xr-x | autoshart | 17 |
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. |
32 | EOF | 32 | EOF |
33 | exit "$1" | ||
33 | } | 34 | } |
34 | 35 | ||
35 | main() { | 36 | main() { |
@@ -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 | ||
54 | auto_kill() { | 59 | auto_kill() { |
55 | cat "$PID_FILE" | xargs kill | 60 | xargs kill <"$PID_FILE" |
56 | } | 61 | } |
57 | 62 | ||
58 | auto_start() { ## auto_start FILE | 63 | auto_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() { | |||
231 | die() { | 236 | die() { |
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 |