dotfiles icon indicating copy to clipboard operation
dotfiles copied to clipboard

[FEATURE] Document how to spawn child terminals from Waybar

Open zzvara opened this issue 4 months ago • 0 comments

I'm using a Waybar module in an Arch Linux Hyprland setup, where my .config/waybar/modules.json is set as follows:

  "custom/clusterteleport": {
    "format": " Cluster Teleport",
    "escape": true,
    "on-click": "$(cat ~/.config/ml4w/settings/terminal.sh) --class dotfiles-floating -e ~/.config/ml4w/scripts/cluster-teleport.sh"
  },

The terminal is:

cat ~/.config/ml4w/settings/terminal.sh
alacritty%

The cluster-teleport.sh is as follows:

#!/bin/bash

sleep 0.1
clear
figlet -f smslant "Teleport to Cluster"
echo

pkill tsh -9
sleep 0.1
tsh kube login cluster
tsh proxy kube -p 8443 > /home/user/log/cluster-teleport-proxy-kube 2>&1 &

# ------------------------------------------------------
# Start K9S?
# ------------------------------------------------------

sleep 0.1

if gum confirm "DO YOU WANT TO START K9S?" ;then
    bash -c "export KUBECONFIG=/home/user/.tsh/keys/cluster/user-kube/cluster/localproxy-8443-kubeconfig && exec alacritty --hold -e k9s &"
    disown
    sleep 0.6
    exit
fi

echo "Press [ENTER] to close."
read

If I open an Alacritty terminal from Arch, the cluster-teleport.sh works correctly. Ultimately, it opens up K9S in another Alacritty terminal, and the original Alacritty that ran the script can be closed. The K9S will keep running in the new terminal.

However, when running the script through Waybar, it will close the K9S terminal when the original script terminates. Even the command proxy kube -p 8443 gets terminated when the terminal that got opened from Waybar terminates.

I created a button similar to how the update feature works in ML4W.

image

I tried many things while starting K9S, but none of them worked. I tried nohup and similar tools as well. My last attempt is what you can see above.

zzvara avatar Oct 19 '24 20:10 zzvara