Closed andis-sprinkis closed 8 months ago
Not sure how entirely robust it its, but running sway
in Linux console tty after login does set $WAYLAND_DISPLAY
id variable for each instance, which then can be checked for in the interactive shell init. script (.zshrc).
# configure zsh-system-clipboard
[ "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] && {
export ZSH_SYSTEM_CLIPBOARD_METHOD="xcc"
}
$WAYLAND_DISPLAY
doesn't get set or updated in already running tmux instance though, but may be OK if user doesn't expect to run i3 and Sway in parallel.
I use this hook to automatically update environment in tmux:
# Update current tmux shell envirenment (useful for new ssh connections, X-forwarding, etc)
function tmux-update-env-preexec () {
emulate -L zsh
if [[ -n "$TMUX" || "$TERM" = tmux* || "$TERM_PROGRAM" = 'tmux' ]]; then
eval "${(@MF)${(f)$(tmux showenv -s 2> /dev/null)}:#(* |)(DISPLAY|WAYLAND_DISPLAY|SSH_CONNECTION|SSH_AUTH_SOCK)[=;]*}"
fi
}
add-zsh-hook {,tmux-update-env-}preexec
I also try to avoid putting too much logic into the code, see Please adjust ZSH_SYSTEM_CLIPBOARD_METHOD
yourway in your personal dotfiles, I'm closing.
This extension by default breaks under X11 for those who have installed the i3 WM (X11) with xclip and the Sway WM (Wayland) with wl-clipboard in parallel, as it prioritizes the "wlc".
Here I have terminal running under X11:
(I experience this issue with and without tmux.)
I am wondering if there is a robust way to detect the display server in focus and pick the compatible handler, perhaps real-time, without restarting the shell.