-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Systemd: Modifications to remove new session after restoration #83
base: master
Are you sure you want to change the base?
Changes from all commits
4c6b1da
3007c86
400724b
28a7663
83c5dd0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
|
@@ -19,11 +20,11 @@ template() { | |
[Service] | ||
Type=forking | ||
Environment=DISPLAY=:0 | ||
ExecStart=/usr/bin/tmux ${systemd_tmux_server_start_cmd} | ||
ExecStart=${PARENT_DIR}/continuum_start.sh | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use a local script to start tmux daemon in place a /usr/bin/tmux |
||
|
||
ExecStop=${HOME}/.tmux/plugins/tmux-resurrect/scripts/save.sh | ||
ExecStop=/usr/bin/tmux kill-server | ||
KillMode=none | ||
KillMode=mixed | ||
|
||
RestartSec=2 | ||
|
||
|
@@ -46,10 +47,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})" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prevent error when creates existing path (script is executed at each start) |
||
echo "$systemd_unit_file" > "${systemd_unit_file_path}" | ||
enable_tmux_unit_on_boot | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,5 +36,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}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. starts the daemon with a named session to allow to kill it after starting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set a parent properly