Browser view only. Use the download link if you want to save the file.
Back to Toolbox#!/bin/bash
# Define the DND file name (using absolute path for reliability)
DND_FILE="DND"
# Function to toggle the DND status
toggle_dnd() {
if [ -e "$DND_FILE" ]; then
rm "$DND_FILE"
if [ $? -eq 0 ]; then
RESULT="OFF"
else
echo "Error: Failed to delete '$DND_FILE'." >&2
exit 1
fi
else
touch "$DND_FILE"
if [ $? -eq 0 ]; then
RESULT="ON"
else
echo "Error: Failed to create '$DND_FILE'." >&2
exit 1
fi
fi
echo "$RESULT"
}
# Main function to handle the toggling and status display
main() {
echo "Toggling DND status..."
NEW_STATUS=$(toggle_dnd)
echo "New DND status: $NEW_STATUS"
echo "Displaying YAD dialog..."
yad --info \
--title="DND Status" \
--text="<span foreground='blue' font='12'>DND is now <b>$NEW_STATUS</b>.</span>" \
--text-markup \
--no-buttons \
--timeout=1 \
--width=200 \
--height=70 \
--center \
##--image="dialog-information"
if [ $? -ne 0 ]; then
echo "Error: YAD failed to display the dialog." >&2
exit 1
fi
echo "YAD dialog displayed successfully."
}
# Execute the main function
main