From 9b9c26a515c524d266c0b7c589023b014708a2c1 Mon Sep 17 00:00:00 2001 From: Hannes Date: Thu, 16 Oct 2025 20:59:52 +0200 Subject: [PATCH] added notification as function helper --- .config/function_helper.sh | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .config/function_helper.sh diff --git a/.config/function_helper.sh b/.config/function_helper.sh new file mode 100644 index 0000000..3c916d6 --- /dev/null +++ b/.config/function_helper.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +# Function to check if a directory is already mounted +function is_mounted() { + mountpoint -q "$1" +} + +# Function to send a low-priority notification +function send_low_notification() { + local icon=${3:-"$HOME/.config/swaync/icons/low.png"} + notify-send -u low -i "$icon" "$1" "$2" +} + +# Function to send a normal notification +function send_normal_notification() { + local icon=${3:-"$HOME/.config/swaync/icons/normal.png"} + notify-send -u normal -i "$icon" "$1" "$2" +} + +# Function to send a high-priority notification +function send_high_notification() { + local icon=${3:-"$HOME/.config/swaync/icons/critical.png"} + notify-send -u critical -i "$icon" "$1" "$2" +} + +# Main function to handle the logic +# Example: send_notification "low" "Upper Text" "Lower Text" "icon Path" +function send_notification() { + local priority=$1 + local uppertext=$2 + local lowertext=$3 + local icon=$4 + + case $priority in + low) + send_low_notification "$uppertext" "$lowertext" "$icon" + ;; + normal) + send_normal_notification "$uppertext" "$lowertext" "$icon" + ;; + high) + send_high_notification "$uppertext" "$lowertext" "$icon" + ;; + *) + echo "Usage: $0 {low|normal|high} 'Uppertext' 'Lowertext' [icon]" + ;; + esac +}