aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/%HOME%/.xsessionrc
blob: 5a625d43590e7971ffc60dc30a013018551d4c20 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# .xsessionrc might only be read on Debian and its derivatives like Ubuntu.

# This is a workaround to make notify-send inside cron jobs work.
# Thanks to this dude: https://unix.stackexchange.com/a/111190/60124
# Then you source ~/.dbus.sh inside your cron job, and voilà!
export_dbus_variables() {
    local output_path="$HOME/.dbus.sh"
    local printf_path
    rm -f -- "$output_path"
    # dash's built-in printf (as opposed to bash's) doesn't support %q.
    touch -- "$output_path" \
        && chmod 0600 -- "$output_path" \
        && [ -n "${DBUS_SESSION_BUS_ADDRESS+x}" ] \
        && printf_path="$( which printf )" \
        && "$printf_path" -- 'export DBUS_SESSION_BUS_ADDRESS=%q\n' "$DBUS_SESSION_BUS_ADDRESS" > "$output_path"
}

export_dbus_variables