diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2018-06-04 15:09:47 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2018-06-04 15:09:47 +0300 |
commit | 1f5ebdab58df42f21512c81d7712701c468e9195 (patch) | |
tree | 01b0b31ff37017609073c173cc9dfa88abb9986e /%HOME%/.xsessionrc | |
parent | spawn_ssh_agent: refactoring (diff) | |
download | linux-home-1f5ebdab58df42f21512c81d7712701c468e9195.tar.gz linux-home-1f5ebdab58df42f21512c81d7712701c468e9195.zip |
.xsessionrc: refactoring
Diffstat (limited to '')
-rw-r--r-- | %HOME%/.xsessionrc | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/%HOME%/.xsessionrc b/%HOME%/.xsessionrc index 6ee3124..5a625d4 100644 --- a/%HOME%/.xsessionrc +++ b/%HOME%/.xsessionrc @@ -3,8 +3,16 @@ # 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Ă ! -touch -- "$HOME/.dbus.sh" \ - && chmod 0600 -- "$HOME/.dbus.sh" \ - && [ -n "${DBUS_SESSION_BUS_ADDRESS+x}" ] \ - && command -v printf > /dev/null 2>&1 \ - && printf -- 'export DBUS_SESSION_BUS_ADDRESS=%q\n' "$DBUS_SESSION_BUS_ADDRESS" > "$HOME/.dbus.sh" +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 |