File: generate-dbus-proxy-interface.sh

package info (click to toggle)
gnome-kiosk 49.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 888 kB
  • sloc: ansic: 8,842; xml: 342; sh: 82; makefile: 6
file content (39 lines) | stat: -rwxr-xr-x 1,922 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh

if [ ! -e "dbus-interfaces/" ]; then
        echo "Please run from top level source directory" > /dev/stderr
        exit 1
fi

export LANG="C.utf-8"

SERVICE="$1"
INTERFACE="${2:-$1}"
OBJECT_PATH="${3:-/$(echo -n ${INTERFACE} | sed 's![.]!/!g')}"
OUTPUT_FILE="dbus-interfaces/${INTERFACE}.xml"

# The sed goo here:
# 1. unescapes new lines and smashes them into a single non-delimiting character
# 2. unescapes anything else (mainly quote marks)
# 3. strips off the s "..." around the result
# 4. smashes </interface> into a single character, so we can do a non-greedy
#    match for it.
# 5. smashes the interface into a single character, so we can do a non-greedy
#    match for it
# 6. do the aforementioned matches to erase all interfaces from output we
#    weren't asked for
# 7. restore </interface> and the interface to their true selves
# 8. likewise, put the new lines back in the stream
busctl call "${SERVICE}" "${OBJECT_PATH}"                                      \
            org.freedesktop.DBus.Introspectable Introspect                     \
       | sed -e 's!\\n!\r!g'                                                   \
             -e 's!\\\(.\)!\1!g'                                               \
             -e 's!s "\(.*\)"$!\1!'                                            \
             -e 's!'${INTERFACE}'!␚!g'                                         \
             -e 's!</interface>!␙!g'                                           \
             -e 's!<interface name="[^␚]*">[^␙]*␙!!g'                          \
             -e 's!␙!</interface>!g'                                           \
             -e 's!␚!'${INTERFACE}'!g'                                         \
             -e 's!\r[\r ]*\r!\r!g'                                            \
             -e 's!\r!\n!g'                                                    \
       > "${OUTPUT_FILE}"