diff options
author | Andrew Cady <d@jerkface.net> | 2018-01-04 21:22:33 -0500 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2018-01-04 21:22:33 -0500 |
commit | 5148ebc85dc3e663eee3fc8156fa8589cf899acc (patch) | |
tree | 927cd6b0a95a914aa9edfeb3628ecb200dd5557a /dot/local/bin/dbus-autolaunch | |
parent | 1cf925c91f27cca67cb641a602d98599a4228639 (diff) |
new command: dbus-autolaunch
Diffstat (limited to 'dot/local/bin/dbus-autolaunch')
-rwxr-xr-x | dot/local/bin/dbus-autolaunch | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/dot/local/bin/dbus-autolaunch b/dot/local/bin/dbus-autolaunch new file mode 100755 index 0000000..6cc8653 --- /dev/null +++ b/dot/local/bin/dbus-autolaunch | |||
@@ -0,0 +1,45 @@ | |||
1 | #!/bin/sh | ||
2 | DOUBLE_CHECK=y | ||
3 | SESSION_FILE=$HOME/.dbus/default_session | ||
4 | |||
5 | if [ "$*" ]; then | ||
6 | eval "$("$0")" | ||
7 | "$@" | ||
8 | exit | ||
9 | fi | ||
10 | |||
11 | dbus_available() | ||
12 | { | ||
13 | dbus-send \ | ||
14 | --session \ | ||
15 | --dest=org.freedesktop.DBus \ | ||
16 | --type=method_call \ | ||
17 | /org/freedesktop/DBus \ | ||
18 | org.freedesktop.DBus.ListNames >/dev/null 2>&1 | ||
19 | } | ||
20 | |||
21 | dbus_available && exit | ||
22 | |||
23 | if [ -r "$SESSION_FILE" ]; then | ||
24 | |||
25 | . "$SESSION_FILE" | ||
26 | |||
27 | if dbus_available; then | ||
28 | cat "$SESSION_FILE" | ||
29 | exit | ||
30 | fi | ||
31 | |||
32 | fi | ||
33 | |||
34 | mkdir -p "$HOME"/.dbus | ||
35 | dbus-launch --sh-syntax > "$SESSION_FILE".$$ || exit | ||
36 | mv "$SESSION_FILE".$$ "$SESSION_FILE" || exit | ||
37 | |||
38 | if [ "$DOUBLE_CHECK" ]; then | ||
39 | |||
40 | . "$SESSION_FILE" | ||
41 | dbus_available || exit | ||
42 | |||
43 | fi | ||
44 | |||
45 | cat "$SESSION_FILE" | ||