Compare commits

...

6 Commits

Author SHA1 Message Date
Sven Vowe 10fc73fbd2
Merge bad218eacf into 0698e8f4b1 2024-01-25 12:17:06 +01:00
Bruno Sutic 0698e8f4b1
Merge pull request #132 from rmartine-ias/osx-added-plist
Only add macOS .plist file if contents have changed
2024-01-20 13:37:57 +01:00
Riley Martine e8be48e5e9
Only add macOS .plist file if contents have changed
Saving this file triggers a notification saying that a background item
was added. This happens on startup, every time. It is annoying.

Fixes: https://github.com/tmux-plugins/tmux-continuum/issues/118
2023-12-08 13:26:39 -07:00
Sven Vowe bad218eacf
docs: cleanup and finalization for pr 2022-05-28 17:46:48 +02:00
Sven Vowe f85fc61b60
chore: updated systemd user template to include display and target 2022-05-28 17:41:22 +02:00
Sven Vowe b8358c79ef
docs: added linux systemd setup configuration 2022-05-28 14:39:19 +02:00
3 changed files with 71 additions and 2 deletions

View File

@ -10,4 +10,69 @@ To control the tmux service you can use all the standard `systemctl` commands us
systemctl --user status tmux.service
## Manual setup example
To be able to configure systemd user services, make sure the following directories exist: `$HOME/.config/systemd/user`. If not, create them:
```shell
mkdir ~/.config/systemd
mkdir ~/.config/systemd/user
```
Create the systemd user service file:
```shell
touch ~/.config/systemd/user/tmux.service
```
The service file can be created from this template:
```shell
[Unit]
Description=tmux default session (detached)
Documentation=man:tmux(1)
After=graphical.target
[Service]
Type=forking
Environment=DISPLAY=:1
ExecStart=/usr/bin/tmux new-session -d
ExecStop=/home/user/.tmux/plugins/tmux-resurrect/scripts/save.sh
ExecStop=/usr/bin/tmux kill-server
KillMode=mixed
RestartSec=2
[Install]
WantedBy=default.target
```
Make sure you adapt the service file to your needs:
- `Environment`: Set the value of your $DISPLAY environment variable (i.e. `:1`, to find out run `echo $DISPLAY`)
- `ExecStart`: If you want to configure the tmux start command, you can do it here
- `ExecStop`: Enter the full path to the `save.sh` script of `tmux-resurrect`, usually in `$HOME/.tmux/plugins/tmux-resurrect/scripts/save.sh`
- `After`: Adapt to your needs, waiting for `graphical.target` helps if you want to open gui applications such as `code` directly from your resurrected terminals
Enable and start your systemd user service:
```shell
systemctl --user enable tmux.service
systemctl --user start tmux.service
```
- Reboot your machine
- To check the current status of your tmux service, run this command:
```shell
systemctl --user status tmux.service
```
You should see something along the lines of:
```shell
Active: active (running)
Docs: man:tmux(1)
Process: 6300 ExecStart=/usr/bin/tmux new-session -d (code=exited, status=0/SUCCESS)
CGroup: /user.slice/user-xxxx.slice/user@xxxx.service/app.slice/tmux.service
├─ 6306 /usr/bin/tmux new-session -d
├─ 7735 zsh
...
```

View File

@ -65,6 +65,8 @@ main() {
local tmux_start_script_path="${CURRENT_DIR}/osx_${strategy}_start_tmux.sh"
local launchd_plist_file_content="$(template "$tmux_start_script_path" "$fullscreen_option_value")"
echo "$launchd_plist_file_content" > "$osx_auto_start_file_path"
if ! diff "$osx_auto_start_file_path" <(echo "$launchd_plist_file_content") &>/dev/null ; then
echo "$launchd_plist_file_content" > "$osx_auto_start_file_path"
fi
}
main

View File

@ -15,15 +15,17 @@ template() {
local content=""
local resurrect_save_script_path="$(get_tmux_option "$resurrect_save_path_option" "$(realpath ${CURRENT_DIR}/../../../tmux-resurrect/scripts/save.sh)")"
local tmux_path="$(command -v tmux)"
local display="$DISPLAY"
read -r -d '' content <<-EOF
[Unit]
Description=tmux default session (detached)
Documentation=man:tmux(1)
After=graphical.target
[Service]
Type=forking
Environment=DISPLAY=:0
Environment=DISPLAY=${display}
ExecStart=${tmux_path} ${systemd_tmux_server_start_cmd}
ExecStop=${resurrect_save_script_path}