chore: Update scripts
This commit is contained in:
parent
caa24fb255
commit
f446486678
4 changed files with 91 additions and 25 deletions
41
scripts/toggle-tailscale.sh
Executable file
41
scripts/toggle-tailscale.sh
Executable file
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/env bash
|
||||
# Script to toggle Do not disturb mode for dunst
|
||||
|
||||
STOPPED_MSG='Tailscale is stopped'
|
||||
|
||||
# Check if tailscale is installed
|
||||
if [ ! "$( command -v tailscale )" ]; then
|
||||
echo 'Tailscale is not installed!'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get current state
|
||||
status="$( tailscale status )"
|
||||
current_state="$( grep -o "${STOPPED_MSG}" <<< "${status}" )"
|
||||
|
||||
while getopts ":g" option; do
|
||||
case "${option}" in
|
||||
g)
|
||||
if [ "${current_state}" == "${STOPPED_MSG}" ]; then
|
||||
state='disconnected'
|
||||
tooltip='Connect tailnet'
|
||||
else
|
||||
state='connected'
|
||||
tooltip="${status:='Disconnect tailnet'}"
|
||||
fi
|
||||
|
||||
printf '{"alt": "%s", "tooltip": "%q", "class": "%s" }' \
|
||||
"${state}" "${tooltip}" "${state}"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Toggle
|
||||
if [ "${current_state}" == "${STOPPED_MSG}" ] ; then
|
||||
notify-send 'Connecting tailnet'
|
||||
notify-send 'Connected tailnet' "$( tailscale up )"
|
||||
else
|
||||
notify-send 'Disconnecting tailnet'
|
||||
notify-send 'Disconnected tailnet' "$( tailscale down )"
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue