mirror of
https://github.com/tmux-plugins/tmux-continuum.git
synced 2025-09-08 02:47:01 +00:00
initial stab at systemd support for tmux-continuum
This commit is contained in:

committed by
Bruno Sutic

parent
15649e9d07
commit
05a4a827e5
10
scripts/handle_tmux_automatic_start/systemd_disable.sh
Executable file
10
scripts/handle_tmux_automatic_start/systemd_disable.sh
Executable file
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
source "$CURRENT_DIR/../variables.sh"
|
||||
|
||||
main() {
|
||||
systemctl --user disable ${systemd_service_name}
|
||||
}
|
||||
main
|
57
scripts/handle_tmux_automatic_start/systemd_enable.sh
Executable file
57
scripts/handle_tmux_automatic_start/systemd_enable.sh
Executable file
@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -x
|
||||
|
||||
CURRENT_DIR="$( dirname ${BASH_SOURCE[0]} )"
|
||||
|
||||
source "$CURRENT_DIR/../helpers.sh"
|
||||
source "$CURRENT_DIR/../variables.sh"
|
||||
|
||||
template() {
|
||||
local tmux_start_script="$1"
|
||||
shift
|
||||
local options="$@"
|
||||
local content=""
|
||||
|
||||
read -r -d '' content <<-EOF
|
||||
[Unit]
|
||||
Description=tmux default session (detached)
|
||||
Documentation=man:tmux(1)
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=True
|
||||
Environment=DISPLAY=:0
|
||||
ExecStart=/usr/bin/tmux ${systemd_tmux_server_start_cmd}
|
||||
ExecStartPost=/usr/bin/tmux run /home/peteches/.tmux/plugins/tmux-resurrect/scripts/restore.sh
|
||||
|
||||
ExecStop=/home/peteches/.tmux/plugins/tmux-resurrect/scripts/save.sh
|
||||
ExecStop=/usr/bin/tmux kill-server
|
||||
KillMode=none
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
EOF
|
||||
|
||||
echo "$content"
|
||||
}
|
||||
|
||||
systemd_tmux_is_enabled() {
|
||||
systemctl --user is_enabled $(basename "${systemd_unit_file_path}") >/dev/null 2>&1
|
||||
}
|
||||
|
||||
enable_tmux_unit_on_boot() {
|
||||
if ! systemd_tmux_is_enabled; then
|
||||
systemctl --user enable ${systemd_service_name}
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
local options="$(get_tmux_option "$auto_start_config_option" "${auto_start_config_default}")"
|
||||
local systemd_tmux_server_start_cmd="$(get_tmux_option "${systemd_tmux_server_start_cmd}" "${systemd_tmux_default_server_start_cmd}" )"
|
||||
local tmux_start_script_path="${CURRENT_DIR}/linux_start_tmux.sh"
|
||||
local systemd_unit_file=$(template "${tmux_start_script_path}" "${options}")
|
||||
echo "$systemd_unit_file" > "${systemd_unit_file_path}"
|
||||
enable_tmux_unit_on_boot
|
||||
}
|
||||
main
|
Reference in New Issue
Block a user