mirror of
https://github.com/tmux-plugins/tmux-continuum.git
synced 2024-11-16 15:38:46 +00:00
Merge 83c5dd098d
into 44e6be6222
This commit is contained in:
commit
b8af4aae1c
34
scripts/continuum_start.sh
Executable file
34
scripts/continuum_start.sh
Executable file
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( dirname "$0" )"
|
||||
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
source "$CURRENT_DIR/variables.sh"
|
||||
|
||||
start_tmux() {
|
||||
local systemd_tmux_server_start_cmd="$(get_tmux_option "${systemd_tmux_server_start_cmd_option}" "${systemd_tmux_server_start_cmd_default}" )"
|
||||
/usr/bin/tmux ${systemd_tmux_server_start_cmd}
|
||||
}
|
||||
|
||||
clean_session() {
|
||||
local sessions_count="$(tmux list-sessions 2>/dev/null | wc -l)"
|
||||
|
||||
if /usr/bin/tmux has-session -t "${tmux_server_session_temporary}"; then
|
||||
# add a new session to preserve server daemon when killing temporary session
|
||||
[ "${sessions_count}" = 1 ] && tmux new-session
|
||||
|
||||
# kill session
|
||||
/usr/bin/tmux kill-session -t "${tmux_server_session_temporary}"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
start_tmux
|
||||
|
||||
# wait detached process of session restoration : start_auto_restore_in_background()
|
||||
# with a sleep 1 inside fetch_and_run_tmux_resurrect_restore_script()
|
||||
#sleep 1
|
||||
|
||||
clean_session
|
||||
}
|
||||
main
|
@ -1,9 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( dirname ${BASH_SOURCE[0]} )"
|
||||
PARENT_DIR="${CURRENT_DIR%/*}"
|
||||
|
||||
source "$CURRENT_DIR/../helpers.sh"
|
||||
source "$CURRENT_DIR/../variables.sh"
|
||||
source "${PARENT_DIR}/helpers.sh"
|
||||
source "${PARENT_DIR}/variables.sh"
|
||||
|
||||
template() {
|
||||
local tmux_start_script="$1"
|
||||
@ -20,11 +21,11 @@ template() {
|
||||
[Service]
|
||||
Type=forking
|
||||
Environment=DISPLAY=:0
|
||||
ExecStart=/usr/bin/tmux ${systemd_tmux_server_start_cmd}
|
||||
ExecStart=${PARENT_DIR}/continuum_start.sh
|
||||
|
||||
ExecStop=${resurrect_save_script_path}
|
||||
ExecStop=/usr/bin/tmux kill-server
|
||||
KillMode=none
|
||||
KillMode=mixed
|
||||
|
||||
RestartSec=2
|
||||
|
||||
@ -47,10 +48,9 @@ enable_tmux_unit_on_boot() {
|
||||
|
||||
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_option}" "${systemd_tmux_server_start_cmd_default}" )"
|
||||
local tmux_start_script_path="${CURRENT_DIR}/linux_start_tmux.sh"
|
||||
local systemd_unit_file=$(template "${tmux_start_script_path}" "${options}")
|
||||
mkdir -p "$(dirname ${systemd_unit_file_path})"
|
||||
[ ! -d "$(dirname ${systemd_unit_file_path})" ] && mkdir -p "$(dirname ${systemd_unit_file_path})"
|
||||
echo "$systemd_unit_file" > "${systemd_unit_file_path}"
|
||||
enable_tmux_unit_on_boot
|
||||
}
|
||||
|
@ -39,5 +39,6 @@ status_wrap_string="\#{value}"
|
||||
systemd_service_name="tmux.service"
|
||||
systemd_unit_file_path="$HOME/.config/systemd/user/${systemd_service_name}"
|
||||
|
||||
tmux_server_session_temporary="tmux-continuum-tmp"
|
||||
systemd_tmux_server_start_cmd_option="@continuum-systemd-start-cmd"
|
||||
systemd_tmux_server_start_cmd_default="new-session -d"
|
||||
systemd_tmux_server_start_cmd_default="new-session -d -s ${tmux_server_session_temporary}"
|
||||
|
Loading…
Reference in New Issue
Block a user