Skip to content

Commit

Permalink
docs: add docker example (#4)
Browse files Browse the repository at this point in the history
This commit adds an example on how tmux-notify can be used within a
docker container.
  • Loading branch information
rickstaa authored Jun 9, 2023
1 parent 88835d1 commit 74f099d
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -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.
11 changes: 11 additions & 0 deletions examples/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions examples/docker/README.md
Original file line number Diff line number Diff line change
@@ -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).
17 changes: 17 additions & 0 deletions examples/docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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.
12 changes: 12 additions & 0 deletions examples/docker/docker_test.bash
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 74f099d

Please sign in to comment.