chore: Update scripts
This commit is contained in:
parent
caa24fb255
commit
f446486678
4 changed files with 91 additions and 25 deletions
|
@ -1,19 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
# Script to toggle Do not disturb mode for dunst
|
|
||||||
|
|
||||||
# Get current state
|
|
||||||
if [ "$( command -v dunstctl )" ]; then
|
|
||||||
current_state="$( dunstctl is-paused )"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Toggle
|
|
||||||
if [ "${current_state}" == "false" ] ; then
|
|
||||||
notify-send 'Hiding notifications'
|
|
||||||
sleep 5
|
|
||||||
# makoctl set-mode do-not-disturb
|
|
||||||
dunstctl set-paused true
|
|
||||||
else
|
|
||||||
# makoctl set-mode default
|
|
||||||
dunstctl set-paused false
|
|
||||||
notify-send 'Showing notifications'
|
|
||||||
fi
|
|
|
@ -30,10 +30,6 @@ declare -A wallpaper
|
||||||
wallpaper[${THEME_LIGHT}]="bg-light"
|
wallpaper[${THEME_LIGHT}]="bg-light"
|
||||||
wallpaper[${THEME_DARK}]="bg-dark"
|
wallpaper[${THEME_DARK}]="bg-dark"
|
||||||
|
|
||||||
declare -A icon
|
|
||||||
icon[${THEME_LIGHT}]="\uf185"
|
|
||||||
icon[${THEME_DARK}]="\uf186"
|
|
||||||
|
|
||||||
#############
|
#############
|
||||||
### Logic ###
|
### Logic ###
|
||||||
#############
|
#############
|
||||||
|
@ -58,8 +54,8 @@ while getopts ":m:g" option; do
|
||||||
class='activated'
|
class='activated'
|
||||||
percentage=100
|
percentage=100
|
||||||
fi
|
fi
|
||||||
printf '{"text": "%s", "alt": "%s", "tooltip": "Set theme to %s", "percentage": %d, "class": "%s"}' \
|
printf '{"alt": "%s", "tooltip": "Set theme to %s", "percentage": %d, "class": "%s"}' \
|
||||||
"${icon[${current_state}]}" "${gsettings_alt[${next_state}]}" "${next_state}" "${percentage:=0}" "${class:="none"}"
|
"${gsettings_alt[${current_state}]}" "${next_state}" "${percentage:=0}" "${class:="none"}"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
48
scripts/toggle-notifications.sh
Executable file
48
scripts/toggle-notifications.sh
Executable file
|
@ -0,0 +1,48 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# Script to toggle Do not disturb mode for dunst
|
||||||
|
|
||||||
|
# Get current state
|
||||||
|
if [ "$( command -v dunstctl )" ]; then
|
||||||
|
current_state="$( dunstctl is-paused )"
|
||||||
|
fi
|
||||||
|
|
||||||
|
while getopts ":g" option; do
|
||||||
|
case "${option}" in
|
||||||
|
g)
|
||||||
|
if [ "${current_state}" == "false" ]; then
|
||||||
|
state='normal'
|
||||||
|
tooltip='Hide notifications'
|
||||||
|
class='none'
|
||||||
|
else
|
||||||
|
state='paused'
|
||||||
|
tooltip='Show notifications'
|
||||||
|
class='activated'
|
||||||
|
fi
|
||||||
|
printf '{"alt": "%s", "tooltip": "%s", "class": "%s" }' \
|
||||||
|
"${state}" "${tooltip}" "${class}"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Toggle
|
||||||
|
if [ "${current_state}" == "false" ] ; then
|
||||||
|
notify-send 'Hiding notifications'
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
if [ "$(command -v makoctl)" ]; then
|
||||||
|
makoctl set-mode do-not-disturb
|
||||||
|
fi
|
||||||
|
if [ "$(command -v dunstctl)" ]; then
|
||||||
|
dunstctl set-paused true
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ "$(command -v makoctl)" ]; then
|
||||||
|
makoctl set-mode default
|
||||||
|
fi
|
||||||
|
if [ "$(command -v dunstctl)" ]; then
|
||||||
|
dunstctl set-paused false
|
||||||
|
fi
|
||||||
|
|
||||||
|
notify-send 'Showing notifications'
|
||||||
|
fi
|
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