Last active
March 3, 2018 13:28
-
-
Save bebehei/0a677b8179db695d67168c63af02580a to your computer and use it in GitHub Desktop.
dunst-docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine | |
RUN apk add --no-cache \ | |
cairo \ | |
dbus \ | |
glib \ | |
gtk+3.0 \ | |
libxdg-basedir \ | |
libxft \ | |
libxinerama \ | |
libxrandr \ | |
libxscrnsaver \ | |
pango \ | |
&& apk add --no-cache --virtual dunstbuild \ | |
cairo-dev \ | |
dbus-dev \ | |
gcc \ | |
git \ | |
glib-dev \ | |
gtk+3.0-dev \ | |
libxdg-basedir-dev \ | |
libxft-dev \ | |
libxinerama-dev \ | |
libxrandr-dev \ | |
libxscrnsaver-dev \ | |
make \ | |
musl-dev \ | |
pango-dev \ | |
&& git clone https://github.com/dunst-project/dunst /tmp/dunst \ | |
&& sed -i 's/-g//g' /tmp/dunst/config.mk \ | |
&& make -C /tmp/dunst -j $(nproc) all install \ | |
&& rm -rf /tmp/dunst \ | |
&& apk del --purge dunstbuild | |
ADD entrypoint.sh /srv/entrypoint | |
ENTRYPOINT ["/srv/entrypoint"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
export USER_UID=${USER_UID:-1000} | |
export USER_GID=${USER_GID:-1000} | |
export USER_NAME=${USER_NAME:-dunstuser} | |
id -g $USER_NAME 2>/dev/null >/dev/null || addgroup -g $USER_GID $USER_NAME | |
id -u $USER_NAME 2>/dev/null >/dev/null || adduser -D -u $USER_UID -G $USER_NAME $USER_NAME | |
su $USER_NAME -s /bin/sh -c "/usr/local/bin/dunst -conf /tmp/dunstrc $*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
IMAGE=bebehei/dunst | |
XSOCK=/tmp/.X11-unix | |
[ -z "${DBUS_SESSION_BUS_ADDRESS}" ] && echo '$DBUS_SESSION_BUS_ADDRESS missing' && exit 1 | |
[ -z "${DISPLAY}" ] && echo '\$DISPLAY missing' && exit 1 | |
# Build image on the fly, if not available yet | |
docker image inspect "${IMAGE}" &>/dev/null || ([ -f Dockerfile ] && docker build -t "${IMAGE}" .) | |
XAUTH=$(mktemp) | |
DBUS_PATH=$(echo ${DBUS_SESSION_BUS_ADDRESS} | cut -d = -f 2) | |
touch ~/.config/dunst/dunstrc | |
xauth nlist :0 | sed -e 's/^..../ffff/' | xauth -f ${XAUTH} nmerge - | |
docker run -it --rm \ | |
--cap-add=SYS_ADMIN \ | |
--env="USER_UID=$(id -u)" \ | |
--env="USER_GID=$(id -g)" \ | |
--env="USER_NAME=$(id -un)" \ | |
--env="DISPLAY" \ | |
--env="DBUS_SESSION_BUS_ADDRESS" \ | |
--env="XAUTHORITY=${XAUTH}" \ | |
--volume=${DBUS_PATH}:${DBUS_PATH} \ | |
--volume=${XSOCK}:${XSOCK} \ | |
--volume=${XAUTH}:${XAUTH} \ | |
--volume=$HOME/.config/dunst/dunstrc:/tmp/dunstrc:ro \ | |
--volume=/usr/share/icons:/usr/share/icons:ro \ | |
--volume=/usr/share/fonts:/usr/share/fonts:ro \ | |
${IMAGE} $* | |
rm ${XAUTH} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment