diff --git a/README.md b/README.md index bb5e1a7..7cef965 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,13 @@ Tmux plugin to notify you when processes are complete. - [Usage](#usage) - [Pre-requisites](#pre-requisites) - [Configuration](#configuration) + - [Enable verbose notification](#enable-verbose-notification) + - [Enable telegram channel notifications](#enable-telegram-channel-notifications) + - [Change monitor update period](#change-monitor-update-period) + - [Add additional shell suffixes](#add-additional-shell-suffixes) - [How does it work](#how-does-it-work) +- [Other use cases](#other-use-cases) + - [Use inside a docker container](#use-inside-a-docker-container) - [Contributing](#contributing) - [References](#references) @@ -108,6 +114,12 @@ Feel free to open [a pull](https://github.com/rickstaa/tmux-notify/pulls) reques A naive approach. Checks if pane content ends with the bash prompt suffixes mentioned above every 10 seconds. +## Other use cases + +### Use inside a docker container + +Because tmux-notify uses [libnotify](https://gitlab.gnome.org/GNOME/libnotify) to send notifications, it needs access to the host's D-Bus socket. An excellent guide on how to do this can be found [here](https://github.com/mviereck/x11docker/wiki/How-to-connect-container-to-DBus-from-host#dbus-user-session-daemon). You can also check out the [examples/docker](examples/docker/README.md) folder for an example. + ## Contributing Feel free to open an issue if you have ideas on how to make this GitHub action better or if you want to report a bug! All contributions are welcome. :rocket: Please consult the [contribution guidelines](CONTRIBUTING.md) for more information. diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..56eafe4 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,5 @@ +# Examples + +This folder contains several examples on how to use tmux-notify in different scenarios: + +- ``docker``: A simple example on how to make tmux-notify work inside a docker container. diff --git a/examples/docker/Dockerfile b/examples/docker/Dockerfile new file mode 100644 index 0000000..3bf4099 --- /dev/null +++ b/examples/docker/Dockerfile @@ -0,0 +1,11 @@ +# A small Dockerfile to build a container in which tmux-notify can be tested. +FROM ubuntu:latest + +# Install required packages. +RUN apt-get update +RUN apt-get upgrade -y +RUN apt-get install -y \ + libnotify-bin \ + dbus \ + tmux \ + git diff --git a/examples/docker/README.md b/examples/docker/README.md new file mode 100644 index 0000000..91dc992 --- /dev/null +++ b/examples/docker/README.md @@ -0,0 +1,9 @@ +# Docker example + +This example shows how to make tmux-notify work inside a docker container. You can test it out by executing the following inside your terminal: + +```bash +bash docker_test.sh +``` + +This command will open a Tmux session inside a docker container, and if you have installed [tmp](https://github.com/tmux-plugins/tpm) and [tmux-notify](https://github.com/rickstaa/tmux-notify), on your host machine you should be able to use [tmux-notify](https://github.com/rickstaa/tmux-notify) as usual. For more information on how this works, see [this guide](https://github.com/mviereck/x11docker/wiki/How-to-connect-container-to-DBus-from-host#dbus-user-session-daemon). diff --git a/examples/docker/docker-compose.yml b/examples/docker/docker-compose.yml new file mode 100644 index 0000000..8ec6d00 --- /dev/null +++ b/examples/docker/docker-compose.yml @@ -0,0 +1,17 @@ +version: "3" +services: + app: + image: tmux-notify-test:latest + build: . + environment: + - DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus # Replace with your user id. + security_opt: + - apparmor:unconfined + volumes: + - /run/user/1000/bus:/run/user/1000/bus # Replace with your user id. + - /etc/group:/etc/group:ro + - /etc/passwd:/etc/passwd:ro + - $HOME/.tmux:$HOME/.tmux # Your tmux folder. + - $HOME/.tmux.conf:$HOME/.tmux.conf # Your tmux config. + - $HOME/.tmux.conf.local:$HOME/.tmux.conf.local # Your tmux local config. + user: 1000:1000 # Replace with your user / group id. diff --git a/examples/docker/docker_test.bash b/examples/docker/docker_test.bash new file mode 100644 index 0000000..fb9c28c --- /dev/null +++ b/examples/docker/docker_test.bash @@ -0,0 +1,12 @@ +# Command line example with all parameters needed to run tmux-notify inside a docker container. +docker build -t tmux-notify-docker-test:latest . +docker run -e DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus \ +-v /run/user/1000/bus:/run/user/1000/bus \ +-v /etc/group:/etc/group:ro \ +-v /etc/passwd:/etc/passwd:ro \ +-v $HOME/.tmux:$HOME/.tmux \ +-v $HOME/.tmux.conf:$HOME/.tmux.conf \ +-v $HOME/.tmux.conf.local:$HOME/.tmux.conf.local \ +--security-opt apparmor=unconfined \ +-u $(id -u):$(id -g) \ +-it tmux-notify-docker-test:latest tmux